|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Query mysql table - select value
I want to be able to select an individual's details from a table by inputting their name into a form. The following is how I get all the details from the table but I am not sure how I would write the wml form and corresponding wml file to make any selections. does anyone know how.
Customertable.wml Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">
<wml>
<card id="card1" title="customer">
<p>
Customer Details.<br/>
<anchor>
<go method="get" href="postme.php">
</go>
Submit Data
</anchor>
</p>
</card>
</wml>
postme.php Code:
<?php
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
. " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
?>
<wml>
<card id="card1" title="Example">
<p>
<?php
//connect to database server
$connection = mysql_connect("localhost", "root", "password")
or die ("connection failed");
//Select the database
$db = mysql_select_db("db_wap", $connection)
or die ("failed to select database <br />\n");
//execute a query
$result = mysql_query("select repid, name, address, tel from tbl_user")
or die ("query failed <br />\n");
print "<b>Customer Database:</b> <br/>";
While ($myrow = mysql_fetch_array($result, MYSQL_ASSOC)):
echo($myrow ["repid"]);
echo("<br/>");
echo($myrow ["name"]);
echo("<br/>");
echo($myrow ["address"]);
echo("<br/>");
echo($myrow ["tel"]);
echo("<br/>");
endwhile;
?>
</p>
</card>
</wml>
|
|
#2
|
||||
|
||||
|
Well to create the input form do this:
PHP Code:
then modify your sql query to: "select repid, address, tel from tbl_user where name='$name'" |
|
#3
|
|||
|
|||
|
Thanks for the code. I entered the login page as follows and that page works fine,
Login.wml Code:
<?xml version="1.0"?> <!-- created by WAPtor (http://www.wapdrive.net/) --> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <!-- THIS IS THE FIRST CARD IN THE DECK --> <wml> <card title='Login' id='login'> <p> <fieldset> Name: <input name='name' type='text' maxlength='20' size='20'/> </fieldset> <br/> <anchor> Login <go href='postme2.php' method='post'> <postfield name='name' value='$name'/> </go> </anchor> <do type='accept' label='Login' name='Login'> <go href='postme2.php' method='post'> <postfield name='min' value='$min'/> <postfield name='pin' value='$pin'/> </go> </do> </p> </card> </wml> but the query didn't bring up any values at all . Usually I get a list of all the user that looks formatted like this: 1 John Smith 22 Mossten Terrace Louthborough 1231522363 etc. The name field in my mysql table is varchar with a max length of 30. I added the extra bit to the original postme.php script query with and without backslashes like this- Code:
$result = mysql_query("select repid, name, address, tel from tbl_user where name = '$name'")
have I done something wrong |
|
#4
|
|||
|
|||
|
It works. I just had to change the select query to:
Code:
$result = mysql_query("select repid, name, address, tel from tbl_user
where name = '$_POST[name]'")
thanks for your help. |
|
#5
|
||||
|
||||
|
As I stated in one of your previous posts, validate your input.
That or send me the url of your site and I will hack you ![]() The reason that it didn't work before is because your server obviously has registered globals switched off. This means you need to specify where the variable has come from, eg: $_POST, $_GET, $_COOKIE etc.... Glad you got it fixed in the end.
__________________
Cheers, Jamie # skiFFie | Home of the 'accessibility module' for Drupal # Jamie Burns [me] Accessibility Module [drupal] # guidelines | search | wap resources | not getting help | fold to cure # Any form of employment is strictly prohibited ...... __________________ Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. __________________ |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > WAP Programming > Query mysql table - select value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|