Baabu Posted February 28, 2008 Share Posted February 28, 2008 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 More sharing options...
cooldude832 Posted February 28, 2008 Share Posted February 28, 2008 why are u using a form to do this, you aren't updating anything at all. Explain your goals Link to comment https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/#findComment-479343 Share on other sites More sharing options...
premiso Posted February 28, 2008 Share Posted February 28, 2008 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. Link to comment https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/#findComment-479345 Share on other sites More sharing options...
Baabu Posted February 28, 2008 Author Share Posted February 28, 2008 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 https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/#findComment-479349 Share on other sites More sharing options...
Baabu Posted February 28, 2008 Author Share Posted February 28, 2008 but if i use post the how would i know that which model and which quantity the script should do the update ??? Link to comment https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/#findComment-479352 Share on other sites More sharing options...
premiso Posted February 28, 2008 Share Posted February 28, 2008 $_POST['model'] $_POST['qty'] But as stated above you have no visible code to do anything with the data. Link to comment https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/#findComment-479353 Share on other sites More sharing options...
cooldude832 Posted February 28, 2008 Share Posted February 28, 2008 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 https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/#findComment-479354 Share on other sites More sharing options...
Baabu Posted February 28, 2008 Author Share Posted February 28, 2008 well i just want the link to be only http://localhost/mobile/update.php?qty=*&model=***&type=*** currently i have no concerns with data that what it should do or not Link to comment https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/#findComment-479360 Share on other sites More sharing options...
Baabu Posted February 28, 2008 Author Share Posted February 28, 2008 messed up Link to comment https://forums.phpfreaks.com/topic/93544-how-to-pass-single-value-to-the-script/#findComment-479366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.