View Single Post
Old 05-30-2022, 12:25 AM  
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,129
CRUD edit display issue

So here is my problem:



The code I'm using for that form is as follows:

Quote:
<h1 style="text-align: center;">Edit Recipe.</h1><p>

<?php
// include database connection file
include_once("config.php");

// Check if submitted then redirect to crud home after update
if(isset($_POST['update']))
{
$RecipeID = $_POST['RecipeID'];
$Title=$_POST['Title'];
$Ingredients=$_POST['Ingredients'];
$Method=$_POST['Method'];
$Category=$_POST['Category'];

// update recipe data
$result = mysqli_query($mysqli, "UPDATE DatabaseName SET Title='$Title',Ingredients='$Ingredients',Method=' $Method',Category='$Category' WHERE RecipeID=$RecipeID");

// Redirect to homepage to display updated recipe in list
header("Location: blah/blah/blah/domain.com/crud/index.php");
}
?>
<?php
// Display selected recipe data based on RecipeID
// Getting id from url
$RecipeID = $_GET['RecipeID'];

// Fetch recipe data based on RecipeID
$result = mysqli_query($mysqli, "SELECT * FROM DatabaseName WHERE RecipeID=$RecipeID");

while($recipe_data = mysqli_fetch_array($result))
{
$Title=$recipe_data['Title'];
$Ingredients=$recipe_data['Ingredients'];
$Method=$recipe_data['Method'];
$Category=$recipe_data['Category'];
}

?>

<form name="update_recipe" method="post" action="edit.php">
<table border="0">
<tr>
<td>Title</td>
<td><input type="text" name="Title" value=<?php echo $Title;?>></td>
</tr>
<tr>
<td>Ingredients</td>
<td><input type="text" name="Ingredients" value=<?php echo $Ingredients;?>></td>
</tr>
<tr>
<td>Method</td>
<td><input type="text" name="Method" value=<?php echo $Method;?>></td>
</tr>
<tr>
<td>Category</td>
<td><input type="text" name="Category" value=<?php echo $Category;?>></td>
</tr>
<tr>
<td><input type="hidden" name="RecipeID" value=<?php echo $_GET['RecipeID'];?>></td>
<td><input type="submit" name="update" value="Update"></td>
</tr>
</table>
</form>
The specific entry in the MySQL row is as follows:



I'm assuming it has something to do with the database row, although I'm not sure why the first area for 'title' isn't displaying the full entry as there is no HTML markup in that column?

Any pointers or help from those of you 'in the know' please? This is actually the first time I'm trying to use CRUD on this system, I have a similar system setup for a domain management setup but that just uses 2/3 words in each column and it works fine (I copied across the edit.php exactly and just changed out the column names on this).

At this point I'm honestly at a loss as to why it isnt working, I've also tried using the <textarea> instead of text input to display the data and that didn't work either
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote