Jump to content

Recommended Posts

Hey all,

Im working on a gallery for a website and i haven't done much php for a while, got everything sorted for a page for adding photos and uploading them however im stuck on displaying the results and i just can't think of where im going wrong.

I basically want to have a dynamic table that is 3 columns wide and however many rows deep.

Can anyone help?

Im using Dreamweaver 8

thank you!
Link to comment
https://forums.phpfreaks.com/topic/35968-mysql-results-in-a-columned-table/
Share on other sites

This is the basic layout.  $connection holds your database info, tell if if you need to know what that looks like.

[code]<table><tr><th>1</th><th>2</th><th>3</th></tr>
<?
$sql = "select * from table";
$result = mysql_query($sql, $connection)

while ($Array = @mysql_fetch_array($result)){
// things in here are repeated for every row
$thing= $Array['thing'];
$thing2= $Array['thing2'];
$thing3= $Array['thing3'];

echo "<tr><td>$thing</td><td>$thing2</td><td>$thing3</td></tr>";

}
?>
</table>[/code]
... he just showed you?

$result executes the $sql query string. Then the while loop fetches an array of all the column in your table, one row at a time. Inside this loop, $thing, $thing2, and $thing3 are all being assigned specific elements in that fetched array - specific data from the columns of your table.  Then he shows an example of echoing that data out.  The only thing he really left out is wrapping an html img tag around one of the $thing variables; whichever one represents your image name.  But surely you at least know how to do that...


This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.