Hello,
I have seen this topic on here, but none of the answers directly reflect what I am trying to do. Being new to PHP, I cannot apply the examples to my situation. What I am trying to do is probably very simple, but I need some help.
I have created a DB and have even created a form for my client to add new retailers to the DB. I created a map of the USA using an imagemap to link to the DB. So, if a customer is looking for a retailer in Ohio, they click Ohio, and a new page displays the results by alphabetical company name.
Right now, I have the results display like this:
company_name
address
city
state
zip
phone
I would like to be able to display each company in a horizontal table to look like:
company_name ¦ address ¦ city ¦ state ¦ zip ¦ phone
I cannot seem to find a good explanation of how to use html and table formatting within the PHP script.
Is it possible to even determine the color of the table cells as it writes the table?
The code I am currently using is this:
php
mysql_connect ("XX.XXX.XX.XX", "nobody", "nobody");
mysql_select_db (retailers);
if ($state == "")
{$state = '%';}
$result = mysql_query ("SELECT * FROM retailer_list
WHERE state LIKE '$state%'
ORDER BY company_name
");
if ($row = mysql_fetch_array($result)) {
do {
print $row["company_name"];
print ("<br>");
print $row["address"];
print ("<br>");
print $row["city"];
print ("<br>");
print $row["state"];
print ("<br>");
print $row["zip"];
print ("<br>");
print $row["country"];
print ("<br>");
print $row["phone"];
print ("<br>");
print ("--------------------------------------");
print ("<br>");
} while($row = mysql_fetch_array($result));
} else {print "Sorry, Products are not yet available in this state!";}
Getting the table format will be great for the US version, but I am also working on a European version of the site and have had a request for the results to display differently. For this case, it would be great to have the results automatically populate the table cells of a table layout like this:
http://www.lilypadz.com/sellingpoints.php
How can you populate results from a DB without using an external query? I mean how can I have this page load and automatically retrieve the data?
Any help with this is GREATLY appreciated.
Thanks!
Ryan