Forum Moderators: coopster
Any help with the loop would be great.
<?
session_start();
if ($_SESSION[valid]!= "yes") {
header("Location: [127.0.0.1...]
exit;
}
$db_name = "voter_ballotDB";
$table_name = "candidate";
$connection = @mysql_connect("localhost", "bobby", "bhappy")
or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or
die(mysql_error());
$sql = "SELECT cand_id, cand_fname, cand_lname, cand_office, cand_major
FROM $table_name WHERE cand_office = 'President' ORDER BY cand_lname";
$result = @mysql_query($sql, $connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$cand_id = $row['cand_id'];
$cand_fname = $row['cand_fname'];
$cand_lname = $row['cand_lname'];
$cand_office = $row['cand_office'];
$cand_major = $row['cand_major'];
$menu_block .= "
<input type=\"radio\" name=\"cb1\">$cand_lname, $cand_fname<br>";
}
$button_block .="
<FORM METHOD=POST ACTION=\"vicepresident.php\">
<input type=\"Submit\" value=\"Vote\">
<input type=\"Submit\" value=\"Skip\">
<P><INPUT TYPE=\"submit\" NAME=\"Continue\" VALUE=\"Continue\"></P>
</form>";
?>
<HTML>
<HEAD>
<TITLE>Voting System</TITLE>
</HEAD>
<BODY>
<P><h1><strong>Please Vote For President</strong></h1></P>
<P><stong>Choose From The Following:</strong></P>
<hr>
<? echo "$menu_block";?>
<hr>
<? echo "$button_block";?>
</BODY>
</HTML>
are these the values that you need to build into the radio buttons?
$cand_id = $row['cand_id'];
$cand_fname = $row['cand_fname'];
$cand_lname = $row['cand_lname'];
$cand_office = $row['cand_office'];
$cand_major = $row['cand_major'];
I don't really understand what you need to do. Maybe if you could show us where and what you need to loop through or a static example that you want to change to a loop it would better demonstrate your problem.