Title: exacuting quieries
257335 - January 7, 2007 02:39 AM (GMT)
| CODE |
$con = mysql_connect("localhost","root","*******"); if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("realestate", $con);
$result = mysql_query($SQL);
while($row = mysql_fetch_array($result)) { echo '<center>'; echo '<a href="descrip.php">'; echo '<img src="images/'. $row['imagename'] .'" width="400"height="400">'; echo '</center>'; echo '<br>'; echo '<br>';
echo "<table border='5'bgcolor='#ff8080'> <tr> <th>Address</th> <th>Price</th> <th>Baths</th> <th>Bedrooms</th> <th>State</th> <th>City</th> <th>Square Feet</th> <th>County</th> <th>Year Built</th> <th>Buy or Lease</th> </tr>"; echo "<tr>"; echo "<td>" . $row['address'] . "</td>"; echo "<td>" . $row['price'] . "</td>"; echo "<td>" . $row['baths'] . "</td>"; echo "<td>" . $row['bedrooms'] . "</td>"; echo "<td>" . $row['state'] . "</td>"; echo "<td>" . $row['city'] . "</td>"; echo "<td>" . $row['squarefeet'] . "</td>"; echo "<td>" . $row['county'] . "</td>"; echo "<td>" . $row['yearbuilt'] . "</td>"; echo "<td>" . $row['buyorlease'] . "</td>"; echo "</tr>"; echo "</table>"; echo "<br>"; echo "<br>";
} if(mysql_num_rows($result) == 0) ECHO "<h3>NO MATCHES FOUND</h3>"; mysql_close($con);
?> |
this out puts tables and a pic link for how ever many search results where found what im trying to to is have it to where when you click on the pic it take you to a new page that has a detailed description of the house. the problem is im not sure how to pick the row out of the table that corresponds to the pic that you clicked on.
patheticcockroach - January 7, 2007 06:00 PM (GMT)
That's why you need the unique id that auto-increments (see
here). Then you only need to query "SELECT * FROM yourtable WHERE id='the_id';" in your descrip.php file
257335 - January 7, 2007 07:52 PM (GMT)
yes i realized this and thats why i asked you to about the auto-increment thing.what im having trouble with is how the computer is going to know what id corresponds to the pic that you click on. im assuming that you have to send a varible the url address kinda like this.
echo $id=$row['id'];
echo '<a href="descrip.php?id=$id">';
is this how you would do it
patheticcockroach - January 7, 2007 09:38 PM (GMT)
Yes, that's it. Then in descrip.php you'd get the id using
257335 - January 7, 2007 10:11 PM (GMT)
$accountnum=$row['accountnum'];
echo '<center>';
echo '<a href="descrip.php?accountnum=$accountnum">';
instead of sending the value of $accountnum is sending the physical string "$accountnum" im not sure how to fix this
257335 - January 7, 2007 10:11 PM (GMT)
just to let you know i change the name from id to accountnum
patheticcockroach - January 8, 2007 06:33 AM (GMT)
Oh, sorry, I didn't look at it carefully... Use
| CODE |
| echo '<a href="descrip.php?accountnum='.$accountnum.'">'; |