Jump to content

how to pass single value to the script


Baabu

Recommended Posts

here is the code

<form action="update.php" method="get">
<?php

	while($row=mysql_fetch_array($result))
	{
		echo "<br>";

?>

<input type="text" name="qty" size="2">

<input type="hidden" name="model" value="<?php echo $row["model"];?>">
<input type="hidden" name="type" value="<?php echo $row["type"];?>">
<input type="submit" value="update">


<?php		

echo "<br>";
echo $row["type"];
echo "<br>";
echo $row["model"];
echo "<br>";
echo $row["price"];

?>


can anyone tell me that how should i arrange this <input> tag that only the value which needs to be updated it should be passed to the next script? as this code is working but when i click update rest of the other types are also passed to the script update.php which is not required so how should i do that only the pressed value is passed only

 

this is what happens

http://localhost/mobile/update.php?qty=&model=2100&type=Nokia&qty=2&model=1100&type=Nokia

i want it to be passed as

http://localhost/mobile/update.php?qty=2&model=1100&type=Nokia

 

Link to comment
Share on other sites

Well if some one wants to change the quantity it will be in this box

<input type="text" name="qty" size="2">

and then he presses the update button the values of model and type must be sent in order to update the quantity of the selected model and type

 

Link to comment
Share on other sites

this isn't perfect but it will work

<?php
echo "<form method=\"get\" action=\"".$_SEVER['PHP_SELF']."\">";
foreach($_GET as $key => $value){
echo "<input type=\"hidden\" name=\"".$key."\" value=\"".$value."\" />\n";
}
$i = 1;
$max = 50;
echo "<select name=\"qty\">";
while($i <= $max){
echo "<option value=\"".$i."\">".$i."</option>\n";
$i++;
}

echo "<input type=\"submit\" value=\"update\"></form>";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.