Hi all,
After some time pulling my hair my brain has turned to mush on this senerio. I'd appreciate any help offered as my PHP skills are still limited. Here is the senerio:

I am creatings a voting website. I am currently creating an admin page that creates local election. From Page 1 the admin creates the election name and number of seats available which then invokes page 2 - a list candidates displayed by a php loop from a SQL table. There are checkboxes included in the loop as I'd like the admin to select which candidates to involve. I'd like the code to take the the checked candidates and add their names to a different table.
Here is what I've got so far:

include "db_login.php";

$votertable= $_SESSION['prstvname']."".$votetable;
$row = "SELECT COUNT (*) FROM candidate";
$select = "Select Candidate_ID, LastName, FirstName, Party, Description FROM candidate";
query = mysql_query($select)
    or die ("Couldn't excute query.");
                   $candidate= $_POST['addcandidate'];
## Here is whereIm encountering difficulty##
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
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))
        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='0' size='7'>";
	echo $id;
    echo "</table>"; 
<input type='submit' value='Submit'>

Using echo with if(isset) returns an array which references the values of the checkbox.
Is it possible to somehow grab the "LastName" of each candidate which I can then put into a simple loop to ALTER a SQL table?
I'd appreciate any help or information.

7 Years
Discussion Span
Last Post by Exploded Fiber

OK I've made this more complicated than necessary. I didn't consider assigin a php variable to the html values and looping with reference from variables...


This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.