How can I show data from table which have for example certain place, I need to make like dropdown menu with places and when I choice one I need statistic from that one, I have already made base here is page www.anketa.comli.com At the end of page is dropdown that I need to finish. can someone help?

Here I can make english version for example www.anketa.comli.com/index1.php

I need to get statistic by locations, like for location example 1 how much voted for Yes how much No, then How much trust Suzana etc... anyone got me?

So you want to select a city at the end of the form and see the statistics for that city (please note: on english version the select element for cities at the end is missing)? Do you want to see results on the same page or on different page (your action attribute of the form is currently set to the index.php)? It would be easier if you post some PHP code here.

its not important really, am not doing design I need code only, we will separate it later, I just need code to show all votes and numbers from base for certain location like SELECT FROM anketa WHERE location='example1'

yes in english version there is missing at the end dropdown with locations, but I put it there just to show example, I dont know how to make dropdown menu and when you click on some location to go to next page with statistic from that location, I need code for that

There is no one who write the code for you. Post what you've and what you got. We'll point you the correct way.

bump, I need code to show data from base, idk SELECT * FROM anketa WHERE location='exaple' not working.... anyone help?

here is full code of index

<?php 
include 'dbc.php';

$err = array();
					 
if($_POST['doSubmit'] == 'Submit') 
{ 

foreach($_POST as $key => $value) {
	$data[$key] = filter($value);
}






	  
$user_ip = $_SERVER['REMOTE_ADDR'];
$date = date("m-d-Y, h:i:s a", time());

$sha1pass = PwdHash($data['pwd']);

$host  = $_SERVER['HTTP_HOST'];
$host_upper = strtoupper($host);
$path   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');







if(empty($err)) {
$sql_insert = "INSERT into `anketa`(`mesto`,`ime`,`broj_clanova`,`clanova_sa_pravom_glasa`,`adresa`,`broj_zaposlenih`,`broj_nezaposlenih`,`broj_penzionera`,`clan_stranke`,`ime_stranke`,`glavni_problem`,`predlog_resenja`,`sporedni_problemi`,`predlog_resenja2`,`politicar`,`sps`,`razlog`,`ako_ne`) VALUES ('$data[mesto]','$data[ime]','$data[broj_clanova]','$data[clanova_sa_pravom_glasa]','$data[adresa]','$data[broj_zaposlenih]','$data[broj_nezaposlenih]','$data[broj_penzionera]','$data[clan_stranke]','$data[ime_stranke]','$data[glavni_problem]','$data[predlog_resenja]','$data[sporedni_problemi]','$data[predlog_resenja2]','$data[politicar]','$data[sps]','$data[razlog]','$data[ako_ne]')";
			
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
$user_id = mysql_insert_id($link);  
$md5_id = md5($user_id);
mysql_query("update users set md5_id='$md5_id' where id='$user_id'");
//	echo "<h3>Thank You</h3> We received your submission.";



  header("Location: hvala.php");  
  exit();
	 
	 } 
 }					 

?>
<html>
<head>
<title>Anketa</title>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr> 
    <td width="160" valign="top"><p>&nbsp;</p>
      <p>&nbsp; </p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    <td width="732" valign="top"><p>
	<?php 
	 if (isset($_GET['done'])) { ?>
	  <h2>Hvala</h2>;
	 <?php exit();
	  }
	?>
	 <?php	
	 if(!empty($err))  {
	   echo "<div class=\"msg\">";
	  foreach ($err as $e) {
	    echo "* $e <br>";
	    }
	  echo "</div>";	
	   }
	 ?> 
	 
	  <br>
      <form action="index.php" method="post" name="regForm" id="regForm" >

<p>Mesna zajednica 
<select name="mesto">
<option value="donji_grad">Donji Grad</option>
<option value="karadjordjev_dud">Karadjordjev Dud</option>
<option value="plavinac">Plavinac</option>
<option value="seone">Seone</option>
<option value="ladna_voda">Ladna Voda</option>
<option value="lestar">Lestar</option>
<option value="zlatno_brdo">Zlatno Brdo</option>
<option value="slavija">Slavija</option>
<option value="papazovac">Papazovac</option>
<option value="carina">Carina</option>
<option value="sveti_sava">Sveti Sava</option>
<option value="25maj">25. Maj</option>
<option value="udovice">Udovice</option>
<option value="lipe">Lipe</option>
<option value="mihajlovac">Mihajlovac</option>
<option value="vranovo">Vranovo</option>
<option value="radinac">Radinac</option>
<option value="mala_krsna">Mala Krsna</option>
<option value="skobalj">Skobalj</option>
<option value="osipaonica">Osipaonica</option>
<option value="drugovac">Drugovac</option>
<option value="badljevica">Badljevica</option>
<option value="salinac">Salinac</option>
<option value="kulic">Kulic</option>
<option value="suvodol">Suvodol</option>
<option value="lunjevac">Lunjevac</option>
<option value="landol">Landol</option>
<option value="petrijevo">Petrijevo</option>
<option value="kolari">Kolari</option>
<option value="binovac">Binovac</option>
<option value="lugavcina">Lugavcina</option>
<option value="saraorci">Saraorci</option>
<option value="vucak">Vucak</option>
<option value="vrbovac">Vrbovac</option>
<option value="ralja">Ralja</option>
<option value="dobri_do">Dobri Do</option>
<option value="vodanj">Vodanj</option>
<option value="malo_orasje">Malo Orasje</option>
</select></p>



