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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 ??? Quote Link to comment 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. Quote Link to comment 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>"; ?> Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Baabu Posted February 28, 2008 Author Share Posted February 28, 2008 messed up Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.