Jump to content

Post Query into Form


cassy01

Recommended Posts

Hi There,

 

i am trying to get the following query into a form;

$query = "SELECT * FROM products WHERE itemID = '$_POST[itemID]'";

 

i am then trying to put each field in that row into a form so the user can edit it and submit it back to the database, i have tried the following;

 

$result=mysql_query($query);

$row = mysql_fetch_array($result)

$itemID =  $result['itemID']

$itemName =  $result['itemName']

 

<input name="itemID" type="text" id="itemID" value="$itemID" />

 

please help

Link to comment
https://forums.phpfreaks.com/topic/93994-post-query-into-form/
Share on other sites

right ive got the correct code at the top;

 

<?php $query = "SELECT * FROM products WHERE itemID = '$_POST[itemID]'";

$result=mysql_query($query);

$row = mysql_fetch_array($result);

?>

 

now how can i get the row of data to be entered as values to the form? i have at the moment;

 

<input name="itemName" type="text" id="itemName" value="<?php $row['itemName'];?>" />

Link to comment
https://forums.phpfreaks.com/topic/93994-post-query-into-form/#findComment-481562
Share on other sites

thats what ive already got :S

 

i can get the data from the database using the above query but cannot get each field to be inserted into the form.

 

Look good at how I posted the code in the query at the end with different quotes. Makes a difference. If that does not work, try:

<?php
$query = "SELECT * FROM products WHERE itemID = ".$_POST['itemID'];

?>

Link to comment
https://forums.phpfreaks.com/topic/93994-post-query-into-form/#findComment-481566
Share on other sites

changed code to:

 

$query = "SELECT * FROM products WHERE itemID = ".$_POST['itemID'];

$result=mysql_query($query);

$row = mysql_fetch_array($result);

 

Now trying to put that row of data into a form as values;

 

<input name="itemName" type="text" id="itemName" value="<?php $row['itemName'];?>"  />

Link to comment
https://forums.phpfreaks.com/topic/93994-post-query-into-form/#findComment-481572
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.