Hi all,
If you look at the code below you will notice that i have unsuccessfully attempted to remove multiple checked items from a form.
Can anyone take a look at the code and tell me where i might me going wrong?
Cheers,
micmac
<?
session_start();
//check session variable
if (session_is_registered("valid_user_onestopm"))
{
?>
<?
include ("include/header.inc.php");
include("include/dbconnect_dmoz.php");
if ($delete_checked) {
//$delete=mysql_query("DELETE FROM $table WHERE CatID=$checkbox",$db);
foreach($id as $value) {
$delete = mysql_query("delete from $table where CatID = $value",$db);
}
?>
<META HTTP-EQUIV="refresh" CONTENT="1; URL=dmoz_results.php">
<?
} else if ($final_step) {
$result = mysql_query("SELECT * FROM $table ORDER BY CatID DESC");
while ($row = mysql_fetch_array($result)) {
$id = $row["CatID"];
//$firstname = $row["CatParent"];
$lastname = $row["CatName"];
$info = $row["info"];
$url = $row["url"];
//echo "<input type=\"hidden\" name=\"CatParent\" value=\"$firstname\">";
echo "<input type=\"hidden\" name=\"CatName\" value=\"$lastname\">";
echo "<input type=\"hidden\" name=\"info\" value=\"$info\">";
echo "<input type=\"hidden\" name=\"url\" value=\"$url\">";
include("include/dbconnect_admin.php");
$sql1 = "insert into cat1(CatParent, CatName, country, state_county, info, url, pref, active, confirm_cat)
values ('$new_CatParent','$lastname','$country','$state_county','$info','$url','N','yes','nil')";
$sql2 = "insert into dmoz_info(CatID, updated)
values (LAST_INSERT_ID(),'no')";
$result1 = mysql_query($sql1);
$result2 = mysql_query($sql2);
}
include("include/dbconnect_dmoz.php");
$delete=mysql_query("DELETE FROM $table WHERE CatID!=''",$db);
$result3 = mysql_query($delete);
if($result1 || $result2 || $result3){
echo "<br>Information uploaded successfully.\n";
} else {
echo "<br>Information could not be uploaded.\n";
}
} else if ($next_step) {
$sql3 = "UPDATE $table SET CatName='$new_CatName',info='$new_info',url='$new_url' WHERE CatID=$id";
$result3 = mysql_query($sql3);
$result = mysql_query("SELECT * FROM $table ORDER BY CatID DESC");
echo "<table cellpadding=0 cellspacing=0 border=0>";
while ($row = mysql_fetch_array($result)) {
$id = $row["CatID"];
$firstname = $row["CatParent"];
$lastname = $row["CatName"];
$info = $row["info"];
$url = $row["url"];
echo "<form method=\"post\" action=\"dmoz_results.php\">";
//echo "<input type=\"hidden\" name=\"CatParent\" value=\"$firstname\">";
//echo "<input type=\"hidden\" name=\"CatName\" value=\"$lastname\">";
//echo "<input type=\"hidden\" name=\"info\" value=\"$info\">";
//echo "<input type=\"hidden\" name=\"url\" value=\"$url\">";
}
echo "<tr><td>Country:</td><td></td></tr>";
echo "<tr><td><select name=\"country\">";
echo "<option value=\"Global\">Global</option>";
echo "<option value=\"UK\">U.K.</option>";
echo "<option value=\"US\">U.S.A.</option>";
echo "<option value=\"AUS\">Australia</option>";
echo "<option value=\"DE\">Germany</option>";
echo "<option value=\"FR\">France</option>";
echo "<option value=\"ESP\">Spain</option>";
echo "</select></td><td></td></tr>";
echo "<tr><td>CatParent:</td><td></td></tr>";
echo "<tr><td><input type=\"text\" name=\"new_CatParent\" value=\"$firstname\" size=\"20\"></td><td></td></tr>";
echo "<tr><td>State/County:</td><td></td></tr>";
echo "<tr><td>";
?>
<select name="country">
<option value="" selected>Select a state/county</option>
<option value=""></option>
<option value="">AUSTRALIA</option>
<option value=""></option>
<option value="ACT">ACT</option>
<option value="NSW">NSW</option>
<option value="NT">NT</option>
<option value="QLD">QLD</option>
<option value="SA">SA</option>
<option value="TAS">TAS</option>
<option value="VIC">VIC</option>
<option value="WA">WA</option>
</select>
<?
echo "</td><td></td></tr>";
echo "<tr><td height=10></td><td></td></tr>";
echo "<tr><td><input type=\"submit\" name=\"final_step\" value=\"Final Step\"></tr></td>";
echo "</form>";
echo "</table><br><br>";
} else {
$result = mysql_query("SELECT * FROM $table ORDER BY CatID DESC");
$resultsnumber = mysql_numrows($result);
if ($resultsnumber == "0") {
echo "<br><br>There are <b>no</b> listings in the temperory table of the onestopm database";
} else {
echo "<table cellpadding=5 cellspacing=0 border=0>";
$alternate = "2";
while ($row = mysql_fetch_array($result)) {
$id = $row["CatID"];
$firstname = $row["CatParent"];
$lastname = $row["CatName"];
$info = $row["info"];
$url = $row["url"];
if ($alternate == "1") {
$color = "#ffffff";
$alternate = "2";
} else {
$color = "#cccccc";
$alternate = "1";
}
echo "<form method=\"post\" action=\"dmoz_results.php?CatParent=$firstname\">";
echo "<input type=\"hidden\" name=\"CatID\" value=\"$id\">";
echo "<tr bgcolor=$color><td><input type=\"text\" name=\"new_CatName\" value=\"$lastname\" size=\"65\"></td><td></td><td><div align=\"right\"><input type=\"checkbox\" name=\"checkbox[]\" value=\"$id\"></div></td></tr>";
echo "<tr bgcolor=$color><td><textarea name=\"new_info\" cols=\"50\" rows=\"5\">$info</textarea></td><td></td><td></td></tr>";
echo "<tr bgcolor=$color><td><input type=\"text\" name=\"new_url\" value=\"$url\" size=\"65\"></td><td><a href=\"$url\" target=\"_blank\">URL</a></td><td><a href='delete_dmoz.php?id=$id' onClick=\"return confirm('Are you sure?')\">delete record</a></td></tr>";
echo "<tr><td colspan=\"4\"><font color=\"red\">-------------------------------------------------------------------------------------------------------------------</font></td></tr>";
}
echo "<tr><td><input type=\"submit\" name=\"next_step\" value=\"Next Step\"> <input type=\"submit\" name=\"delete_checked\" value=\"Delete all checked listings\"></tr></td>";
echo "</form>";
echo "</table><br><br>";
}
}
?>
<?
} else {
// You are not logged in.
//Only logged in members may see this page.
require("warning.htm");
}
?>