Wednesday, May 5, 2010

Post Vars as an Array

$result_storeList=mysql_query('SELECT * FROM stores');

while($arrayStoreName=mysql_fetch_array($result_storeList)) {
echo "".$arrayStoreName['name']."(put html checkbox here with $arrayStoreName['ID']).(other HTML here)\n";
}


Submit that to:

$getStore = "SELECT * from stores";
$getStoreQuery = mysql_query($getStore);
while($getStoreArray = mysql_fetch_array($getStoreQuery)) {
        $totalStoreNum = $getStoreArray['ID'];

if(htmlspecialchars($_POST[$getStoreArray['ID']])) {

$storeChoice = $getStoreArray['ID'];

$sql_Query = "INSERT INTO storeItems (storeID,itemID) VALUES ('".$storeChoice."','".$recordID."')";

mysql_query($sql_Query); }

}

No comments:

Post a Comment