hey all.
Have a list of checkboxes with SQL data in table. Currently using echo to ensure I'm using the correct data, however, echo it returning the last checkbox data only. Here is a segment of what I've got.
echo "<table border='1'>";
echo "<tr><th>Last Name</th><th>First Name</th><th>Party</th><th>Description</th><th>Cast Vote</th>";
while($row = mysql_fetch_array($query))
{
$id= $row['Candidate_ID'];
echo "<tr><td>";
echo $row['LastName'];
echo "</td><td>";
echo $row['FirstName'];
echo "</td><td>";
echo $row["Party"];
echo "</td><td>";
echo $row["Description"];
echo "</td><td>";
echo "<input type='checkbox' name='addcandidate[]' value='<?php $id;?>' size='7'>";
echo $id;
if(isset($_POST['addcandidate'])){
$candidate= $_POST['addcandidate'];
$N= count($candidate);
$test= "SELECT LastName FROM candidate WHERE Candidate_ID = '$id'";
$sql4= mysql_query($test) or die("SQL error: ".mysql_error());
$candidateID= mysql_fetch_array($sql4);
$candidateID= $candidateID[0];
for($i=1; $i <= $N; $i++){
$alter= "ALTER TABLE '$votertable' ADD '$candidateID' int";
}
}
}
echo "</table>";
?>
<input type='submit' value='Submit'>
</form>
<?php
echo $id;
echo $candidateID;
?>
Any suggestions?