Patrick3002 Posted August 16, 2007 Share Posted August 16, 2007 Heres my code: <?php include_once("config.php"); $sql="SELECT `title`, `op1`, `op2`, `op3`, `op4`, `op5`, `op6`, `op7`, `op8`, `op9`, `op10` FROM `vote` WHERE `poll_id` = '69'"; $result=mysql_query($sql); $num_rows=mysql_num_rows($result); echo "<table width=\"335\" height=\"342\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\"> <tr> <td height=\"42\" colspan=\"2\" align=\"center\" valign=\"middle\"><table width=\"95%\" height=\"80%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td align=\"left\" valign=\"middle\" bgcolor=\"#00CCFF\"><?php echo $title; ?></td> </tr> </table></td> </tr>"; $i=0; $x=0; while ($i < $num_rows) { $title=mysql_result($result,$i,"title"); $op=mysql_result($result,$i,"op1"); $op=mysql_result($result,$i,"op2"); $op=mysql_result($result,$i,"op3"); $op=mysql_result($result,$i,"op4"); $op=mysql_result($result,$i,"op5"); $op=mysql_result($result,$i,"op6"); $op=mysql_result($result,$i,"op7"); $op=mysql_result($result,$i,"op8"); $op=mysql_result($result,$i,"op9"); $op=mysql_result($result,$i,"op10"); $brdr_clr=mysql_result($result,$i,"brdr_clr"); echo "<tr> <td>$op</td> <td width=\"73\" align=\"center\" valign=\"middle\"><input name=\"$op\" type=\"radio\" value=\"radiobutton\"></td> </tr>"; $i++; $x++; } echo "</table>"; ?> Now, its only echoing the last $op var, which would be = to whatever op10 = in the db, i want it to echo w/e op1-op10 is from the db, so i guess i'd need it to automatically increase, but im not sure how i'd go about doing that. I want to echo this for each op1-op10, so it would echo that table and the first table, $op would = op1, the second table, $op2 would = op2 and so on... echo "<tr> <td>$op</td> <td width=\"73\" align=\"center\" valign=\"middle\"><input name=\"$op\" type=\"radio\" value=\"radiobutton\"></td> </tr>"; Any help is appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/65325-solved-need-some-help/ Share on other sites More sharing options...
Patrick3002 Posted August 16, 2007 Author Share Posted August 16, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/65325-solved-need-some-help/#findComment-326259 Share on other sites More sharing options...
Patrick3002 Posted August 17, 2007 Author Share Posted August 17, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/65325-solved-need-some-help/#findComment-326292 Share on other sites More sharing options...
MrBillybob Posted August 17, 2007 Share Posted August 17, 2007 you have to loop through $op not just echo it... so <?php while ($op = mysql_fetch_array($result)) { echo "<tr> <td> $op['op1']; </td> <td width=\"73\" align=\"center\" valign=\"middle\"> <input name=\"$op\" type=\"radio\" value=\"radiobutton\"> </td> </tr>"; echo "<tr> <td> $op['op2']; </td> <td width=\"73\" align=\"center\" valign=\"middle\"> <input name=\"$op\" type=\"radio\" value=\"radiobutton\"> </td> </tr>"; //and so on } Quote Link to comment https://forums.phpfreaks.com/topic/65325-solved-need-some-help/#findComment-326301 Share on other sites More sharing options...
trq Posted August 17, 2007 Share Posted August 17, 2007 For starters, don't bump your thread every 45 mins or so, have some patience and if need be reword your question a little clearer. Secondly... the problem you describe is only one issue here. The code you provided really ought not to be working as you expect. Your opening <?php tages within an already existing php echo'd string. Thirdly, this piece.... $op=mysql_result($result,$i,"op1"); $op=mysql_result($result,$i,"op2"); $op=mysql_result($result,$i,"op3"); $op=mysql_result($result,$i,"op4"); $op=mysql_result($result,$i,"op5"); $op=mysql_result($result,$i,"op6"); $op=mysql_result($result,$i,"op7"); $op=mysql_result($result,$i,"op8"); $op=mysql_result($result,$i,"op9"); $op=mysql_result($result,$i,"op10"); Your assinging different results over the same variable... what do you expect the resultant $op to be? You might try..... <?php while ($i < $num_rows) { for ($cnt = 1; $<=10; $i++) { $op = mysql_result($result,$i,${'op'.$cnt}); echo "<tr><td>$op</td><td width=\"73\" align=\"center\" valign=\"middle\"><input name=\"$op\" type=\"radio\" value=\"radiobutton\"></td></tr>"; $cnt++; } $i++; $x++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65325-solved-need-some-help/#findComment-326307 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.