Jump to content

tabled results


villain222

Recommended Posts

Ok, homies, can somebody bail me out.  I can't come up with an answer.  I have some stuff i want to query from a db and display in a table that is 4 to 5 columns wide and however many rows tall.  I can get the results, but i can't get them to individually go each cell.  I get a result and it repeats 5 times and then creates the new row and repeats the same thing.  I want each box of the table to show a different result based on date. Here's the code i got.

<?
$sessionid = $_SESSION['userid'];
$join = "SELECT items.*, image.* FROM items, image WHERE items.imageid = image.imageid AND items.userid = $sessionid ORDER BY dateposted DESC";
//-----------
function maketable($join){
//count number of columns

$columns = '5'; //echo $columns;
//run the query 
$PicSQL = mysql_query($join) or die(mysql_error()) ;
$itemnum = mysql_num_rows($PicSQL);
while ($row=mysql_fetch_array($PicSQL)){
//echo $itemnum;
if($itemnum > 0){ 
  do{     
   echo "<tr>" ;
   for($x = 0; $x < $columns; $x++){  
    echo "<td>" .$row['name']. "</td>" ;
   }
   echo "</tr>" ;
  } while ($row=mysql_fetch_array($PicSQL));
}
}
}
//--------------

echo "<center><table border=1>";	
echo "<strong>";

maketable($join);
echo "</tr></table><br>" 
?>

Link to comment
Share on other sites

Lookey har, yer code ain't even all that, mein. 

 

You gone and done a while loop and inside that biznatch you go all crazy and add a do-while?? WTF?  That ain't even right.  Pull that do-while outta there, cause that be janky.

Link to comment
Share on other sites

Lookey har, yer code ain't even all that, mein. 

 

You gone and done a while loop and inside that biznatch you go all crazy and add a do-while?? WTF?  That ain't even right.  Pull that do-while outta there, cause that be janky.

ROFL! that just brightened up my morning!

 

+1000

 

:D lol

Link to comment
Share on other sites

well thanks for the Non-help in the "php coding HELP" forum.  Its a sample of what I'm doing.  I refine a lot later when i get the result i want, but anyway its reporting an error that it is expecting while.  This is a bit of code I snatched else where and I've been trying to get the result I want.

 

I removed the do-while Shizz.  still the same as before.

 

p.s.  that accent was weak,    it should have been done like this:

 

LUkey har, yer code ain't even all Dat, mayn.

 

u gon an' dun a wile lup an' inside Dat biznOtch U go all crazy an' add a du-wile?? WTF?  Dat ain't even rite.  Pull Dat du-wile outa there, cuz Dat b janky (really? Janky?).

Link to comment
Share on other sites

well thanks for the Non-help in the "php coding HELP" forum.  Its a sample of what I'm doing.  I refine a lot later when i get the result i want, but anyway its reporting an error that it is expecting while.  This is a bit of code I snatched else where and I've been trying to get the result I want.

 

I removed the do-while Shizz.  still the same as before.

 

p.s.  that accent was weak,    it should have been done like this:

 

LUkey har, yer code ain't even all Dat, mayn.

 

u gon an' dun a wile lup an' inside Dat biznOtch U go all crazy an' add a du-wile?? WTF?  Dat ain't even rite.  Pull Dat du-wile outa there, cuz Dat b janky (really? Janky?).

 

I must be from a different part of the hood.

 

With that said, I did point out an error in your code.  If you post the current version maybe we can help you out.  I don't know what you removed, but you should have left in the while loop and just removed the inner do... while() loop.

Link to comment
Share on other sites

I removed the do while within the top while loop.  The end result was the same.  I think sasa's post is leading in the right direction from my brief look at it.  I just have to get my results to post in each table cell.  I'm going to try working on it now and see if we can get this solved.

Link to comment
Share on other sites

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.