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
https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/
Share on other sites

Can't be done as it is a field in the form. You best bet is if possible, not even use GET but use POST instead which hides the whole query string from the url so it would look like this:

 

http://localhost/mobile/update.php

 

Other than that if it is on the form, it will be passed in the query string.

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

 

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>";
?>

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.