Jump to content

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


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

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.