<p>Ime i prezime <input name="ime" type="text" id="ime" size="40"></p>

<p>Broj clanova domacinstva <input name="broj_clanova" type="text" id="broj_clanova" size="20"></p>

<p>Clanova sa pravom glasa <input name="clanova_sa_pravom_glasa" type="text" id="clanova_sa_pravom_glasa" size="20"></p>

<p>Ulica i broj <input name="adresa" type="text" id="adresa" size="40"></p>

<p>Broj zaposlenih u domacinstvu <input name="broj_zaposlenih" type="text" id="broj_zaposlenih" size="40"></p>

<p>Broj ne zaposlenih <input name="broj_nezaposlenih" type="text" id="broj_nezaposlenih" size="20"></p>

<p>Broj penzionera clanova domacinstva <input name="broj_penzionera" type="text" id="broj_penzionera" size="20"></p>

<p>Da li ste Vi ili neko od clanova vaseg domacinstva clanovi neke stranke i koje, ako nije tajna: Da<input name="clan_stranke" type="radio" id="clan_stranke" value="da">   Ne<input name="clan_stranke" type="radio" id="clan_stranke" value="ne">
<select name="ime_stranke">
<option value="" selected="selected"></option>
<option value="ds">DS</option>
<option value="sps">SPS</option>
<option value="srs">SRS</option>
<option value="sns">SNS</option>
<option value="pzs">PZS</option>
<option value="kzbs">KZBS</option>
<option value="urs">URS</option>
<option value="ldp">LDP</option>
<option value="ostali">Ostali</option>
</select></p>

<p>Problemi u vasoj okolini:</p>

<p>Glavni problem: <input name="glavni_problem" type="text" id="glavni_problem" size="200"></p>

<p>Predlog resenja: <input name="predlog_resenja" type="text" id="predlog_resenja" size="200"></p>

<p>Sporedni problemi: <input name="sporedni_problemi" type="text" id="sporedni_problemi" size="200"></p>

<p>Predlog resenja: <input name="predlog_resenja2" type="text" id="predlog_resenja2" size="200"></p>

<p>Kom smederevskom politicaru najvise verujete:<br><br>
1. Suzana Spasojevic <input name="politicar" type="checkbox" id="politicar" value="suzana_spasojevic"><br>
2. Brance Stojanovic <input name="politicar" type="checkbox" id="politicar" value="brance_stojanovic"><br>
3. Predrag Umicevic <input name="politicar" type="checkbox" id="politicar" value="predrag_umicevic"><br>
4. Jasna Avramovic <input name="politicar" type="checkbox" id="politicar" value="jasna_avramovic"><br>
5. Sasa Radosavljevic <input name="politicar" type="checkbox" id="politicar" value="sasa_radosavljevic"><br>
6. Milan Lukic <input name="politicar" type="checkbox" id="politicar" value="milan_lukic"><br>
7. Dragan Sormaz <input name="politicar" type="checkbox" id="politicar" value="dragan_sormaz"></p>

<p>Da li biste glasali za SPS? Da<input name="sps" type="radio" id="sps" value="da"> Ne<input name="sps" type="radio" id="sps" value="ne"> Mozda<input name="sps" type="radio" id="sps" value="mozda"></p>
        
<p>Zasto bi ste glasali/ne bi ste glasali: <input name="ako_ne" type="text" id="ako_ne" size="200"></p> 		
		
<p>Ako je odgovor ne, za koga bi glasali? <select name="ako_ne">
<option value="ds">DS</option>
<option value="sps">SPS</option>
<option value="srs">SRS</option>
<option value="sns">SNS</option>
<option value="pzs">PZS</option>
<option value="kzbs">KZBS</option>
<option value="urs">URS</option>
<option value="ldp">LDP</option>
<option value="ostali">Ostali</option>
<option value="ni_za_koga"  selected="selected">Ni za koga</option>
</select></p>
		
		<p align="center">
          <input name="doSubmit" type="submit" id="doSubmit" value="Submit">
        </p>
      </form>
   
	   
      </td> 
    <td width="196" valign="top">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
</table>

Pokazi statistiku za <select name="">
<option value="donji_grad">Donji Grad</option>
<option value="karadjordjev_dud"><a href="karadjordjev_dud.php">Karadjordjev Dud</a></option>
<option value="plavinac">Plavinac</option>
<option value="seone">Seone</option>
<option value="ladna_voda">Ladna Voda</option>
<option value="lestar">Lestar</option>
<option value="zlatno_brdo">Zlatno Brdo</option>
<option value="slavija">Slavija</option>
<option value="papazovac">Papazovac</option>
<option value="carina">Carina</option>
<option value="sveti_sava">Sveti Sava</option>
<option value="25maj">25. Maj</option>
<option value="udovice">Udovice</option>
<option value="lipe">Lipe</option>
<option value="mihajlovac">Mihajlovac</option>
<option value="vranovo">Vranovo</option>
<option value="radinac">Radinac</option>
<option value="mala_krsna">Mala Krsna</option>
<option value="skobalj">Skobalj</option>
<option value="osipaonica">Osipaonica</option>
<option value="drugovac">Drugovac</option>
<option value="badljevica">Badljevica</option>
<option value="salinac">Salinac</option>
<option value="kulic">Kulic</option>
<option value="suvodol">Suvodol</option>
<option value="lunjevac">Lunjevac</option>
<option value="landol">Landol</option>
<option value="petrijevo">Petrijevo</option>
<option value="kolari">Kolari</option>
<option value="binovac">Binovac</option>
<option value="lugavcina">Lugavcina</option>
<option value="saraorci">Saraorci</option>
<option value="vucak">Vucak</option>
<option value="vrbovac">Vrbovac</option>
<option value="ralja">Ralja</option>
<option value="dobri_do">Dobri Do</option>
<option value="vodanj">Vodanj</option>
<option value="malo_orasje">Malo Orasje</option>
</select></p>


