Hi Gys n Gals
Got a problem here, think I am close but am not really sure.
I have a page which calls only selected fields from each row in a database. This is working fine. What I want is for the user to click a button/link which takes them to a new page which would then display all the fields from the selected entry.
The button on the first page has this code in it
<input type='button' onclick='window.location=\"viewall.php?id=$id\" 'value='View All Details'>
I have created the code for viewall.php as follows
<?php
// This is to connect to and open the database
include 'library/config.php';
include 'library/opendb.php';
$id = $_GET['id'];
$database = mysql_connect($dbhost,$dbuser,$dbpass) or die("Could not connect to server");
mysql_select_db($dbname) or die("Could not find table");
$sql = "SELECT * FROM livestock WHERE id=$id";
echo nl2br($comment);
$result = mysql_query($sql);
#First print the opening tag...
echo '<table align="center" width="800" border="0" cellspacing="0" cellpadding="0">';
while ($row = mysql_fetch_assoc ($result)) {
$text = $row['id'];
$url = $row['path'];
$comment = $row['comment'];
$title = $row['title'];
$member = $row['member'];
$email = $row['email'];
$telephone = $row['telephone'];
$price = $row['price'];
#this will print a new row for each photo..
echo "
<tr>
<td colspan=\"2\"><h2 align=\"center\">$title</h2></td><td colspan=\"2\"><h2 align=\"center\">Asking Price: £ $price</h2></td>
</tr>
<tr>
<td width=\"25\" align=\"left\" valign=\"middle\"></td>
<td align=\"center\"><a href=\"$url\" target=\"_blank\"><img src=\"$url\" width=\"200\" alt=\"\" border=\"0\"></a><br><span class='small'>Click Picture to enlarge</span></td>
<td width=\"25\" align=\"left\" valign=\"middle\"></td>
<td align=\"left\" valign=\"top\"><p><textarea class=\"txtarea\" name=\"\" cols=\"70\" rows=\"20\" border=\"0\">$comment</textarea></p></td>
</tr>
<tr>
<td colspan=\"4\"><table width=\"800\" border=\"0\"><tr><td width=\"33%\"><p>Contact Name: $member</p></td><td width=\"33%\"><p>Contact Email: <a href=\"mailto:$email\">$email</a></p></td><td width=\"34%\"><p>Contact Telephone: $telephone</p></td></tr></table>
</tr>
<tr>
<td colspan=\"4\"><a href=\"readad.php\">View This Advert</a></td>
</tr>
<tr>
<td colspan=\"4\"><hr></td>
</tr> ";
}
// This is to close database
mysql_close($conn);
echo "</table>";
?>
I keep getting this error when i load the viewall page from the first page
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/sites/grap.co.uk/public_html/livestock/readad.php on line 53
Please could someone more able than me take a look at my code and tell me what i did wrong
Thanks in advance for your assistance