Q695 Posted July 11, 2009 Share Posted July 11, 2009 look for "//outside <tr>": <?php $sql="SELECT * FROM inventory WHERE user='$id'"; $result=@mysql_query($sql,$con) or die(death($sql)); $inv=mysql_num_rows($result); while ($row=mysql_fetch_array($result)){ echo" <tr> <td bgcolor='#003300' align='center' width='100' height='100'>".item($row[item])."</td>";//outside <tr> $row=mysql_fetch_array($result); echo" <td bgcolor='#003300' align='center' width='100' height='100'>item($row[item])</td>"; $row=mysql_fetch_array($result); echo"<td bgcolor='#003300' align='center' width='100' height='100'>item($row[item])</td> </tr>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/165575-solved-syntax-writing-data-outside-of/ Share on other sites More sharing options...
Zane Posted July 11, 2009 Share Posted July 11, 2009 look for "//outside ": $sql="SELECT * FROM inventory WHERE user='$id'"; $result=@mysql_query($sql,$con) or die(death($sql)); ... ... ow[item])."";//outside Ok....I found it Quote Link to comment https://forums.phpfreaks.com/topic/165575-solved-syntax-writing-data-outside-of/#findComment-873366 Share on other sites More sharing options...
Philip Posted July 11, 2009 Share Posted July 11, 2009 @zanus: lmao @Q695: First of all, whats the question? Second, why are you calling mysql_fetch_array($result) 3 times?! - Mainly the 2 inside the while loop... Quote Link to comment https://forums.phpfreaks.com/topic/165575-solved-syntax-writing-data-outside-of/#findComment-873367 Share on other sites More sharing options...
Q695 Posted July 11, 2009 Author Share Posted July 11, 2009 and why is it putting the html outside of the top <tr>? if you need help, here is the html output: <table border="0" cellspacing="20" cellpadding="0"> <a href='?page=transfer&item=1'><img src='images/items/WoodSword.jpg' width='100' height='100' border='0'></a> <tr> <td bgcolor='#003300' align='center' width='100' height='100'></td> <td bgcolor='#003300' align='center' width='100' height='100'></td><td bgcolor='#003300' align='center' width='100' height='100'></td> </tr></table> I was calling fetch 3 times to save time coding (lazyness to get out the prototype face site game). Quote Link to comment https://forums.phpfreaks.com/topic/165575-solved-syntax-writing-data-outside-of/#findComment-873368 Share on other sites More sharing options...
Zane Posted July 11, 2009 Share Posted July 11, 2009 and why is it putting the html outside of the top ? I still don't understand your question I was calling fetch 3 times to save time coding. That won't work....for the simple fact that you typed it three times proves that. This would perfectly suffice. echo ""; while ($row=mysql_fetch_array($result)){ echo "".item($row[item]).""; } echo ""; Quote Link to comment https://forums.phpfreaks.com/topic/165575-solved-syntax-writing-data-outside-of/#findComment-873369 Share on other sites More sharing options...
Q695 Posted July 11, 2009 Author Share Posted July 11, 2009 I am also doing the while loop the way I am because it's like a backpack. I want "<a href='?page=transfer&item=1'><img src='images/items/WoodSword.jpg' width='100' height='100' border='0'></a>" to be included inside the top <td>. I don't really know how to do the <div> table method beside the single line method. Quote Link to comment https://forums.phpfreaks.com/topic/165575-solved-syntax-writing-data-outside-of/#findComment-873370 Share on other sites More sharing options...
Q695 Posted July 11, 2009 Author Share Posted July 11, 2009 Did anyone see what was wrong in the semantics? Eventually there will be multiple rows. Quote Link to comment https://forums.phpfreaks.com/topic/165575-solved-syntax-writing-data-outside-of/#findComment-873376 Share on other sites More sharing options...
Q695 Posted July 11, 2009 Author Share Posted July 11, 2009 I looked at how I did it in a different section, which is dirtier, but it works. <?php $sql="SELECT * FROM inventory WHERE user='$id'"; $result=@mysql_query($sql,$con) or die(death($sql)); while ($row=mysql_fetch_array($result)){?> <tr> <td bgcolor='#003300' align='center' width='100' height='100'><?php item($row[item])?></td> <?php $row=mysql_fetch_array($result); ?> <td bgcolor='#003300' align='center' width='100' height='100'><?php item($row[item])?></td> <?php $row=mysql_fetch_array($result); ?> <td bgcolor='#003300' align='center' width='100' height='100'><?php item($row[item])?></td> </tr> <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/165575-solved-syntax-writing-data-outside-of/#findComment-873394 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.