</body>
</html>

now I need to edit last dropdown with locations and add to each option to show statistics from questionnaire from above if someone chose that location, I need total votes and numbers from that location

First, you have to give name to the select element on line 210 (i.e. cities).

Pokazi statistiku za <select name="cities">

Where do you want to display the statistics? Is it on the same page? If yes then you have to save all the values that user has already filled in, otherwise they can get very anoyed seeing the empty form (the form will empty on submission).

Basicaly the principle is that when you check for form submission with f($_POST['doSubmit'] == 'Submit') you can check whether $_POST exists (userhas selected a city). If it exists you can fire the query and store the result in a string which will be displayed somewhere on the page. Add the following code to your if block on line 6:

foreach($_POST as $key => $value) {
    $data[$key] = filter($value);
}

// check if any value was posted for cities
if(isset($data['cities'])) {

    // query for getting statistics from anketa table
    $query_c = "SELECT * FROM anketa WHERE location='" . $data['cities'];

    // execute the query
    $res = mysql_query($query_c,$link) or die("Error:" . mysql_error());

    // store the result of your query in the $row array
    $stat = mysql_fetch_assoc($res);

    // string for displaying statitics
    $stat_string = '<ul>';

    // $stat array now contains all the fields from anketa table (whatever they are)
    // you can now loop through them using foreach and store them in a string
    foreach($stat as $field => $data) {

        $stat_string .= "<li>$field: $data</li>";
    }

    $stat_string .= "</ul>";
}

Now you can display the string somewhere on the page echo $stat_string; .

Still better option would be to use ajax but if you are not familiar with it you need some time to study it.

yes but let assume I want on other page, I have base already with some data, I want to show data where location is only example landol, and I need dropdown menu where people will chose what location to see

What to put in <option value="????">????</option> to go to page with selected location statistic

If I put in select name="cities" that will go to base where I already have option from above for people to chose locations

Mesto is location in my language

When someone select location in first dropdown menu, it goes to base and all other votings and comments from that person, now I need to show all that data when someone chose that location later to see statistic

when I add this code just mesto instead of cities

foreach($_POST as $key => $value) {
    $data[$key] = filter($value);
    }
     
    // check if any value was posted for cities
    if(isset($data['cities'])) {
     
    // query for getting statistics from anketa table
    $query_c = "SELECT * FROM anketa WHERE location='" . $data['cities'];
     
    // execute the query
    $res = mysql_query($query_c,$link) or die("Error:" . mysql_error());
     
    // store the result of your query in the $row array
    $stat = mysql_fetch_assoc($res);
     
    // string for displaying statitics
    $stat_string = '<ul>';
     
    // $stat array now contains all the fields from anketa table (whatever they are)
    // you can now loop through them using foreach and store them in a string
    foreach($stat as $field => $data) {
     
    $stat_string .= "<li>$field: $data</li>";
    }
     
    $stat_string .= "</ul>";
    }

nothing is showed

I think you need to use some JavaScript to write the location

some thing like this

<head>
<script language="JavaScript">
	function goPage (newURL) 
	{
	// This function is called from the pop-up menus to transfer to
	// a different page. Ignore the value returned is a null string
	
	   	if (newURL != "") 
		{
	   	
	// skip the menu dividers and reset the menu selection to default
	   		if (newURL == "-" ) 
			{
				resetMenu();			
			} else {  
	// send page to designated URL		 	
	   			document.location.href = newURL;
	   		}
	   	}
	}
	
	function resetMenu() 
		{
	// resets the menu selection upon entry to this page
	   document.gomenu.selector.selectedIndex = 2;
	}
	</script>
</head>

and this

