For the code below, the Insert statement I only need to happen ONCE. When the while loop is performed and the items are displayed for user. is there anyway to do this? I need duplicate entries in the database so I cant do that. see code below
$insertedMeal = false; while($dbRow=$dbQuery->fetch(PDO::FETCH_ASSOC) and ($cnt < $max)) { echo "//displays information from table" $cnt++; $MealID=$dbRow["MealID"] if (!$insertedMeal) { $insertedMeal = true; $stmt=$conn->prepare("INSERT into Meals (UserID, MealID) VALUES (:UserID, :MealID) "); $stmt->execute(array( ':UserID' => $UserID, ':MealID' => $MealID )); } //end
while loop if some_condition is true then set $mealid to desired value end if advance to next recordend loopuse $mealid in insert statement
$stmt->execute(array( ':UserID' => $UserID, ':MealID' => $MealID
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)