help with modifying data script..thanks in advance

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gilbertwang
Forum Commoner
Posts: 32
Joined: Sun Jun 30, 2002 11:08 pm
Location: Calgary

help with modifying data script..thanks in advance

Post by gilbertwang »

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;
}


?>
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

In the second file:

Code: Select all

<input type="text" name="whatever" value="<?php echo $_GET&#1111;'proname']; ?>">
If you're talking about what I think, that should take care of it.
gilbertwang
Forum Commoner
Posts: 32
Joined: Sun Jun 30, 2002 11:08 pm
Location: Calgary

Post by gilbertwang »

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;
}


?>
User avatar
phpcoder
Forum Contributor
Posts: 158
Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK

Post by phpcoder »

Instead of using

Code: Select all

<input type="text" name="whatever" value="<?php echo $_GET&#1111;'proname']; ?>">
use

Code: Select all

<input type="text" name="whatever" value="<?php echo $_POST&#1111;'proname']; ?>">
Post Reply