0

hmmm I found in database one line, idk how I sent to database, but with that code in insert.php it wont sent, I will try with empty insert.php again now

0

and it wont show that one line now, I had like 20 lines before and it showed it in statistika.php now I have one error at line 20 which is $num=mysql_numrows($result);

it should show that one line from base, now am stuck don't know how I inserted that one line recently, and I was able to show data from previous code which worked good for inserting

0

nope still nothing, I dont know how did I get one line in base, I tried to put php before html its same

0

ok i tried almost everything, May I ask someone to make me simple php script which will insert data into base with random values I will edit later, and php to show data on other page. Thanks in advance

0

I can insert data to base with this code

<?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>

but now this code won't show data

<html>
	<head><title>Anketa</title></head>
	<body>






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

mysql_connect("mysql6.000webhost.com",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM anketa WHERE";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

echo "<b><center>Statistika</center></b><br><br>";

$i=0;
while ($i < $num) {

$mesto=mysql_result($result,$i,"mesto");
$ime=mysql_result($result,$i,"ime");
$broj_clanova=mysql_result($result,$i,"broj_clanova");
$clanova_sa_pravom_glasa=mysql_result($result,$i,"clanova_sa_pravom_glasa");
$adresa=mysql_result($result,$i,"adresa");
$broj_zaposlenih=mysql_result($result,$i,"broj_zaposlenih");
$broj_nezaposlenih=mysql_result($result,$i,"broj_nezaposlenih");
$broj_penzionera=mysql_result($result,$i,"broj_penzionera");
$clan_stranke=mysql_result($result,$i,"clan_stranke");
$glavni_problem=mysql_result($result,$i,"glavni_problem");
$predlog_resenja=mysql_result($result,$i,"predlog_resenja");
$spredni_problemi=mysql_result($result,$i,"sporedni_problemi");
$predlog_resenja2=mysql_result($result,$i,"predlog_resenja2");
$politicar=mysql_result($result,$i,"politicar");
$sps=mysql_result($result,$i,"sps");
$razlog=mysql_result($result,$i,"razlog");
$ako_ne=mysql_result($result,$i,"ako_ne");



echo "<p>Mesto: $mesto</p> <p>Broj clanova domacinstva: $broj_clanova</p> <p>Broj clanova sa pravom glasa: $clanova_sa_pravom_glasa</p> <p>Broj zaposlenih u domacinstvu: $broj_zaposlenih</p> <p>Broj nezaposlenih: $broj_nezaposlenih</p> <p>Broj penzionera clanova u domacinstvu: $broj_penzionera<p>";

$i++;
}

?>

error is on line 20 which is numrows, without it it opens page with title only, but before it showed data from base, where is problem?

0

ok I made it show data, but can someone tell me how can I make votes from check boxes to count as 1 so in statistic page I can see Name: 2 votes for example?

and what should be in options in dropdown menu for locations to chose statistics from?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.