PHP noob here. I've written out the 8 step to try to get the data from the database but my first line just return me with
"Notice: Undefined index: itemid in C:\xampp\htdocs\1605267B\KUSO\cart.php on line 130"
I can't find anything wrong with using the GET function on the first line. Please do help me.
<?php
$itemid = $_GET['itemid'];
//TODO 1: Connect to forumdb database
$mysqli = new mysqli("localhost","root",null,"kuso");
//TODO 2: Prepare the statement to select message id and subject info belonging to $userid from forummessage table
$stmt = $mysqli->prepare("select itemid, itemname, itempicture, description, price from items where itemid=?");
//TODO 3: Bind the values
$stmt->bind_param("i",$itemid);
//TODO 4: Execute the statement
$stmt->execute();
//TODO 5: bind results into $messageid, $subject
$stmt->bind_result($itemid, $itemname, $itempicture, $description, $price);
echo "<table border='1'>";
echo "<tr><td><b>Subject</b></td><td><b>Actions</b></td></tr>";
// Use while loop to fetch messages and put in a <table>
while ($stmt->fetch()) {
echo "<tr>";
//TODO 6: In 1st <td>, display subject
echo "Sliim-fit.jpg";
echo "<a href='menschoice.php?productid==$itemid'>";
//TODO 7: In 2nd <td>, display View hyperlink with messageid in query string.
//The View hyperlink links to messagedetails.php
echo "<td> <a href='messagedetails.php?messageid=$messageid'> View </a></td>";
echo "</tr>";
}
echo "</table>";
//TODO 8: close the statement
$stmt->close();
//TODO 9: close $mysqli
$mysqli->close();
?>
I don't know why it keeps throwing me back the undefined index. Help me out senpais thanks.