Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Databases _ inserting pictures from databases

Posted by: minidiapolis Oct 12 2011, 02:03 PM

if you have the urls to pictures in a database how would you display the actual pictures on a webpage?

Posted by: Darin McGrew Oct 12 2011, 02:29 PM

Have a server-side program retrieves the URLs from the database, then sends HTML that includes those URLs in <img> tags.

Posted by: minidiapolis Oct 12 2011, 03:13 PM

here 's what I have so far

<?php
require_once("functions.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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;
}
</style>
</head>

<body>
<?php
navBar();
echo "<form action=\"\" method=\"post\" name=\"catalog\">";

DatabaseConnection();

$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>";
?>
</form>
</body>'
</html>

Posted by: minidiapolis Oct 12 2011, 09:00 PM

Here 's another question. Can I have two columns with different products in each column?

Posted by: Brian Chandler Oct 13 2011, 12:15 AM

QUOTE
here 's what I have so far


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

CODE

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'.

Posted by: minidiapolis Oct 13 2011, 09:29 AM

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

Posted by: Brian Chandler Oct 13 2011, 12:14 PM

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.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)