plodos Posted December 20, 2008 Share Posted December 20, 2008 <?php $q = "select * from research_field order by id asc"; $query = mysql_query($q); while ($row = mysql_fetch_array($query)) { $opstr =" <table border='0' width='100%' id='table3'> <tr> <td><input type='checkbox' name='state[]' value='{$row['id']}'>{$row['field']}</td> <td><input type='checkbox' name='state[]' value='{$row['id']}'>{$row['field']}</td> </tr> <table> "; echo $opstr; } ?> output is like that because i used $row['id'] and $row['field'] two times aaaa aaaaa bbbb bbbbb ccccc ccccccc dddd ddddd but i want to seperate with two colums like aaaa bbbb ccccc dddd how can I get the next $row['id'] value ? <td><input type='checkbox' name='state[]' value='{$row['id']}'>{$row['field']}</td> <td><input type='checkbox' name='state[]' value='{$row['id++']}'>{$row['field++']}</td> Quote Link to comment https://forums.phpfreaks.com/topic/137853-script-is-working-but-output-has-problem/ Share on other sites More sharing options...
MadTechie Posted December 20, 2008 Share Posted December 20, 2008 Untested but try this <?php $q = "select * from research_field order by id asc"; $query = mysql_query($q); echo "<table border='0' width='100%' id='table3'><tr>"; $rows = 2; $row=1; while ($row = mysql_fetch_array($query)) { $opstr ="<td><input type='checkbox' name='state[]' value='{$row['id']}'>{$row['field']}</td>"; if($row==$rows) { $row=0; echo "</tr><tr>$opstr"; }else{ $row++; echo $opstr; } } echo "</tr></table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/137853-script-is-working-but-output-has-problem/#findComment-720464 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.