Help - Search - Members - Calendar
Full Version: inserting pictures from databases
HTMLHelp Forums > Programming > Databases
if you have the urls to pictures in a database how would you display the actual pictures on a webpage?
Darin McGrew
Have a server-side program retrieves the URLs from the database, then sends HTML that includes those URLs in <img> tags.
here 's what I have so far

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
td {
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #30C;,
border-right-color: #30C;
border-bottom-color: #30C;
border-left-color: #30C;

echo "<form action=\"\" method=\"post\" name=\"catalog\">";


$query = "SELECT * FROM treats";
$result_set = mysql_query($query) or die(mysql_error());
$i = 0;

echo "<table>";
while ($row = mysql_fetch_array($result_set))
echo"<tr><td width=\"400px\">($row['product_pic']{$row['product_id']}.<br />{$row['product_title']}.<br /> {$row['product_Description']}.<br />{$row['product_price']}</td></tr>";
echo "</table>";
Here 's another question. Can I have two columns with different products in each column?
Brian Chandler
here 's what I have so far

Hmm. It is not reasonable to expect someone else to debug your programs for you.


while ($row = mysql_fetch_array($result_set))
{       echo"<tr><td width=\"400px\">($row['product_pic']{$row['product_id']}.<br />{$row['product_title']}.<br  />  {$row['product_Description']}.<br />{$row['product_price']}</td></tr>";

Do you understand what while(...) means?
What do you expect $row to hold for each <table> row that you are generating?
What are all these dots (.) for?
Does this produce a php syntax error, or does it output some html? What does the html look like?

You need to ask yourself questions like these, and learn how to work out what is going on -- this is called 'debugging'.
I'm NOT asking anyone to do my programming for me! ! This is a really hard subject for me!
Brian Chandler
QUOTE(minidiapolis @ Oct 13 2011, 11:29 PM) *

I'm NOT asking anyone to do my programming for me! ! This is a really hard subject for me!

What I think is unreasonable is posting a whole page of code and just saying "help".

So I picked out what is probably the core problem, and asked some questions about it, of which the first was:

Do you understand what while(...) means?

Well? Do you understand what this while loop does? If you don't quite understand, perhaps we can try to help you. If you do understand fully, then we could go on to the next question. If you don't want to engage with some sort of learning process, and don't want someone to just write your program for you, then I'm at a total loss to know how you think anyone could help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.