PHP Post Form

I can’t seem to figure out how to resolve this issue. I have a form that grabs categories from my database and inserts it into a while loop. I realize that my coding may not be good at the moment, I am still working on it all, any help would be greatly appreciated.

Here is what i have for the form:

vote.php


<form name="form1" method="post" action="./inserts/voteform.php">
<table width="50%">

<?php
$g_cat = $_GET['category'];


$catlist1 = mysql_query( "SELECT * FROM vote
                          LEFT JOIN voted
                          ON voted.category = vote.id

                          " );


while($cat_1 = mysql_fetch_array( $catlist1 )) {
$category = $cat_1['category_name'];
$category_user = $cat_1['username'];
$category_text = $category . '_text';
$cats = $cat_1['category'];
if($cats != '0'){
echo "<tr>
         <td colspan='2' bgcolor='cyan'>
            <h3>$category</h3>
         </td>
<tr />";


$namelist1 = mysql_query( "SELECT * FROM email_list_final
                          LEFT JOIN voted
                          ON email_list_final.id = voted.username
                          LEFT JOIN vote
                          ON vote.id = voted.category
                          WHERE vote.category_name = '$category'
                          ORDER BY vote.id ASC" );


while($row1 = mysql_fetch_array( $namelist1 )) {

	$v_id = $row1['id'];
   $lastname1 = $row1['last'];
   $firstname1 = $row1['first'];

   $membership1 = $row1['membership']; 
	$bio = $row1['bio'];
	$biopic = "./images";

echo "
		<tr>
         <td>
            <input type='radio' name='$category' value='$membership1' />";
echo "

$firstname1 $lastname1
</td>
      </tr>
	<tr>
		 <td>
<input type='radio' name='$category' value='' /><input type='text' name='$category_text' value='Write your own Candidate' size='40' />

			
         </td>
      </tr>
         ";
}
}else{}
}
?>


</table><br />
<input name="submit" type="submit" value="Submit" />


</form>

when I try to show this in the viewform page I would like to list the categories (in $_POST) without having to list them all (I have no idea how many categories there may be)

voteform.php


<?php
include('../includes/connect.php');

$catlist1 = mysql_query( "SELECT * FROM vote
                          LEFT JOIN voted
                          ON voted.category = vote.id

                          " );


while($cat_1 = mysql_fetch_array( $catlist1 )) {
$category = $cat_1['category_name'];
$category_user = $cat_1['username'];
$category_text = $category . '_text';
$cats = $cat_1['category'];


$position = nl2br(addslashes(htmlspecialchars($_POST['$category'])));

echo "<tr>
         <td colspan='2' bgcolor='cyan'>
            <h3>$category</h3>
         </td>
<tr />";


echo "
      <tr>
         <td>

$position
</td>
      </tr>

         ";
}
?>


</table>


any suggestions on how to get this to do what I hope would be great…Im just not sure what I need to look at.

What is it doing right now and what are you trying to make it do?

I also noticed that also you are creating a value for $g_cat from the query string with GET I don’t see where you are using it.

yeah, don’t mind the $_GET variable…I was using that for something else and must have missed it when deleting it out.

My objective is to create a while loop so I can just use one small command to have a repeated form with names under the various categories.

President
person 1
person 2
etc

Treasurer
person 1
person 2
etc

I managed to get it to show each name that falls under the list (unfortunately if I have more than one name under the category, the category repeats the amount of times that someone is listed.I’m not sure how to fix that part yet.)

So, at the moment, I actually have only 1 name per category (noone seems to want to run this year)

when I “vote” for someone in the specified category, its sent to the next form. From there, my problem expands: the $_POST feature wants me to separate the choices into individual category listings.

What I am looking for on this page is to have it run through a while loop (if possible) and show me the names that I chose by using one $_POST (hopefully it’s within a loop)

The eventual goal of this is for the post to be sent out by email.

At the moment, what is occurring is nothing. the only way that I can get the $_POST to show is to type out all of the possible categories into separate lines.
I hope I made my objective clearer.