i'm going crazy
i'm using the following code:
PHP Code:
<?php
include("config.php");
if (isset($submitok)) {
if ($delete) {
foreach($delete as $val) {
$query = "DELETE FROM award WHERE aw='$uid'";
$result = mysql_query($query) or die("SELECT Error: " . mysql_error() . " in Query: $miet");
}
if($result) {
print ("deleted");
} else {
print ("not gedeleted");
}
}
foreach($aw as $val) {
$lala="UPDATE award SET aw='$val' WHERE awardsid='$val[awardsid]'";
$result = mysql_query($lala) or die("SELECT Error: " . mysql_error() . " in Query: $query");
}
if($result) {
print ("updated");
} else {
print ("not updated");
}
}
else {
?>
<center>
<h3>Awards
<hr width="75%" color="#00AAFF">
</h3>
</center><br>
<form action="<?PHP $PHP_SELF ?>">
<table width="100%" cellspacing="0" cellpadding="5" border="1">
<tr>
<td>Awardsname</td>
<td>Button</td>
</tr>
<?php
include("config.php");
$result = mysql_query("SELECT aw,awardsid,name, url FROM award");
while ($award = mysql_fetch_array($result)) {
$lesane=$award[aw];
if($lesane == "$award[awardsid]") {
$lala="checked";
} else {
$lala="";
}
echo "<tr><td><input type='checkbox' name='aw[$award[awardsid]]' value='$award[awardsid]'";
if ($aw) {
echo "selected $lala>$award[name]</td><td nowrap>";
} else {
echo " $lala>$award[name]</td><td nowrap>";
}
echo "<img src=\"$award[url]\"> </td>";
if(!$award[aw]) {
$uid="aw[$award[awardsid]]";
} else {
$uid="";
}
}
echo "<br><tr><td colspan=2 align=center>";
echo "<br><input type='hidden' name='delete[]' value='$uid'>";
echo "<br><br><input type='submit' name='submitok' value='Submit'>";
echo "</td></tr></table></form>";
}
?>
I have currently 2 awards in the database
1. Awards name with the awardsid 9 and aw is also 9
2. Lesane with the awardsid 13 and aw is empty (means not checked)
So when i execute the script then i c awards name selected and lesane is not selected and if i check the code by <input type =hidden then i c:
<input type='hidden' name='delete[]' value='aw[13]'>
so thats right, lesane is not selected and have the id 13.
Now i'm totally confused because when i click on submit then it deletes lesane totally and when i uncheck the award with the name "awards name" then that aw is not gonna deleted because only the input type = hidden was lesane
So my questions are:
Whats the delete query to delete only the aw row from awards where awardsid=?
&
How is it possible to delete the aw row from the award called "Awards Name" when i uncheck him?
I hope u have a solution