<?
								$query = "select distinct country from hotels";
								$hotels_result= mysql_query($query) or trigger_error("SQL", E_USER_ERROR);
								$hotels_num = 0;
								$hotels_num = mysql_num_rows($hotels_result);
								$i = 0;
								$x = 0;
							
							    while($i < $hotels_num) 
									{
										$id = mysql_result($hotels_result,$i,"country");
										$x = $x + 1;
										$i++;
									}
						?>
                              <script language="javascript">
						
							locations_text = new Array(<?=$x?>);
							locations_text [0] = new Array(1)
						//arrays for the text
							 <?   
							 		$hotels_num = $x+1;
									$n = 1;
							 		while($n < $hotels_num) 
									{
										echo"locations_text [$n] = new Array(1);";
										$n++;
									}
							?>
							//arrays for values	
							locations_values = new Array(<?=$x?>);
							locations_values [0] = new Array(1)	
							<?
									
							 		$hotels = $x+1;
									$m = 1;
							 		while($m < $hotels) 
									{
										echo"locations_values [$m] = new Array(1);";
										$m++;
									}		
									
									
									
								$queryfnum = "select distinct country from hotels order by country asc";
								$routes_result4= mysql_query($queryfnum) or trigger_error("SQL", E_USER_ERROR);
								$routes_num4 = 0;
								$routes_num4 = mysql_num_rows($routes_result4);
								$i = 0;
								$z = 1;
								$today_date = date("y-m-d");
							
							    while($i < $hotels_num4) 
									{
									   $country = mysql_result($hotels_result4,$i,"country");
													$query1 = "select hotel from hotels where country='$country' and isshow='$Yes' and  id='$id' order by hotel asc";
													$result1 = mysql_query($query1);
													$y = 0;
													$num_results = mysql_num_rows($result1);
													while ($row = mysql_fetch_array($result1))
													{
														$id = $row['hotel'];
														$hotel = $row['hotel'];


															echo "locations_text [$z][$y] = '$hotel';";
															echo "locations_values [$z][$y] = '$hotel';";
													 $y = $y + 1;
													}		
										 $z = $z + 1;
										$i++;
									}			
										
								?>
						
							//============================================
							//function to write the locations
						
							function writeLocations11(theObject)
							{
								theForm = theObject.form;
								var regionnum=theForm.country.selectedIndex;
							
								theForm.hotel.selectedIndex = 0;
								for ( x=0;x<locations_text[regionnum].length;x++)
								 {
								 theForm.hotel.options[x] = new Option(locations_text[regionnum][x], locations_values[regionnum][x]);
								 }
							
								theForm.hotel.length = x;
								theForm.hotel.focus();
							}
							
						//-->
						      </script>
                              <select class=bodyTxt name=country onChange=goPage(this.options[this.selectedIndex].value)>
                                <option>-- select region --</option>
                                <?
									$country = $_GET['nav'];
									$query = "select distinct country from hotels";
									$result = mysql_query($query);
									$num_results = mysql_num_rows($result);
									while ($row = mysql_fetch_array($result))

									{
										$hotel = $row['hotels'];
										$s_country = $row['country'];
										if($country == $s_country)
										{
											echo"<option value='restaurants.php?nav=$s_country' selected>$s_country</option>";
										}
										else
										{
											echo"<option value='restaurants.php?nav=$s_country'>$s_country</option>";										
										}

									}
								?>
                            </select>
                            <input type=hidden name=country value=<?=$hotels?>>
                            <input type=hidden name=country value=<?=$country?>>
                            </td>
                          </tr>
                        </table>
						<table width="100%" border="0" cellspacing="1" cellpadding="1">
                              <tr>
                                <td><div style="border-bottom-style:dotted"></td>
                              </tr>
                          </table>
                         

                          
		 			<?
$country = $_GET['nav'];
						$query = "select distinct hotel FROM hotels where country='$country' order by hotel desc";
						$pager = new PS_Pagination($conn,$query,20,10);
						$rs = $pager->paginate();
						while($row = mysql_fetch_assoc($rs)) 
				
						{
							$hotel = $row['hotel'];
					//$urlname = urlencode($name);
									/*$id = $_GET['id'];
									$query = "select * FROM hotels where country='$country' and isshow='Yes'";
									//select distinct country from hotels
									//$pager = new PS_Pagination($conn,$query,5,5);
									//$rs = $pager->paginate();
									$pager = new PS_Pagination($conn,$query,15,15);
									$rs = $pager->paginate();
									$result = mysql_query($query);
									$num_results = mysql_num_rows($result);
									while ($row = mysql_fetch_array($result))
									{
										$id = $row['id'];
										$hotel = $row['hotel'];
										$location = $row['location'];
										$cuisines = $row['cuisines'];*/
										$image_file = $row['image_file'];
										
										echo
										
										"		
<table width='100%' valign='top' bgcolor='#F4F4F4' border='0' cellspacing='1' cellpadding='1'>
  <tr>
    <td height='32' bgcolor='#CC3333'><table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' bgcolor='#F5F5F5'>
      <tr>
        <td width='7%' height='28' align='center'><!--<img src='../useradmin/$image_file' class='border1' width='50' height='51' title='$menutitle' align='center' hspace='2' vspace='2'>--></td>
        <td width='60%' align='left'><strong><font color='#990000'>$hotel</font></strong></td>
        <td width='19%' align='left'>&nbsp;</td>
        <td width='14%' align='center'><span class='bodyTxt'>
		        <div  style='border-bottom-style:dotted'>
		<a href='menu.php?nav=$country&hotel=$hotel&id=$id'><span class='bodyTxt'><small class='bodyTxt'>See Menu</small></span></a></div></td>
      </tr>
    </table></td>
  </tr>
</table>
				";
					}
						//Display the full navigation in one go
				echo"<tr><td colspan=14 align=center bgcolor='#F4F4F4'><br>" .$pager->renderFullNav(). "</td></tr></table>";	
						?>

sorry its not nested , i have lot of work to do on my site a.s.p hope you understand.

noo, I just need code to show data from base for each location separate, it can't be that long

Sorry, I do not understand exactly what you mean. The select element has to have it's name so you can use it once saved in $_POST array (after the form was submitted). If the name of the select element is cities the element of $_POST array will be $_POST and the value will be the name of the city that was selected. You use that name in your query. Results are always displayed on one page (either index.php or any other, depending what you set in action attribute) but since the page is set up dinamicaly from the query result it will always contain the data for different city (the city that the user selected).

