Code error with 'select' and 'where'
Posted: Sun Aug 14, 2011 3:02 pm
This is probably something really easy that I'm missing.
here's the code:
The error message I'm getting is:
Any ideas what I'm missing?
Many TIA
here's the code:
Code: Select all
require_once("Dbconn");
list($kto,$gdzie)=explode('_',key($_POST));
if($kto=='schools'){
$query = "select schools.ID,schools.Name,schools_location.district,schools_location.town
from schools left join schools_location on schools.ID=schools_location.school_id where schools_location.county='$gdzie' group by schools.ID";
}
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
?>
<?php if($kto=='schools'):?>
<h2>Schools - <?php echo '$gdzie';?></h2>
<table class="sortable" 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>
Code: Select all
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join schools_location on schools.ID=schools_location.school_id where school' at line 1
Many TIA