villain222 Posted March 3, 2011 Share Posted March 3, 2011 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>" ?> Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/ Share on other sites More sharing options...
gizmola Posted March 3, 2011 Share Posted March 3, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1182261 Share on other sites More sharing options...
Muddy_Funster Posted March 3, 2011 Share Posted March 3, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1182282 Share on other sites More sharing options...
ZacTopher Posted March 3, 2011 Share Posted March 3, 2011 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 lol Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1182285 Share on other sites More sharing options...
villain222 Posted March 6, 2011 Author Share Posted March 6, 2011 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?). Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1183453 Share on other sites More sharing options...
sasa Posted March 6, 2011 Share Posted March 6, 2011 look http://www.phpfreaks.com/forums/index.php?topic=95426.msg381816#msg381816 Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1183527 Share on other sites More sharing options...
villain222 Posted March 7, 2011 Author Share Posted March 7, 2011 Sasa, thank you. I think i can work with that. Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1183897 Share on other sites More sharing options...
gizmola Posted March 8, 2011 Share Posted March 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1184528 Share on other sites More sharing options...
villain222 Posted March 10, 2011 Author Share Posted March 10, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1185399 Share on other sites More sharing options...
villain222 Posted March 10, 2011 Author Share Posted March 10, 2011 It worked using the example that Sasa provided. Thanks. you're in the comments of the code, bro. Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1185452 Share on other sites More sharing options...
sasa Posted March 10, 2011 Share Posted March 10, 2011 post your new code and we can help you Quote Link to comment https://forums.phpfreaks.com/topic/229464-tabled-results/#findComment-1185531 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.