If you want to display statistics on different page just set the action to it. Another important thing is that select element for cities should be in it's own form so you separate the collection of data for anketa from viewing statistics.

<form action="view_statistics.php" method="post">

Pokazi statistiku za <select name="cities">
<option value="donji_grad">Donji Grad</option>
<option value="karadjordjev_dud"><a href="karadjordjev_dud.php">Karadjordjev Dud</a></option>
<option value="plavinac">Plavinac</option>
...

</select>
<input type="submit" name="submit_stat" value="Statistika" />
...
</form>

On the page showing statistics for selected city (view_statistics.php) you might have code like:

<?php
// check if statistics form was submitted
if(isset($_POST['submit_stat'])) {

    $city = filter($_POST['cities']);

    // query for getting statistics from anketa table
    // this query might be different since I do not know the data structure and the logic of your app
    // maybe "SELECT COUNT(votes) FROM anketa WHERE location='" . $city"
    $query_c = "SELECT * FROM anketa WHERE location='" . $city;

    // read the result
    // ...

    // display the statistics
    // ...

} else {

    // if nothing is in $_POST redirect back to index.php
    header('location:index.php');
}
?>

let me try that, so what should I put instead of cities, mesto? because mesto is value in my database that goes from first dropdown in questionnaire, and that is location

Am geting error in index.php at line 3 and where is in your code include config with database?

It does not matter what the name of select is as long as you refer to the same name in the $_POST array.

What is the error you are getting now?

But I need same name from base as input, I already have locations with name mesto, I need to show data from it later, don't need to chose location again, just to show location as option from already chosed in questionnaire

error is

Parse error: syntax error, unexpected '<' in /home/a4764180/public_html/anketa/index.php on line 3

Here is example of what I need

dropdown menu with locations. You chose yours

Then Example vote for something Yes or No

And now I need dropdown menu with locations same as above. And when I chose for example same location as you did, it need to show me if you voted yes then Yes=1 got me?

I have first dropdown menu, now I need second, that is where I got stucked

Seems like we have really a trouble communicating each other our texts :-).

So if I understand correctly:

You have one form to fill in your survey (anketa) where users also select for which city from the list of cities they select answers.

Then you have another form where users can select a city (same list of cities as in the first form) and see some statistics. I do not quite understand what the statistics should show. Is it statistic data for all the answers from the first form?

I think your first form and second form should each be included in own <form> ... </form> tags and have different IDs. Each form should have its own submit button which have to have different names (i.e. submit_vote and submit_stats). Then you have two if blocks when you test for each of two submit buttons.

if($_POST['submit_vote'])
{
// insert vote results in a database

}

if($_POST['submit_stats'])
{
// read results from a database, calculate whatever needed and display statistics

}

Setting the action attribute for each form depends on where do you want users to have results displayed. If this is on another page the above if blocks can be on that page.

If you use the same list of cities twice on the page it would be a good idea to put the cities in an array and generate select elements from that array. The following is a sample (a bit lenghty but easy to maintain and adapt):

$cities = array(
    array(
        'value' => 'donji_grad', 
        'text'  => 'Donji Grad'),
    array(
        'value' => 'karadjordjev_dud', 
        'text'  => 'Karadjordjev Dud',
        'link'  => 'karadjordjev_dud.php'),
    array(
        'value' => 'plavinac', 
        'text'  => 'Plavinac'),
    array(
        'value' => 'seone', 
        'text'  => 'Seone'),
    array(
        'value' => 'ladna_voda', 
        'text'  => 'Ladna Voda'),
    array(
        'value' => 'lestar',
        'text'  => 'Lestar'),
    array(
        'value' => 'zlatno_brdo', 
        'text'  => 'Zlatno Brdo'),
    array(
        'value' => 'slavija', 
        'text'  => 'Slavija'),
    array(
        'value' => 'papazovac', 
        'text'  => 'Papazovac'),
    array(
        'value' => 'carina', 
        'text'  => 'Carina'),
    array(
        'value' => 'sveti_sava', 
        'text'  => 'Sveti Sava'),
    array(
        'value' => '25maj', 
        'text'  => '25. Maj'),
    array(
        'value' => 'udovice', 
        'text'  => 'Udovice'),
    array(
        'value' => 'lipe', 
        'text'  => 'Lipe'),
    array(
        'value' => 'mihajlovac', 
        'text'  => 'Mihajlovac'),
    array(
        'value' => 'vranovo', 
        'text'  => 'Vranovo'),
    array(
        'value' => 'radinac', 
        'text'  => 'Radinac'),
    array(
        'value' => 'mala_krsna',
        'text'  => 'Mala Krsna'),
    array(
        'value' => 'skobalj',
        'text'  => 'Skobalj'),
    array(
        'value' => 'osipaonica',
        'text'  => 'Osipaonica'),
    array(
        'value' => 'drugovac',
        'text'  => 'Drugovac'),
    array(
        'value' => 'badljevica', 
        'text'  => 'Badljevica'),
    array(
        'value' => 'salinac', 
        'text'  => 'Salinac'),
    array(
        'value' => 'kulic',
        'text'  => 'Kulic'),
    array(
        'value' => 'suvodol', 
        'text'  => 'Suvodol'),
    array(
        'value' => 'lunjevac',
        'text'  => 'Lunjevac'),
    array(
        'value' => 'landol',
        'text'  => 'Landol'),
    array(
        'value' => 'petrijevo',
        'text'  => 'Petrijevo'),
    array(
        'value' => 'kolari',
        'text'  => 'Kolari'),
    array(
        'value' => 'binovac',
        'text'  => 'Binovac'),
    array(
        'value' => 'lugavcina',
         'text'  => 'Lugavcina'),
    array(
        'value' => 'saraorci',
        'text'  => 'Saraorci'),
    array(
        'value' => 'vucak',
        'text'  => 'Vucak'),
    array(
        'value' => 'vrbovac',
        'text'  => 'Vrbovac'),
    array(
        'value' => 'ralja',
        'text'  => 'Ralja'),
    array(
        'value' => 'dobri_do',
        'text'  => 'Dobri Do'),
    array(
        'value' => 'vodanj',
        'text'  => 'Vodanj'),
    array(
        'value' => 'malo_orasje',
        'text'  => 'Malo Orasje')
    );
    
    // begin select element
    $select_element = '<select name="city_vote">';
    
    foreach($cities as $city) {
    
        // add one option value
        $select_element .= '<option value="' . $city['value'] . '">';
        
        // if this option also has a link add <a> tag
        if(isset($city['link'])) {
        
            $select_element .= '<a href="' . $city['link'] . '">';
        }
        
        // add text to display an option
        $select_element .= $city['text'];

        // if this option also has a link finish with </a> tag
        if(isset($city['link'])) {
        
            $select_element .= '</a>';
        }
        
        // end option tag for one option
        $select_element .= '</option>';
    }
    
    // end select element
    $select_element .= '</select>';
    
    // display select element
    echo $select_element;

