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
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>";
?>

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.