Marcos01 Posted November 26, 2008 Share Posted November 26, 2008 hello, I want to skip a question in the form i have. input name = sprintf("%02d%02d", $i,$j) variable = $_POST[sprintf("%02d%02d", $i,$j)] The variable works but the input name doesn't. I don't see what is wrong. Thanks for your help. $name = sprintf("%02d%02d", $i,$j); if ($name==0401 && $_POST[sprintf("%02d%02d", $i,$j)]==2) { echo "need to skip questions and goto page 12"; } Link to comment https://forums.phpfreaks.com/topic/134379-skip-form-question/ Share on other sites More sharing options...
flyhoney Posted November 26, 2008 Share Posted November 26, 2008 Why dont you do this? <?php $name = sprintf("%02d%02d", $i,$j); if ($name = 0401 && $_POST[$name]==2) { echo "need to skip questions and goto page 12"; } ?> Link to comment https://forums.phpfreaks.com/topic/134379-skip-form-question/#findComment-699590 Share on other sites More sharing options...
Marcos01 Posted November 26, 2008 Author Share Posted November 26, 2008 flyhoney, thanks for your reply. There is no problem with the value(i wrote variable) but with the name. Link to comment https://forums.phpfreaks.com/topic/134379-skip-form-question/#findComment-699603 Share on other sites More sharing options...
flyhoney Posted November 26, 2008 Share Posted November 26, 2008 Would need to see more code to help. Link to comment https://forums.phpfreaks.com/topic/134379-skip-form-question/#findComment-699608 Share on other sites More sharing options...
Marcos01 Posted November 26, 2008 Author Share Posted November 26, 2008 Ok thanks, here is more code: Here is the input: echo '<input type="'.$row2['type'].'" name="'.sprintf("%02d%02d",$row2['pagina'], $row2['questionnumber']).'" value="'.$row2['responsenum'].'"/>'.$text.'<br />'; $name = sprintf("%02d%02d", $i,$j); if ($name==0401 && $_POST[sprintf("%02d%02d", $i,$j)]==2) { echo "need to skip questions and goto page 12"; } Link to comment https://forums.phpfreaks.com/topic/134379-skip-form-question/#findComment-699612 Share on other sites More sharing options...
flyhoney Posted November 26, 2008 Share Posted November 26, 2008 I dont really know what $i and $j are so im having trouble seeing what is going on. Can you post the entire nested loop? Link to comment https://forums.phpfreaks.com/topic/134379-skip-form-question/#findComment-699633 Share on other sites More sharing options...
Marcos01 Posted November 26, 2008 Author Share Posted November 26, 2008 ok here it is: for ($i=1; $i <= $highpagina; $i ++) { for ($j=1; $j <= $maxquestions ; $j ++) { if ( isset($_POST[sprintf("%02d%02d", $i,$j)])) { echo 'Name:'.sprintf("%02d%02d", $i,$j).' Value='.$_POST[sprintf("%02d%02d", $i,$j)].'<br>'; //=========skip questions $name = sprintf("%02d%02d", $i,$j); if ($name==0401 && $_POST[sprintf("%02d%02d", $i,$j)]==2) { echo "need to skip questions and goto page 12"; } $query = "INSERT INTO `bkdb`.`formanswers` (page ,questionnumber, responsenum, sessionid) values('$i','$j','".$_POST[sprintf("%02d%02d", $i,$j)]."','$sessionid')"; echo "<p>$query</p>"; mysql_query($query, $bkdb) or die("Could not save last page answers"); } } } Link to comment https://forums.phpfreaks.com/topic/134379-skip-form-question/#findComment-699713 Share on other sites More sharing options...
Marcos01 Posted November 27, 2008 Author Share Posted November 27, 2008 Anyone? Link to comment https://forums.phpfreaks.com/topic/134379-skip-form-question/#findComment-699903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.