I also noticed that some checkboxes have same IDs (politicar). IDs in one HTML document have to be unique so change those (i.e. to politicar1, politicar2...). Names can be the same if checkboxes in question are part of a group.

I am not sure if I helped you with what you want but this is what I can do upon your description of the problem.

Yes you understand good, just you did not saw my code which says INSERT into anketa and data for it?

when politicar is checked his name goes to base, I can see in base lines for each questionnaire and see who checked what politicar. Now I need to make another page which will show how much politicar's names was checked for each location, I have to make counting and showing that data if you can understand? When you check for example Suzana Spasojevic, and submit it goes to base and I see line with all data from your questionnaire. Now I want page which will have option to select locations, and in each location how much checked for example Suzana Spasojevic = 5 votes. Got me?

I can give you access to database and ftp so you can see base? just tell me if you have skype or xfire or facebook any instant msg

Sorry to come back so late I am pretty busy finishing up a project at work. At the moment I can hardly take time to chat on skype on this subject or to spend too much time (i.e. to set up a database and prepare a code for you). Will try to help with bits and pieces as much as possible.

No I have code and base all done, and all working. I just want you to see system how it works, because you offered me code with totaly new inputs which I don't need, I need just to show existing one in difrent page with difrent data=statistics from all other questionnaires

Post the last version of your code and table structures (or if you wish you can PM the access to your database).

Post the last version of your code and table structures (or if you wish you can PM the access to your database).

<?php 
include 'dbc.php';

$err = array();
					 
if($_POST['doSubmit'] == 'Submit') 
{ 

foreach($_POST as $key => $value) {
	$data[$key] = filter($value);
}






	  
$user_ip = $_SERVER['REMOTE_ADDR'];
$date = date("m-d-Y, h:i:s a", time());

$sha1pass = PwdHash($data['pwd']);

$host  = $_SERVER['HTTP_HOST'];
$host_upper = strtoupper($host);
$path   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');







if(empty($err)) {
$sql_insert = "INSERT into `anketa`(`mesto`,`ime`,`broj_clanova`,`clanova_sa_pravom_glasa`,`adresa`,`broj_zaposlenih`,`broj_nezaposlenih`,`broj_penzionera`,`clan_stranke`,`ime_stranke`,`glavni_problem`,`predlog_resenja`,`sporedni_problemi`,`predlog_resenja2`,`politicar`,`sps`,`razlog`,`ako_ne`) VALUES ('$data[mesto]','$data[ime]','$data[broj_clanova]','$data[clanova_sa_pravom_glasa]','$data[adresa]','$data[broj_zaposlenih]','$data[broj_nezaposlenih]','$data[broj_penzionera]','$data[clan_stranke]','$data[ime_stranke]','$data[glavni_problem]','$data[predlog_resenja]','$data[sporedni_problemi]','$data[predlog_resenja2]','$data[politicar]','$data[sps]','$data[razlog]','$data[ako_ne]')";
			
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
$user_id = mysql_insert_id($link);  
$md5_id = md5($user_id);
mysql_query("update users set md5_id='$md5_id' where id='$user_id'");
//	echo "<h3>Thank You</h3> We received your submission.";



  header("Location: hvala.php");  
  exit();
	 
	 } 
 }					 

?>
<html>
<head>
<title>Anketa</title>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr> 
    <td width="160" valign="top"><p>&nbsp;</p>
      <p>&nbsp; </p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p></td>
    <td width="732" valign="top"><p>
	<?php 
	 if (isset($_GET['done'])) { ?>
	  <h2>Hvala</h2>;
	 <?php exit();
	  }
	?>
	 <?php	
	 if(!empty($err))  {
	   echo "<div class=\"msg\">";
	  foreach ($err as $e) {
	    echo "* $e <br>";
	    }
	  echo "</div>";	
	   }
	 ?> 
	 
	  <br>
      <form action="index.php" method="post" name="regForm" id="regForm" >

