I have this script a lot of it is probably useless. Well what i am trying to do is have all the rows display in an html table then in the last 2 columns have a drop down box with ACCEPTED, DECLINED, PENDING
then when they hit Apply i want it to update the specific field for that row. I used variable variables because i dont know arrays. So please someone help me. I have gotten very close with this crap coding i just cant get it to update the field or if someone would show me how they would accomplish something like this.
<html>
<head>
<title>[MWG] Applicants</title>
<head></head>
<body>
<?php
$db_host = 'localhost';
$db_user = 'DATABASE USER';
$db_pwd = 'DATABASE PASS';
$database = 'DATABASE';
$table = 'applications';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die();
if (!mysql_select_db($database))
die();
if (isset($_POST['submit'])) {
//$insert2 = "INSERT INTO applications (accepted)
//$insert2 = "UPDATE application SET accepted='".$_POST['$add']."' WHERE username=$add2";
//INSERT INTO applications (accepted) WHERE id = '$add' VALUES ('".$_POST['$add']."')";
//$add_member2 = mysql_query($insert2);
mysql_query("UPDATE application SET accepted='".$_POST['$add']."' WHERE username=$add2");
?>
<h1>Status Changed</h1>
<p>Members Status Sucessfully changed. <a href="http://mwgclan.com/apply/admin/index.php">Go Back To Admin Panel</a></p>
<?php
}
else
{
// sending query
$result = mysql_query("SELECT * FROM {$table}");
if (!$result) {
die();
}
$fields_num = mysql_num_fields($result);
?>
<h1><center>Applicants</h1></br>
</center>
<br>
<table align="center" style= cellspacing="0" cellpadding="2" width="100%" background="themes/subBlack/images/bg.png" border="2">
<tbody>
<tr>
<td width="8%"><b>Username:</b></td>
<td width="8%"><b>Name:</b></td>
<td width="10%"><b>Email:</b></td>
<td width="10"><b>Country:</b></td>
<td width="4%"><b>Age:</b></td>
<td width="8%"><b>X-Fire:</b></td>
<td width="10%"><b>Date Submitted:</b></td>
<td width="16%"><b>How You Heard of [MWG]:</b></td>
<td width="16%"><b>Reason You Joined:</b></td>
<td width="10%"><b>Status:</b></td>
<?php
$add = "";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$row = mysql_fetch_array($result);
$id = $row['id'];
$idl = strlen($id);
$il = strlen($i);
$idl = (0 - $idl);
$constant = "";
echo "<tr>";
echo "<td>", $row['username'], "</td>";
echo "<td>", $row['name'], "</td>";
echo "<td>", $row['email'], "</td>";
echo "<td>", $row['country'], "</td>";
echo "<td>", $row['age'], "</td>";
echo "<td>", $row['xfire'], "</td>";
echo "<td>", $row['datesubmitted'], "</td>";
echo "<td>", $row['howyouheard'], "</td>";
echo "<td>", $row['reasontojoin'], "</td>";
$us = "";
$usr = $row['username'];
$usrl = strlen($user);
$$us = $user;
$rest2 = substr("$us${$us}", "$usrl"); // returns "username"
$$constant2 = $rest2;
$add2 = "$constant2${$constant2}";
$$i = $id;
$rest = substr("$i${$i}", "$idl"); // returns "$id"
$$constant = $rest;
$add = "$constant${$constant}";
echo "<td>", $row['accepted'];
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<select name="<?php $add ?>">
<option value="Accepted" selected="selected">Accepted</option>
<option value="Declined">Declined</option>
<option value="Pending">Pending</option>
</td>
<td>
<input type="submit" name="submit" value="Apply"></form>
</td>
</tr>
<?php } }
/*
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($result);
*/
?>
</tbody></table></html>
THANKS IN ADVANCE