Hi, I have written this script that partially displays some information, that is fine, except when you click on the [b]More…
Except it displays this error
[code]SQL ERROR: SELECT FROM `branches` WHERE id = ‘2’ – 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 ‘FROM `branches` WHERE id = ‘2” at line 1
I am running;
Apache version 1.3.33 (Unix)
PHP version 4.3.10
MySQL version 4.0.25-standard-log
with this code
[code=php]<? session_start(); ?>
<?php include(‘header.php’); ?>
<p class=”header”>
Branches
</p>
<div align=”left”>
<table border=”0″ width=”97%” cellpadding=”0″ cellspacing=”0″ class=”body”>
<?php
if($_GET[“view”]) { //Find if showing all details
/#this part should display all the information when the link is clicked, but displays the error above #/
?>
<tr>
<td class=”smallborder”><b>Area</b></td>
<td class=”smallborder”><b>Contact</b></td>
<td class=”smallborder”><b>Phone</b></td>
<td class=”smallborder”><b>Address</b></td>
<td class=”smallborder”> </td>
</tr>
<?php
$view_sql = “SELECT FROM `branches` WHERE id = ‘{$_GET[‘view’]}'”;
$result = @mysql_query($view_sql);
if(!$result)
{
echo(“SQL ERROR: $view_sql – ” . mysql_error()); //shows this error
}
else
{
echo(“<tr><td class=’smallborder’>{$result2[‘area’]}</td>
<td class=’smallborder’>{$result2[‘phone’]}</td>
<td class=’smallborder’>{$result2[‘phone’]}</td>
<td class=’smallborder’>{$result2[‘phone’]}</td>
<td class=’smallborder’><a href=’branches.php’ />View all</a></td>
</tr>”);
}
}else {
//this is what loads first, partial data, then should expand with the top section of code to display all information from that record.
?>
<tr>
<td class=”smallborder”><b>Area</b></td>
<td class=”smallborder”><b>Phone</b></td>
<td class=”smallborder”> </td>
</tr>
<?php
//SQL QUERY TO SELECT ALL OF THE USERS
$sql2 = “SELECT * FROM branches ORDER by area ASC”;
$sql2 = mysql_query($sql2);
//WHILE USERS ARE IN THE DATABASE DO THE FOLLOWING
while($result2 = mysql_fetch_assoc($sql2)) {
//PRINT EACH USERS NAME & EMAIL
echo(“<tr><td class=’smallborder’>{$result2[‘area’]}</td>
<td class=’smallborder’>{$result2[‘phone’]}</td>
<td class=’smallborder’><a href=’branches.php?view={$result2[‘id’]}’ />More…</a></td>
</tr>”);
}
}
?>
</table>
</div />
<p>Please feel free to contact any of the above or</p>
<p>National Headquarters – Address – PO Box 88-028 Clendon. Manurewa. Manukau City. or</p>
<p>National Secretary (direct) 195 Weymouth Road. Manurewa. Phone 09-268 4536.</p>
<?php include(‘footer.php’); ?>
Thanks