PhilGDUK Posted January 27, 2007 Share Posted January 27, 2007 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 8thank you! Quote Link to comment https://forums.phpfreaks.com/topic/35968-mysql-results-in-a-columned-table/ Share on other sites More sharing options...
JJBlaha Posted January 27, 2007 Share Posted January 27, 2007 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] Quote Link to comment https://forums.phpfreaks.com/topic/35968-mysql-results-in-a-columned-table/#findComment-170578 Share on other sites More sharing options...
PhilGDUK Posted January 27, 2007 Author Share Posted January 27, 2007 cheers, i get most of it, just not sure about the array part, i feel like a noob again because i have forgotten what i know!Right i basically have a mysql table with the image name, so how do i include that and show the picture?cheers Quote Link to comment https://forums.phpfreaks.com/topic/35968-mysql-results-in-a-columned-table/#findComment-170585 Share on other sites More sharing options...
.josh Posted January 27, 2007 Share Posted January 27, 2007 ... 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... Quote Link to comment https://forums.phpfreaks.com/topic/35968-mysql-results-in-a-columned-table/#findComment-170592 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.