Jump to content

Passing Database Variables


justinbriggs1

Recommended Posts

Hello everyone,I'm trying to figure out how I can manipulate my database queries to look nice on the screen. Here is what I am doing:1. PHP - Query a database for a record and store the values in an array.2. HTML & CSS - Format and place the values so it looks nice on the screenCan you pass PHP variables to HTML on the same page?

Link to comment
Share on other sites

Hello everyone,I'm trying to figure out how I can manipulate my database queries to look nice on the screen. Here is what I am doing:1. PHP - Query a database for a record and store the values in an array.2. HTML & CSS - Format and place the values so it looks nice on the screenCan you pass PHP variables to HTML on the same page?
I've been looking at tutorials but I can't seem to find the answer. Here's sample code:<?phpinclude "config.php";$result = mysql_query("SELECT * FROM news");while($row = mysql_fetch_array($result)) { $test = $row['title']; }?><html>What kind of HTML do I use here to display $test? </html>
Link to comment
Share on other sites

<html><body><table><?phpinclude "config.php";$result = mysql_query("SELECT * FROM news");echo '<tr>';while($row = mysql_fetch_array($result)){$test = $row['title'];echo '<td>Test:' . $test  . '</td>';}echo '</tr>';?></table></body></html>

Link to comment
Share on other sites

<html><body><table><?phpinclude "config.php";$result = mysql_query("SELECT * FROM news");echo '<tr>';while($row = mysql_fetch_array($result)){$test = $row['title'];echo '<td>Test:' . $test  . '</td>';}echo '</tr>';?></table></body></html>

Ooooooooooooooohhhhhhhhhhhhhhhh...didn't think of that! Thanks!
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...