<p>Location
<select name="mesto">
<option value="donji_grad">Example1</option>
<option value="karadjordjev_dud">Example2</option>
<option value="plavinac">Example3</option>

</select></p>



<p>Name <input name="ime" type="text" id="ime" size="40"></p>

<p>Number of family members <input name="broj_clanova" type="text" id="broj_clanova" size="20"></p>

<p>Members with right to vote <input name="clanova_sa_pravom_glasa" type="text" id="clanova_sa_pravom_glasa" size="20"></p>

<p>Adress <input name="adresa" type="text" id="adresa" size="40"></p>

<p>Number of employes in family <input name="broj_zaposlenih" type="text" id="broj_zaposlenih" size="40"></p>

<p>Number of uneployed <input name="broj_nezaposlenih" type="text" id="broj_nezaposlenih" size="20"></p>

<p>Broj penzionera clanova domacinstva <input name="broj_penzionera" type="text" id="broj_penzionera" size="20"></p>

<p>Bwegfwegwegw: Yes<input name="clan_stranke" type="radio" id="clan_stranke" value="da">   No<input name="clan_stranke" type="radio" id="clan_stranke" value="ne">
<select name="ime_stranke">
<option value="ds">DS</option>
<option value="sps">SPS</option>
<option value="srs">SRS</option>
<option value="sns">SNS</option>
<option value="pzs">PZS</option>
<option value="kzbs">KZBS</option>
<option value="urs">URS</option>
<option value="ldp">LDP</option>
<option value="ostali">Ostali</option>
</select></p>



<p>To who you turst most:<br><br>
1. Suzana Spasojevic <input name="politicar" type="checkbox" id="politicar" value="suzana_spasojevic"><br>
2. Brance Stojanovic <input name="politicar" type="checkbox" id="politicar" value="brance_stojanovic"><br>
3. Predrag Umicevic <input name="politicar" type="checkbox" id="politicar" value="predrag_umicevic"><br>
4. Jasna Avramovic <input name="politicar" type="checkbox" id="politicar" value="jasna_avramovic"><br>
5. Sasa Radosavljevic <input name="politicar" type="checkbox" id="politicar" value="sasa_radosavljevic"><br>
6. Milan Lukic <input name="politicar" type="checkbox" id="politicar" value="milan_lukic"><br>
7. Dragan Sormaz <input name="politicar" type="checkbox" id="politicar" value="dragan_sormaz"></p>

<p>Would you vote for SPS? Yes<input name="sps" type="radio" id="sps" value="da"> No<input name="sps" type="radio" id="sps" value="ne"> Maybe<input name="sps" type="radio" id="sps" value="mozda"></p>
        
		
		
<p>If not to who then? <select name="ako_ne">
<option value="ds" selected="selected">DS</option>
<option value="sps">SPS</option>
<option value="srs">SRS</option>
<option value="sns">SNS</option>
<option value="pzs">PZS</option>
<option value="kzbs">KZBS</option>
<option value="urs">URS</option>
<option value="ldp">LDP</option>
<option value="ostali">Ostali</option>
<option value="ni_za_koga">Ni za koga</option>
</select></p>
		
		<p align="center">
          <input name="doSubmit" type="submit" id="doSubmit" value="Submit">
        </p>
      </form>
   
	   
      </td> 
    <td width="196" valign="top">&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="3">&nbsp;</td>
  </tr>
</table>

</body>
</html>

I made new system

Now it want to show data from base, but won't insert it where is problem?

<html>
	<head><title>Anketa</title></head>
	<body>
	
	<form action="insert.php" method="post">
	
Mesna zajednica 
<select name="mesto">
<option value="donji_grad">Donji Grad</option>
<option value="karadjordjev_dud">Karadjordjev Dud</option>
<option value="plavinac">Plavinac</option>
<option value="seone">Seone</option>
<option value="ladna_voda">Ladna Voda</option>
<option value="lestar">Lestar</option>
<option value="zlatno_brdo">Zlatno Brdo</option>
<option value="slavija">Slavija</option>
<option value="papazovac">Papazovac</option>
<option value="carina">Carina</option>
<option value="sveti_sava">Sveti Sava</option>
<option value="25maj">25. Maj</option>
<option value="udovice">Udovice</option>
<option value="lipe">Lipe</option>
<option value="mihajlovac">Mihajlovac</option>
<option value="vranovo">Vranovo</option>
<option value="radinac">Radinac</option>
<option value="mala_krsna">Mala Krsna</option>
<option value="skobalj">Skobalj</option>
<option value="osipaonica">Osipaonica</option>
<option value="drugovac">Drugovac</option>
<option value="badljevica">Badljevica</option>
<option value="salinac">Salinac</option>
<option value="kulic">Kulic</option>
<option value="suvodol">Suvodol</option>
<option value="lunjevac">Lunjevac</option>
<option value="landol">Landol</option>
<option value="petrijevo">Petrijevo</option>
<option value="kolari">Kolari</option>
<option value="binovac">Binovac</option>
<option value="lugavcina">Lugavcina</option>
<option value="saraorci">Saraorci</option>
<option value="vucak">Vucak</option>
<option value="vrbovac">Vrbovac</option>
<option value="ralja">Ralja</option>
<option value="dobri_do">Dobri Do</option>
<option value="vodanj">Vodanj</option>
<option value="malo_orasje">Malo Orasje</option>
</select><br><br>





