i have a question. i am trying to send a variable from a page with a drop down list to a page where i can check for approval and update the approval as nesscesary.
i have the code there but i am not seeing results. but i am not getting any errors. could i get some help? thanks
here is the code for the drop down menu:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="teamsearch" name="teamsearch" method="post" action="playercheck.php">
<p> </p>
<p>
<label>
<?php
include 'dbc.php';
$query="SELECT teamname,teamid FROM teams";
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
$result = mysql_query ($query);
echo "<select name=teamname value=''>Team Name</option>";
// printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[teamid]>$nt[teamname]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>
<input name="submit" type="submit" id="submit" value="Submit" />
</form>
<p> </p>
<p> </p>
</body>
</html>
here is the page that will show the teamid from the page with the drop down menu:
<?php
/* For the following details, ask your server vendor */
$dbhost = "localhost";
$dbuser = "netman13_adminbc";
$dbpass = "95887rj";
$dbname = "netman13_bccsltest";
mysql_connect( $dbhost, $dbuser, $dbpass ) or die ( "Unable to connect to MySQL server" );
mysql_select_db( "$dbname" );
mysql_query( "SET NAMES utf8" );
if(isset($_POST["update"]) AND isset($_POST["hiddenid"]))
{
$updated=false;
$activateapproved=array();
$deactivateapproved=array();
foreach($_POST["hiddenid"] AS $value)
{
if(isset($_POST["checkboxapproved"][$value]))
$activateapproved[]=intval($value);
else
$deactivateapproved[]=intval($value);
}
if(count($activateapproved)>0) {
$SQL=sprintf("UPDATE players SET approved=1 WHERE id in (%s)" , implode(",", $activateapproved));
mysql_query($SQL) OR DIE(mysql_error());
$updated=true;
}
if(count($deactivateapproved)>0) {
$SQL=sprintf("UPDATE players SET approved=0 WHERE id in (%s)" , implode(",", $deactivateapproved));
mysql_query($SQL) OR DIE(mysql_error());
$updated=true;
}
if($updated==true) {
header("Location: ".$_SERVER["PHP_SELF"]."?todo=updated");
exit();
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if(isset($_GET["todo"]) AND $_GET["todo"]=="updated")
{
echo "Updated succesfully";
}
?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" name="Form">
<table border="1">
<tr>
<td>First name</td> <td>Last Name</td> <td>Address</td> <td>City</td> <td>Postal Code</td> <td>Phone Number</td> <td>Height Ft</td> <td>Height In</td> <td>Weight</td> <td>Birthdate</td> <td>Teamid</td> <td>Player Type</td> <td>Approved</td>
</tr>
<?php
$sql="select * from players where teamid='$nt[teamid]'";
$res=mysql_query($sql) or die(mysql_error());
while($r=mysql_fetch_assoc($res))
{
?>
<tr>
<input type="hidden" name="hiddenid[]" value="<?php echo $r["id"]?>">
<td>
<div align="center"><?php echo empty($r["fname"])?' ':htmlspecialchars($r["fname"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["lname"])?' ':htmlspecialchars($r["lname"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["address"])?' ':htmlspecialchars($r["address"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["city"])?' ':htmlspecialchars($r["city"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["postal"])?' ':htmlspecialchars($r["postal"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["phone"])?' ':htmlspecialchars($r["phone"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["hfeet"])?' ':htmlspecialchars($r["hfeet"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["hinches"])?' ':htmlspecialchars($r["hinches"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["weight"])?' ':htmlspecialchars($r["weight"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["birthdate"])?' ':htmlspecialchars($r["birthdate"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["teamid"])?' ':htmlspecialchars($r["teamid"]); ?> </div></td>
<td>
<div align="center"><?php echo empty($r["status"])?' ':htmlspecialchars($r["status"]); ?> </div></td>
<td>
<div align="center">
<input type="checkbox" name="checkboxapproved[<?php echo $r["id"]?>]" value="1"<?php echo empty($r["approved"])?'':' checked="checked"'; ?> />
</div></td>
</tr>
<?php
}
?>
</table>
<input type="submit" value="update" name="update">
</form>
</body>
</html>