Click here to Skip to main content
15,913,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am trying to get the VALUE of the selected button aka the ID of the item

See code below, the last query brings back $MealID item thats displayed.

The loop loops around & displays 4 items, all which have buttons beside them.

When clicked, i need to get the ID of the meal in order to changed 'Displayed' to 1 in the DB table

Can anyone help?

What I have tried:

//output recipe information
while($dbRow=$dbQuery->fetch(PDO::FETCH_ASSOC) and ($cnt < $max))  
    {
            echo "".$dbRow["Name"].""."<br><img src=\".$dbRow['Picture']."' width='150' height='150' />"."".$dbRow["Instructions"]."<form method='POST'><input type='submit' name='submit' value='Completee' class='button'>";
	  $cnt++;

	$RecipeID=$dbRow["RecipeID"];
	if (!$inserted) {
    $Displayed = false;
		$stmt=$conn->prepare("INSERT into UserMeals (UserID, MealID, Displayed) VALUES (:UserID, :MealID, :Displayed) "); 
		$stmt->execute(array(
	   ':UserID' => $UserID,
		':MealID' => $MealID,
		':Displayed' => $Displayed
		)); 
 }
	}


   if (isset($_POST['submit']) && ($daysLeft == 7)){
$dbQuery = $conn->prepare('UPDATE UserRecipes SET Displayed="1" WHERE UserID=:UserID AND MealID=$MealID');
   $dbParams = array(':UserID'=>$UserID);
 $dbQuery->execute($dbParams);
   }
Posted
Updated 2-Apr-18 4:17am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900