Ime i prezime : <input type="text" name="ime"><br><br>

Broj clanova domacinstva : <input type="text" name="broj_clanova"><br><br>

Broj clanova domacinsta sa pravom glasa: <input type="text" name="clanova_sa_pravom_glasa"><br><br>

Ulica i broj: <input type="text" name="adresa"><br><br>

Broj zaposlenih u domacinstvu <input name="broj_zaposlenih" type="text" id="broj_zaposlenih" size="40"><br><br>

Broj ne zaposlenih <input name="broj_nezaposlenih" type="text" id="broj_nezaposlenih" size="20"><br><br>

Broj penzionera clanova domacinstva <input name="broj_penzionera" type="text" id="broj_penzionera" size="20"><br><br>

Da li ste Vi ili neko od clanova vaseg domacinstva clanovi neke stranke i koje, ako nije tajna: Da<input name="clan_stranke" type="radio" id="clan_stranke" value="da">   Ne<input name="clan_stranke" type="radio" id="clan_stranke" value="ne">
<select name="ime_stranke">
<option value="" selected="selected"></option>
<option value="ds">DS</option>
<option value="sps">SPS</option>
<option value="srs">SRS</option>
<option value="sns">SNS</option>
<option value="pzs">PZS</option>
<option value="kzbs">KZBS</option>
<option value="urs">URS</option>
<option value="ldp">LDP</option>
<option value="ostali">Ostali</option>
</select><br>

Problemi u vasoj okolini:

Glavni problem: <input name="glavni_problem" type="text" id="glavni_problem" size="200"><br><br>

Predlog resenja: <input name="predlog_resenja" type="text" id="predlog_resenja" size="200"><br><br>

Sporedni problemi: <input name="sporedni_problemi" type="text" id="sporedni_problemi" size="200"><br><br>

Predlog resenja: <input name="predlog_resenja2" type="text" id="predlog_resenja2" size="200"><br><br>

Kom smederevskom politicaru najvise verujete:<br><br>
1. Suzana Spasojevic <input name="politicar" type="checkbox" id="politicar" value="suzana_spasojevic"><br>
2. Brance Stojanovic <input name="politicar" type="checkbox" id="politicar" value="brance_stojanovic"><br>
3. Predrag Umicevic <input name="politicar" type="checkbox" id="politicar" value="predrag_umicevic"><br>
4. Jasna Avramovic <input name="politicar" type="checkbox" id="politicar" value="jasna_avramovic"><br>
5. Sasa Radosavljevic <input name="politicar" type="checkbox" id="politicar" value="sasa_radosavljevic"><br>
6. Milan Lukic <input name="politicar" type="checkbox" id="politicar" value="milan_lukic"><br>
7. Dragan Sormaz <input name="politicar" type="checkbox" id="politicar" value="dragan_sormaz"></p>

Da li biste glasali za SPS? Da<input name="sps" type="radio" id="sps" value="da"> Ne<input name="sps" type="radio" id="sps" value="ne"> Mozda<input name="sps" type="radio" id="sps" value="mozda"><br><br>
       
Zasto bi ste glasali/ne bi ste glasali: <input name="razlog" type="text" id="razlog" size="200"><br><br>
		
Ako je odgovor ne, za koga bi glasali? <select name="ako_ne">
<option value="ds">DS</option>
<option value="sps">SPS</option>
<option value="srs">SRS</option>
<option value="sns">SNS</option>
<option value="pzs">PZS</option>
<option value="kzbs">KZBS</option>
<option value="urs">URS</option>
<option value="ldp">LDP</option>
<option value="ostali">Ostali</option>
<option value="ni_za_koga"  selected="selected">Ni za koga</option>
</select></p>

<input type="Submit">
</form>


<?
$username="a4764180_anketa";
$password="a12345";
$database="a4764180_anketa";

$mesto=$_POST['mesto'];
$ime=$_POST['ime'];
$broj_clanova=$_POST['broj_clanova'];
$clanova_sa_pravom_glasa=$_POST['broj_clanova_sa_pravom_glasa'];
$adresa=$_POST['adresa'];
$broj_zaposlenih=$_POST['broj_zaposlenih'];
$broj_nezaposlenih=$_POST['broj_nezaposlenih'];
$broj_penzionera=$_POST['broj_penzionera'];
$clan_stranke=$_POST['clan_stranke'];
$glavni_problem=$_POST['glavni_problem'];
$predlog_resenja=$_POST['predlog_resenja'];
$sporedni_problemi=$_POST['sporedni_problemi'];
$predlog_resenja2=$_POST['predlog_resenja2'];
$politicar=$_POST['politicar'];
$sps=$_POST['sps'];
$razlog=$_POST['razlog'];
$ako_ne=$_POST['ako_ne'];





mysql_connect("mysql6.000webhost.com",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO anketa VALUES ('$mesto','$ime','$broj_clanova','$clanova_sa_pravom_glasa','$adresa','$broj_zaposlenih','$broj_nezaposlenih','$broj_penzionera','$clan_stranke','$glavni_problem','$predlog_resenja','$sporedni_problemi','$predlog_resenja2','$politicar','$sps',$razlog','$ako_ne')"; 
mysql_query($query);

mysql_close();
?>

	</body>
	</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.