WAP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreWAP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old June 11th, 2006, 05:26 PM
noxhanti noxhanti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 23 noxhanti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 19 m 48 sec
Reputation Power: 0
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>

Reply With Quote
  #2  
Old June 11th, 2006, 11:58 PM
vrspectre's Avatar
vrspectre vrspectre is offline
I see semi-colons
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Portland, OR
Posts: 297 vrspectre User rank is Sergeant (500 - 2000 Reputation Level)vrspectre User rank is Sergeant (500 - 2000 Reputation Level)vrspectre User rank is Sergeant (500 - 2000 Reputation Level)vrspectre User rank is Sergeant (500 - 2000 Reputation Level)vrspectre User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 10 h 38 m 59 sec
Reputation Power: 16
Send a message via AIM to vrspectre Send a message via Yahoo to vrspectre
Well to create the input form do this:

PHP Code:
echo( "<wml>\n" );

echo( 
"<head>\n" );
echo( 
"</head>\n" );

echo( 
"<card title='Login' id='login'>\n" );

echo( 
"<p>\n" );


echo( 
"<fieldset>\n" );

echo( 
"Name: \n" );
echo( 
"<input name='name' type='text' maxlength='10' size='10'/>\n" );
echo( 
"</fieldset>\n" );

echo( 
"<br/>\n" );


echo( 
"<anchor>\n" );
echo( 
"Login\n" );
echo( 
"<go href='postme.php' method='post'>\n" );
echo( 
"<postfield name='name' value='\$name'/>\n" );
echo( 
"</go>\n" );
echo( 
"</anchor>\n" );

echo( 
"<do type='accept' label='Login' name='Login'>\n" );
echo( 
"<go href='postme.php' method='post'>\n" );
echo( 
"<postfield name='min' value='\$min'/>\n" );
echo( 
"<postfield name='pin' value='\$pin'/>\n" );
echo( 
"</go>\n" );
echo( 
"</do>\n" );
echo( 
"\n" );

echo( 
"</p>\n" );
echo( 
"</card>\n" );
echo( 
"</wml>\n" ); 


then modify your sql query to:

"select repid, address, tel from tbl_user where name='$name'"

Reply With Quote
  #3  
Old June 12th, 2006, 04:11 AM
noxhanti noxhanti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 23 noxhanti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 19 m 48 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old June 12th, 2006, 04:34 AM
noxhanti noxhanti is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 23 noxhanti User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 19 m 48 sec
Reputation Power: 0
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.

Reply With Quote
  #5  
Old June 12th, 2006, 04:45 AM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Feb 2002
Location: Finland
Posts: 8,670 jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 10th Grade (Above 100000 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 3 Months 3 Weeks 4 Days 6 h 10 m 50 sec
Reputation Power: 1618
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29 Send a message via Google Talk to jabba_29 Send a message via Skype to jabba_29
Facebook
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.
Comments on this post
vrspectre agrees: Yes, make sure you validate any and all input that comes from the user.
andymoo agrees: Yup, validate all user input unless you want someone to break your site and plunder your database
__________________
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.

__________________

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreWAP Programming > Query mysql table - select value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway