PDA

View Full Version : help getting sql results into html


jake7338
07-03-2006, 06:22 PM
Can someone explain the best way to get my sql results into html? Specifucaly a table.

I have the query working great, but now what? How do i get these results into my html doc? I am using the html "form" tag to submit data to a php script which searches the db and returns my data. It returns the data to a blank white page.

Obvioulsly i would like a normal html page with an html table containing the results. How do i do this...

Please explain... thanks, --jake

Zachery
07-03-2006, 06:26 PM
Whats youyr query and what exactly do you want to show with your resusts? Did you assign your query a varible?

jake7338
07-03-2006, 06:56 PM
Here is my query, this is from the php that is called by the html form "action" parameter. So all the data should be in $result

Can i access $result from my html doc? Even if i could it takes me to the white blank page when "submit" is hit. Thanks.. --jake

$result = mysql_query("SELECT * FROM condo_vendors WHERE city='$localcity'");

while($row = mysql_fetch_array($result))
{
echo $row['biz_type'];
echo $row['name'];
echo $row['phone'];
echo $row['website'];
echo $row['username'];
echo $row['comment'];
echo $row['datevar'];
echo "<br />";
}

I

kinda found the answer myself.... so i will post so maybe someone else will benefit...

Basically php and html docs are one and the same. Name your html file *.php and then you can call php commands (sql queries) in an inline fashion at will. Just put your start and stop PHP tags around your PHP commands.

The db access login,passwd,dbaname will not show, because the document will be rendered. So its safe to view source and your db password and info will not be shown.

Hope that helps someone else... --jake

Paul M
07-03-2006, 10:23 PM
Are you sure that your query is producing rows ?