marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 Right, so the buttons display now, but not the form bit (hence the button doesn't work without the form bit) It should display in the source but it isn't. Im not too good with loops, are you sure the while ($n < ($num/2)){ bit is right? Will it work? Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609516 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Show me the current code. I've lost track ---------------- Now playing: Flyleaf - So I Thought via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609517 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 <?php you know the drill here ?> <style type="text/css"> fieldset { border:1px solid green; padding: 1em; font:80%/1 sans-serif; } legend { padding: 0.2em 0.5em; border:1px solid green; color:green; font-size:90%; text-align:left; } label { float:left; width:25%; margin-right:0.5em; padding-top:0.2em; text-align:right; font-weight:bold; } </style> <script type="text/javascript"> function formgo(){ var cnum = document.lform.ops.length; for (i = 0; i <cnum; i++) { if (document.lform.ops[i].checked) { var chkd = document.lform.ops[i].value; } } switch (chkd) { <?php $query = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error()); while ($row = mysql_fetch_array($query)){ echo 'case "'.$row['name'].'": document.'.$row['name'].'.submit(); break; '; } ?> default: alert(""); } alert(chkd); } </script> <form name="lform"> <fieldset> <legend>Login Forms</legend> <?php $query2 = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error()); // while ($row2 = mysql_fetch_assoc($query2)){ //print_r($row2); //} // echo mysql_num_rows($query); while ($rows = mysql_fetch_assoc($query2)){ echo ' <label for="ops">'.$rows['label'].'</label> <input type="radio" name="ops" value="'.$rows['name'].'"> <br />'; } ?> <button type="button" onClick="formgo()">Submit</button> </fieldset> </form> <?php while ($row = mysql_fetch_assoc($query2)){ $info = explode("|", $row['info']); $num = count($info); if($num % 2 != 0){ echo 'Problem'; }else{ echo '<form name="'.$row['name'].'" action="'.$row['action'].'" method="post">'; //here? $n = 0; while ($n < ($num/2)){ $m = $n+1; echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">'; $n++; $n++; } echo '</form>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609519 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 <?php // connect stuff // CSS Junk // Random JS // I presume the switch is working $q = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error()); while ($r = mysql_fetch_assoc($q)){ echo ' <label for="ops">'.$r['label'].'</label> <input type="radio" name="ops" value="'.$r['name'].'"> <br />'; } while ($a = mysql_fetch_assoc($q)){ $info = explode("|", $ra['info']); $num = count($info); if($num % 2 != 0){ echo 'Problem'; }else{ echo '<form name="'.$row['name'].'" action="'.$row['action'].'" method="post">'; $n = 0; while ($n < ($num/2)){ // Why are you doing this? $m = $n+1; echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">'; $n++; $n++; } echo '</form>'; } } ?> ---------------- Now playing: Flyleaf Vs. The Legion Of Doom - I'm So Sick (T-Virus Remix) via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609520 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 No, it displays the radios, it doesn't display the hidden forms (if you check the source, it doesn't show them) Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609525 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 Is there a reason behind [pre]while ($n < ($num/2))[/pre]? ---------------- Now playing: Foo Fighters - Have It All via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609528 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 yeah, the $info variable is an array, and it stores it in the first block will be a the name of a field, the second the value of it. Then the third block will be the name of another.....and so on. So within each row, there may be many different hidden fields, so that hopefully goes through them, but im running this now (still doesn't work) $l = $num/2; $n = 0; while ($l != ($num/2)){ $m = $n+1; echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">'; $n++; $n++; $l++; } When im trying print_r($row) within the last while loop, it doesn't work... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609532 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 See if you can spot the problem $l = $num/2; // <---!!!!!!!!! $n = 0; while ($l != ($num/2)){ // <-- What did you just define $l as $m = $n+1; echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">'; $n++; $n++; $l++; } ---------------- Now playing: Foo Fighters - Times Like These via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609535 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 I was waiting for you to spot that .... Ok, $l is now 0, but it still doesn't display anything. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609537 Share on other sites More sharing options...
LemonInflux Posted August 6, 2008 Share Posted August 6, 2008 $l = 0; $n = 0; while ($l != ($num/2)){ // <-- What did you just define $l as echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$n+1].'">'; $n++; $n++; // Why twice? $l++; } ---------------- Now playing: Foo Fighters - Disenchanted Lullaby via FoxyTunes Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609538 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 n is incremented twice, so in the first loop, its $info[0] then $info[1]. So next loop it needs to start at $info[2], and to get 0 to 2, it needs to go up by two. Though I think that the problem may lie in the parent while loop. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609539 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 Ok, even when just echoing $num, doesn't work. Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609544 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 ... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-609932 Share on other sites More sharing options...
marklarah Posted August 6, 2008 Author Share Posted August 6, 2008 Yup. Still wont work... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-610248 Share on other sites More sharing options...
marklarah Posted August 7, 2008 Author Share Posted August 7, 2008 I fixed it... Link to comment https://forums.phpfreaks.com/topic/118238-solved-simple-help-please/page/2/#findComment-610732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.