Having some trouble figuring out the logic behind using radio buttons to update multiple rows
if($_POST["btnModify"]) {
$ct=count($txtStoreName);
for($i=0;$i<$ct;$i++) {
if ($_POST['txtAction'] > 0) {
echo $_POST['txtAction'][$i]."<br />";
} else {
echo "die";
}
//echo $_POST['txtStoreName'][$i]."<br />";
//$updateStores = mysql_query("UPDATE directory SET store_name='".$_POST['txtStoreName'][$i]."','store_url=''".$_POST['txtStoreURL'][$i]."','store_cat='".$_POST['txtStoreCat'][$i]."' WHERE store_id='".$_POST['txtAction'][$i]."'");
// echo "<tr><td>Store Database updated.</td></tr>";
}
} else {
heres my form output
// Main loop to cycle through mall directory DB
for ($z=0; $z < $TotRows; $z++) {
$rows = mysql_fetch_array($result);
printf("<tr>");
// Print Store Title and Store URL here line 24
printf("<td>Title<br /><input type=\"text\" name=\"txtStoreName[]\" size=\"50\" value=\"%s\"><br />Web Address<br /><input type=\"text\" name=\"txtStoreURL[]\" size=\"50\" value=\"%s\"></td>", $rows["store_name"], $rows["store_url"]);
/*
/* open another query to list the stores in a select box lines 31-44
*/
$storelist = new dbconnect("localhost","user","pass","db");
$storelist->view_db();
$querystore = "SELECT * FROM dir_category";
$storeResult = mysql_query($querystore);
$storeTotRows = mysql_num_rows($storeResult);
printf("<td>");
printf("<select name=\"txtStoreCat[]\">");
for ($i=0; $i < $storeTotRows; $i++) {
$storeRows = mysql_fetch_array($storeResult);
/*
/* simple IF statement to select the predefined category in the db for select stores
*/
if ($storeRows["cat_id"] == $rows["store_cat"]) {
printf("<option value=\"%s\" selected>%s", $storeRows["cat_id"], $storeRows["cat_name"]);
} else {
printf("<option value=\"%s\">%s", $storeRows["cat_id"], $storeRows["cat_name"]);
}
}
printf("</select>");
printf("</td>");
// Add in code for modification or update
printf("<td><input type=\"radio\" name=\"txtAction[]\" value=\"%s\">Delete? <input type=\"radio\" name=\"txtAction[]\" value=\"%s\">Update?</td>", $rows["store_id"], $rows["store_id"]);
printf("</tr>");
}
printf("<tr><td colspan=\"3\"><input type=\"submit\" name=\"btnModify\" value=\"Apply Changes\"></td></tr>");
printf("</form>");
So basically either prints all records for updating or in the case of the echo statement it work if a radio button is selected, however, how can i distinguish between update and delete with radio buttons? Probably some silly html I haven't come across yet any help would be appreciated