Greaser9780 Posted February 21, 2007 Share Posted February 21, 2007 This is my code: while($r=mysql_fetch_array($sql1)) { $rank=1; $list = "<table>"; $list .="<td width='61'>$rank </td>; $list .="<td width='150' align='left'>".$r['name']."</TD>"; $list .="<td width='150' align='left'>".$r['1pick']."</td>"; $list .="<td width='50' align='left'>".$r['1pos']."</td>"; $list .="</table>"; echo $list; } How can I incorporate $rank++ so that my rank continues to 2 on the 2nd listing? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 21, 2007 Share Posted February 21, 2007 Put $rank=1 outside the loop, and inside it do $rank++; Quote Link to comment Share on other sites More sharing options...
marcus Posted February 21, 2007 Share Posted February 21, 2007 $rank=1; while($r=mysql_fetch_array($sql1)){ $list = "<table>"; $list .="<td width='61'>$rank </td>; $list .="<td width='150' align='left'>".$r['name']."</TD>"; $list .="<td width='150' align='left'>".$r['1pick']."</td>"; $list .="<td width='50' align='left'>".$r['1pos']."</td>"; $list .="</table>"; $rank++; echo $list; } Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 21, 2007 Author Share Posted February 21, 2007 Thanks for the input. Why does the $rank++ go outside of the $list? It works that way but why? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 21, 2007 Share Posted February 21, 2007 mgall's code has a missing ", as obvious by the colors. $list is a string of html. $rank++ is php incrementing a variable. That's why they don't go together.... Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 21, 2007 Author Share Posted February 21, 2007 Happy to hear the answer. I tried about 10 differentways to incorporate it into the table or td but to no avail.As usual ty for the expert advice. Quote Link to comment 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.