php - Why am I getting a break in the output of this WHERE loop? -


i made while loop game making looks this: updated full if statement

if ($switch == 0){ echo '<a href="/index.php">exit voting booth - may vote again later</a></br>'; echo '<div role="main" id="main"><div class="wrapper">'; echo '<h3>ballot questions:</h3></br>'; $query = "select * ballot_questions"; $ballots = mysql_query($query,$link) or die("unable select: ".mysql_error()); $x = 1;  //echo $x; while($row = mysql_fetch_array($ballots)) { echo '<h4>'.$row['question'].'<form action="vote_engine.php" method="post"> <input type="hidden" name="id" value= "',$id,'"> yes:<input type="radio" value="yes" name = "',$x,'"> no:<input type="radio" value="no" name = "',$x,'"></h4></br>'; $x++; //echo $x; } echo '<p><input type="submit" value="submit" name="submit"> </form></p>'; } 

shows in browser this:

test ballot question 1

yes no

test ballot question 2 yes no

test ballot question 3 yes no

test ballot question 4 yes no

the first line shows if there /br tag. rest shows want.

here html output:

exit voting booth - may vote again later

ballot questions:

test ballot question#1yes:no:test ballot question #2yes:no:test ballot question #3yes:no:test ballot question #4yes:no:

any ideas? thanks

this not produce valid html @ all. knows how browsers going try render page.

two things see off bat:

  1. your <br> tags not correct.
  2. you starting bunch of forms , ending tags once.

you can fix code:

<?php if ($switch == 0) {     echo '<a href="/index.php">exit voting booth - may vote again later</a></br>';     echo '<div role="main" id="main"><div class="wrapper">';     echo '<h3>ballot questions:</h3><br />'; ; // </br>     $query = "select * ballot_questions";     $ballots = mysql_query($query, $link) or die("unable select: " . mysql_error());     $x = 1;      echo '<form action="vote_engine.php" method="post">'; // create 1 form     while ($row = mysql_fetch_array($ballots)) {         echo '<h4>' . $row['question'] . '<input type="hidden" name="id" value= "', $id, '">                 yes:<input type="radio" value="yes" name = "', $x, '">                 no:<input type="radio" value="no" name = "', $x, '">               </h4>             <br />'; // </br>         $x++;     }     echo '<p><input type="submit" value="submit" name="submit"></p></form>'; // switch </p> , </form> tags } ?> 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -