|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Will this code get the user selected var and make it available to another php page?
Im trying to get this list to post the variable "id" so that my popflag3.php page can insert the var into sql query string. Will this code post the var? pls let me know what i should use if i dont want to use sessions or cookies.
<form name="country" method="post" action="popflag3.php"> <p align="left"><font color="#FF0000" face="Arial, Helvetica, sans-serif"> </font></p> <p align="left"><font color="#FF0000" face="Arial, Helvetica, sans-serif"> <SELECT NAME="id" SIZE="1" class="ddlist"> <option value="1">Australia</option> <option value="3">Austria</option> <option value="2">Algeria </option> <option value="4">Antigua </option> <option value="5">Barbados</option> <option value="6">China</option> <option value="7">Denmark</option> <option value="8">England</option> <option value="9">Finland</option> <option value="10">Ghana</option> <option value="11">India</option> <option value="12">Jamaica</option> </select> <?php $HTTP_POST_VARS[$id]); ?> </form> ------------------------------------------------------------------------- The other page, popflag3.php looks like this <? $username = "username"; $password = "password"; $hostname = "db.synth.com"; $db_connect = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $db_select = mysql_select_db("flags", $db_connect)or die("Unable to select flags"); $query= "SELECT * FROM data WHERE id = $HTTP_POST_VARS['$id']" ; $result = mysql_query("SELECT * FROM data WHERE id = $HTTP_POST_VARS['$id']") or die(mysql_error()); while($row = mysql_fetch_array($result)){ $country=$row['country']; $flaglink=$row['flaglink']; $mobrate=$row['mobrate']; $landrate=$row['landrate']; echo "<tr> <td> $country </td> <td> $mobrate </td> <td> $landrate </td> <td> <img src=\"$link\"> </td> </tr>"; } ?> The query works fine with a static value such as if i hardcode id=1 in the query. If i try to insert the variable $id from the user selected value in the previous page using SELECT * FROM data WHERE id = $HTTP_POST_VARS['$id']" ; i get nothing...no errors but no results either. What am i doing wrong?? Thanks for your help surfie35 |
|
#2
|
||||
|
||||
|
In the first page, rather than just printing out the id, you need to print it out as the value for a hidden field named id.
|
|
#3
|
|||
|
|||
|
Quote:
Just add a hidden field called id and set the value of that field to $id? pls can i ave the exact code to do that? thanks |
|
#4
|
|||
|
|||
|
i tried this...but i cant get the var id to print on the next page
<input name="id" type="hidden" value="$id"> not working ![]() |
|
#5
|
||||
|
||||
|
Code:
<input type="hidden" name="id" value="<?php echo $_POST["id"]; ?>"> |
|
#6
|
|||
|
|||
|
thanks a whole bunch
will $query= ("SELECT * FROM data WHERE id= '$id'") substitute the variable value in the query?? i think my query looks ok, pls advise, and thank u again for ur prompt replies.. kris |
|
#7
|
|||
|
|||
|
im using this line to get the var value
$id= $_GET['$id']; the using in the query... $query= ("SELECT * FROM data WHERE id= '$id'") ; have i got all the quotes and brackets corrct, many thanks |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Will this code get the user selected var and make it available to another php page? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|