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.