Jump to content

[SOLVED] help with a couple lines


justAnoob

Recommended Posts

Still can't get image to display,,, just the image path.

<?php
// "<img src='/userimages/cars/>"      this is the image path where the pics are
echo "<tr><td>";
echo $row['imgpath'];    //this only echos the actuall image path, not the pic
?>

<?php
echo "<img src='/userimages/cars/pic.jpg>";  //if i enter one of the picture names in the code, the same picture is for every entry displayed, so atleast i know that the path is correct and the images will display.     
?>

this might help showing you the whole script.

<?php
mysql_connect("xxxxxx","xxxxx","xxxxx"); 
mysql_select_db("xxxxxx");
$sql = mysql_query("SELECT imgpath, item_name, description, in_return FROM xxxxxx");

echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>";
echo "<table border=1> <tr> <td><H3>Image </h3></td> <td><H3>Item Name</H3></td> <td><H3>Description</H3></td><td><H3>Seeking</H3></td></tr>";

while ($row = mysql_fetch_array($sql))
{
    echo "<tr><td>";
    echo $row['imgpath'];
    echo "</td><td>";
    echo $row['item_name'];
    echo "</td><td>";
    echo $row['description'];
    echo "</td><td>";
    echo $row['in_return'];
    echo "</td></tr>";
}
echo "</table>";
?>

so it has to be something minor to get the images to display for each row of the datase

Link to comment
https://forums.phpfreaks.com/topic/152301-solved-help-with-a-couple-lines/
Share on other sites

<?php
mysql_connect("xxxxxx","xxxxx","xxxxx");
mysql_select_db("xxxxxx");
$sql = mysql_query("SELECT imgpath, item_name, description, in_return FROM xxxxxx");

echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>";
echo "<table border=1> <tr> <td><H3>Image </h3></td> <td><H3>Item Name</H3></td> <td><H3>Description</H3></td><td><H3>Seeking</H3></td></tr>";

while ($row = mysql_fetch_array($sql))
{
echo "<tr><td>";
echo "<img src=\"".$row['imgpath']."\">";
echo "</td><td>";
echo $row['item_name'];
echo "</td><td>";
echo $row['description'];
echo "</td><td>";
echo $row['in_return'];
echo "</td></tr>";
}
echo "</table>";
?>

Your HTML is malformed (missing quote around image path). If $row['imgpath'] holds the image path, i.e. /userimages/cars/pic.jpg, this should work:

 

while loop excerpt

<?php
while ($row = mysql_fetch_array($sql))
{
    echo "<tr><td>";
    echo '<img src="' . $row['imgpath'] . '" alt="" />';
    echo "</td><td>";
    echo $row['item_name'];
    echo "</td><td>";
    echo $row['description'];
    echo "</td><td>";
    echo $row['in_return'];
    echo "</td></tr>";
}
?>

 

Edit: Got beaten 8)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.