madspof Posted August 30, 2007 Share Posted August 30, 2007 I have picture section where users can upload pictures to my website and I have created a basic way viewing these pictures but this is not astheticaly pleasing. So i was wondering if i could populate a html table with these pictures. The way this system works is that it uses a while loop that brings the date, url and also who uploaded the picture into the page. I was wondering if this information could be put into a table but i cannot see a way. Here is a live demo: www.deskfun.co.nr/testing/list/listing.php Here is the code i have: <?php include("connect.php"); $query = "SELECT picid, userid, url, date FROM userpic"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo "This is the $number User. <br><br>" . "Name :{$row['picid']} <br>" . "Subject : {$row['userid']} <br>" . "<img src='{$row['url']}' width='400' height='300'><br>" . "Date uploaded : {$row['date']} <br><br><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/ Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 An HTML table is just like any other html. Just echo it. What is the problem? Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338090 Share on other sites More sharing options...
madspof Posted August 30, 2007 Author Share Posted August 30, 2007 Well i cannot make it so that the table works in a way that it poppulates sideways as well as downwords if you see what i mean Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338096 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 No I don't see what you mean. Are you saying you don't know how to do more than one cell per row? Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338102 Share on other sites More sharing options...
madspof Posted August 30, 2007 Author Share Posted August 30, 2007 Well i cannot get the script to create rows only collums could you give me an insight on what i would need to do thanks Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338106 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Say you want three cells per row. It would work like this (this isn't tested but it should be close, you might have to work with it a bit) <?php print '<table>'; $counter = 0; $cellsPer = 3; while($row = mysql_fetch_assoc($result)){ if($counter%$cellsPer == 0){ print '<tr>'; } print '<td>'; print "This is the $number User. <br><br>" . "Name :{$row['picid']} <br>" . "Subject : {$row['userid']} <br>" . "<img src='{$row['url']}' width='400' height='300'><br>" . "Date uploaded : {$row['date']} <br><br><br>"; print '</td>'; if(($counter+1)%$cellsPer == 0){ print '</tr>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338107 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Share Posted August 30, 2007 lol you can use more than one table cell per table row. thats just ridiculous. Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338109 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 darkfreaks, considering some of the questions you've asked earlier today, let's leave the rude and sarcastic remarks to the professionals. If you're not actually going to HELP, hold back on the snark. Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338110 Share on other sites More sharing options...
madspof Posted August 30, 2007 Author Share Posted August 30, 2007 quick question what is the differences between print and echo Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338120 Share on other sites More sharing options...
Jessica Posted August 31, 2007 Share Posted August 31, 2007 None really. I prefer print, but other prefer echo because it is one character shorter. It's a habit. Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338121 Share on other sites More sharing options...
darkfreaks Posted August 31, 2007 Share Posted August 31, 2007 im an echo man haha Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338124 Share on other sites More sharing options...
madspof Posted August 31, 2007 Author Share Posted August 31, 2007 okay thanks and i changed that script a bit and it worked excelent just what i needed thanks Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338125 Share on other sites More sharing options...
Jessica Posted August 31, 2007 Share Posted August 31, 2007 No problem. Quote Link to comment https://forums.phpfreaks.com/topic/67374-solved-how-would-i-create-a-dynamic-table-javascript/#findComment-338131 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.