Jump to content

[SOLVED] How would I create a dynamic table Javascript?


madspof

Recommended Posts

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>";
}

?>

 

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>';
   }
}
?>

Archived

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

×
×
  • 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.