I am retrieving data from mysql to a drop down box. The drop down box is populated but how can I select the item and then click the submit button and populated in the text fields in another page in order to modify it. There is two pages, one is update.php which gets the data to a drop down box with a submit button.
The other updatedata.php with text fields populated with data select from the previous drop down box with a update button.
-----------------------------------------------------------------
update.php code below
------------------------------------------------------------------
$query = "select proname from products order by proname";
$result = mysql_query($query) or die(mysql_error());
//create form containing selection list
print "<form action='updatedata.php' method='get'> \n";
print "<select name='proname' size='6'> \n";
while(list($row)=mysql_fetch_array($result))
{
print "<option value='$row'>$row</option> \n";
}
print "</Select> \n";
print "<input type='submit' value='Select product to modify'> </form> \n";// Submit Button
-----------------------------------------------------------------------
updatadata.php code is below
----------------------------------------------------------------------
$query=" SELECT * FROM products WHERE productid='$productid'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$proname=mysql_result($result,$i,"proname");
$price=mysql_result($result,$i,"price");
$prolink=mysql_result($result,$i,"prolink");
$prodate=mysql_result($result,$i,"prodate");
<form action="updated.php" method="post">
<input type="hidden" name="ud_id" value="<? echo "$productid"; ?>">
Product Name: <input type="text" value="ud_first" value="<? echo "$proname"?>"><br>
Price: <input type="text" value="ud_phone" value="<? echo "$price"?>"><br>
Product Link: <input type="text" value="ud_mobile" value="<? echo "$prolink"?>"><br>
Date: <input type="text" value="ud_fax" value="<? echo "$prodate"?>"><br>
<input type="Submit" value="Update">
</form>
++$i;
}
?>
help with modifying data script..thanks in advance
Moderator: General Moderators
-
gilbertwang
- Forum Commoner
- Posts: 32
- Joined: Sun Jun 30, 2002 11:08 pm
- Location: Calgary
In the second file:
If you're talking about what I think, that should take care of it.
Code: Select all
<input type="text" name="whatever" value="<?php echo $_GETї'proname']; ?>">-
gilbertwang
- Forum Commoner
- Posts: 32
- Joined: Sun Jun 30, 2002 11:08 pm
- Location: Calgary
I am trying to pull the name from the previous page and display the fields of that select name.
I have follow your code to change like this:
but I get an error "Parse error: parse error in /home/atlentis/www/www/updatedata.php on line 84
"
I still can't find what's wrong, please help!!!
the page is now:
<?php
$connection = mysql_connect("localhost","atlentis","12345");
$db = mysql_select_db("atlentis");
//$proname = $_REQUEST['proname'];
print "$proname";
$query=" SELECT * FROM products WHERE proname='$proname'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$proname=mysql_result($result,$i,"proname");
$price=mysql_result($result,$i,"price");
$prolink=mysql_result($result,$i,"prolink");
$prodate=mysql_result($result,$i,"prodate");
<form action="updated.php" method="post">
<input type="text" name="whatever" value="<?php echo $_GET['proname']; ?>">
//<input type="hidden" name="ud_id" value="<? echo "$productid"; ?>">
Product Name: <input type="text" value="ud_first" value="<? echo "$proname"?>"><br>
Price: <input type="text" value="ud_phone" value="<? echo "$price"?>"><br>
Product Link: <input type="text" value="ud_mobile" value="<? echo "$prolink"?>"><br>
Date: <input type="text" value="ud_fax" value="<? echo "$prodate"?>"><br>
<input type="Submit" value="Update">
</form>
++$i;
}
?>
I have follow your code to change like this:
but I get an error "Parse error: parse error in /home/atlentis/www/www/updatedata.php on line 84
"
I still can't find what's wrong, please help!!!
the page is now:
<?php
$connection = mysql_connect("localhost","atlentis","12345");
$db = mysql_select_db("atlentis");
//$proname = $_REQUEST['proname'];
print "$proname";
$query=" SELECT * FROM products WHERE proname='$proname'";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$proname=mysql_result($result,$i,"proname");
$price=mysql_result($result,$i,"price");
$prolink=mysql_result($result,$i,"prolink");
$prodate=mysql_result($result,$i,"prodate");
<form action="updated.php" method="post">
<input type="text" name="whatever" value="<?php echo $_GET['proname']; ?>">
//<input type="hidden" name="ud_id" value="<? echo "$productid"; ?>">
Product Name: <input type="text" value="ud_first" value="<? echo "$proname"?>"><br>
Price: <input type="text" value="ud_phone" value="<? echo "$price"?>"><br>
Product Link: <input type="text" value="ud_mobile" value="<? echo "$prolink"?>"><br>
Date: <input type="text" value="ud_fax" value="<? echo "$prodate"?>"><br>
<input type="Submit" value="Update">
</form>
++$i;
}
?>
Instead of using
use
Code: Select all
<input type="text" name="whatever" value="<?php echo $_GETї'proname']; ?>">Code: Select all
<input type="text" name="whatever" value="<?php echo $_POSTї'proname']; ?>">