This is just wrong unless I am really missing something.
You select recipeid from the table but then you are trying to echo out variables before you have them. You are treating the href as if it is an include.
while($row = mysqli_fetch_array($result))
{
// Here you pull in the ID field.
$id = $row['RecipeID'];
echo "<tr>";
echo "<td>" . $row['RecipeID'] . "</td>";
//Everything is fine till here.
// You attempt to build your href but it isnt going to work because
// you attempt to echo out title when you don't have the title yet.
echo "<td> <a href='viewmore.php?id=$id'>" . $row['Title'] . "</a> </td>";
// Then you attempt to echo out the other fields when, again, you don't have them yet.
echo "<td>" . $row['Ingredients'] . "</td>";
echo "<td>" . $row['Method'] . "</td>";
echo "<td>" . $row['Keywords'] . "</td>";
echo "</tr>";
}
echo "</table>";
.................................................. ......................
Try something like this instead:
$result = mysqli_query($con,"SELECT RecipeID, Title FROM Recipes WHERE id = $id");
echo "<table width=100%>
<tr>
<th>ID</th>
<th>Title</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
$id = $row['RecipeID'];
echo "<tr>";
echo "<td>" . $row['RecipeID'] . "</td>";
echo "<td> <a href='viewmore.php?id=$id'>" . $row['Title'] . "</a> </td>";
echo "</tr>";
}
echo "</table>";
Then, in viewmore, as k0nr4d said, you need to establish a connection.
Not sure I caught all of it but that is the way I see it, like I said, unless I missed something somewhere.
.
|