average american Posted September 12, 2007 Share Posted September 12, 2007 I am trying to retieve images from my database mysql using php and am unable to get them to display. this is my code //listing results $sql = "SELECT listings.* FROM listings"; $result = mysql_query($sql); $numrows = mysql_num_rows($result); require("header.php"); echo "<table cellpadding ='5'>"; echo "<tr>"; echo "<h1>Available Properties</h1>"; echo "<th>Image</th>"; echo "<th>Item</th>"; echo "<th>Bed/Bath/Garage</th>"; echo "<th>Rent</th>"; echo "<th>Description</th>"; echo "</tr>"; if($numrows == 0) { echo "<tr><td colspan=4>No Items!</td></tr>"; } else { while($row = mysql_fetch_assoc($result)) { $imagesql = "SELECT * FROM images WHERE listing_id = ". $row['id']." LIMIT 1"; $imageresult = mysql_query($imagesql); $imagenumrows = mysql_num_rows($imageresult); echo "<tr>"; if($imagenumrows == 0) { echo "<td>No Image</td>"; } else { $imagerow = mysql_fetch_assoc($imageresult); echo "<td>" .$imageresult["content"] . "</td>"; } echo "<td>"; echo "<a href='listingdetails.php?id=" . $row['id'] . "'>" . $row['address'] . "</a>"; $_SESSION['USERID'] == $row['user_id']; echo "</td>"; $BBGsql = "SELECT * FROM listings WHERE listings.id=" . $row['id'] . ";"; $BBGresult = mysql_query($BBGsql); $BBGrow = mysql_fetch_assoc($BBGresult); $BBGnumrows = mysql_num_rows($BBGresult); echo "<td>"; echo $BBGrow['bed'] . " ⁄ "; echo $BBGrow['bath'] . " ⁄ "; echo $BBGrow['garage']; echo "</td>"; echo "<td>" . $config_currency; echo $BBGrow['rent']; echo "</td>"; echo "<td>"; echo $BBGrow['description']; echo "</td>"; i am in quite the bind as i only have a couple of days to get this done. I have my database setup and the info is BLOB. Quote Link to comment Share on other sites More sharing options...
watthehell Posted September 13, 2007 Share Posted September 13, 2007 Try This <?php //listing results $sql = "SELECT listings.* FROM listings"; $result = mysql_query($sql); $numrows = mysql_num_rows($result); require("header.php"); echo "<table cellpadding ='5'>"; echo "<tr>"; echo "<h1>Available Properties</h1>"; echo "<th>Image</th>"; echo "<th>Item</th>"; echo "<th>Bed/Bath/Garage</th>"; echo "<th>Rent</th>"; echo "<th>Description</th>"; echo "</tr>"; if($numrows == 0) { echo "<tr><td colspan=4>No Items!</td></tr>"; } else { while($row = mysql_fetch_assoc($result)) { $imagesql = "SELECT * FROM images WHERE listing_id = ". $row['id']." LIMIT 1"; $imageresult = mysql_query($imagesql); $imagenumrows = mysql_num_rows($imageresult); echo "<tr>"; if($imagenumrows == 0) { echo "<td>No Image</td>"; } else { $imagerow = mysql_fetch_assoc($imageresult); echo "<td><img src=".$imageresult["content"]." width="100" height="100" border="0" /></td>"; } echo "<td>"; echo "<a href='listingdetails.php?id=" . $row['id'] . "'>" . $row['address'] . "[/url]"; $_SESSION['USERID'] == $row['user_id']; echo "</td>"; $BBGsql = "SELECT * FROM listings WHERE listings.id=" . $row['id'] . ";"; $BBGresult = mysql_query($BBGsql); $BBGrow = mysql_fetch_assoc($BBGresult); $BBGnumrows = mysql_num_rows($BBGresult); echo "<td>"; echo $BBGrow['bed'] . " ⁄ "; echo $BBGrow['bath'] . " ⁄ "; echo $BBGrow['garage']; echo "</td>"; echo "<td>" . $config_currency; echo $BBGrow['rent']; echo "</td>"; echo "<td>"; echo $BBGrow['description']; echo "</td>"; ?> Quote Link to comment Share on other sites More sharing options...
average american Posted September 13, 2007 Author Share Posted September 13, 2007 thanks that worked out Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.