coding error php - Can't retrieve info from mysql db
Posted: Sun Aug 14, 2011 3:52 pm
Hello All,
There's something I'm missing (coding wise, I know I'm missing plenty in the head) in the php coding for retrieving info from the db.
Some information on the webpage can be seen, namely the $gdzie command, but the rest $row['Name'] etc isn't working.
I've tried re-writing the code in full php to no avail.
I should let you know that I play with php with trial and error and this was a project done for me, which I'm just trying to make some amendments to by myself.
Anyway, here's the code:
Many TIA
There's something I'm missing (coding wise, I know I'm missing plenty in the head) in the php coding for retrieving info from the db.
Some information on the webpage can be seen, namely the $gdzie command, but the rest $row['Name'] etc isn't working.
I've tried re-writing the code in full php to no avail.
I should let you know that I play with php with trial and error and this was a project done for me, which I'm just trying to make some amendments to by myself.
Anyway, here's the code:
Code: Select all
<?php
if(count($_POST)==0)header("location: index.html");
list($kto,$gdzie)=explode('_',key($_POST));
//echo $kto;
//echo $gdzie;
require_once("Dbconn");
//print_r($countys);die;
if($kto=='schools'){
$query = "select sc.ID,sc.Name,sl.district,sl.town
from schools sc
left join schools_location sl on sc.ID=sl.school_id
where sl.county='$gdzie' group by sc.ID";
}
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
//print_r($data);//die;
?>
<?php if($kto=='schools'):?>
<h2>Schools - <?php echo $gdzie;?></h2>
<table class="sortable" id="anyid" width="100%">
<tr><th align="left">Name:</th><th align="left">Town:</th><th align="left" class="unsortable">District:</th><th align="left" class="unsortable">Details:</th></tr>
<tr><td><?php echo $row['Name']?></td>
<td><?php echo $row['town']?></td>
<td><?php echo $row['district']?></td>
<td><a href="schoolsprofile.php?ID=<?php echo $row['ID']?>">School's profile</a></td></tr>
</table>
<?php endif;?>