Jump to content

[SOLVED] inserting a variable into an html element


yellowepi

Recommended Posts

I am new to programming and have been figuring most of what I know out by reading, but I have spent too much time trying to figure this out.

I am trying to pull information from a mysql database to display an image or create a link and have not been able to get either to work.

 

 

<?php

echo "<table border = 1>";

 

$query_row=mysql_num_rows($result);

while ($row=mysql_fetch_array($result))

 

{

echo "<tr>

 

          <td>" "<a href= "\" .$row[item_title] "\">".$row[item_title] . "</a></td>

          <td>" .$row[item_desc] . "</td>

          <td>" .$row[item_price] . "</td>

 

 

</tr>";

}

echo "</table>";

 

 

?>

 

I've attempted to insert an image in a similar fashion, but haven't been able to.

 

Thanks

echo "<table border = 1>";

$query_row=mysql_num_rows($result);
while ($row=mysql_fetch_array($result))
{
?>
<!-within here will be inside the loop area-->
    <tr>
        <td><a href="<?php echo $row['item_title']; ?>"></a></td>
        <td><?php echo $row['item_desc']; ?></td>
        <td><?php echo $row['item_price']; ?></td>
    </tr>
<!-within here will be inside the loop area-->
<?php
}
echo "</table>";

 

With this, maybe you can see more clearer what is inside your HTML tag.

thankyou, saved me more frustration. I also added on more line to get the link to work, because there wasn't any clickable link. I took your advice for that also, and it worked.

<td><a href="<?php echo $row['item_title'];?>"><?php echo $row['item_title']; ?></a></td>

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.