p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > PHP/MySQL > PHP How-To
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 27th, 2009, 05:51 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Oct 2009
Location: Bulgaria
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to phobia1
Exclamation Mysql database to listbox need help

1.<html>
2. <head>
3. <title>List Box Form Data</title>
4. </head>
5. <body>

6. <p>Form data passed from the form</p>
7. <?php
8. require("./resources/globals.php") ;
9. $query="SELECT DISTINCT * FROM Garant GROUP BY Location";
10. $stmt= substr($query, 0, strlen($query)-4) ;

11.// Connect to the Database
12.$link=mysql_connect($location,$userName,$passwo rd) or die (mysql_error());
13.mysql_select_db($dbname) or die (mysql_error());
14.$result=mysql_query($query) or die (mysql_error());

15.// Select the Database
16.if (!mysql_select_db($dbname, $link)) {
17. DisplayErrMsg(sprintf("Error in selecting %s database", $dbname)) ;
18. DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error
19.($link))) ;
20. exit() ;
21.}

22.// Execute the Statement
23.if (!($result =mysql_query($query, $link))) {
24. DisplayErrMsg(sprintf("Error in executing %s stmt", $query)) ;
25. DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error
26.($link))) ;
27. exit() ;
28.}

29.echo"<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">';

30.echo '<select name="areasearch" onChange="submit();">';
31.while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
32.echo "<option value=$nt[Town]>$nt[Location]</option>";
33.}
34. echo"</select>";

35. echo" </form>";
36. echo $areasearch;

37. mysql_free_result($result) ;
38. ?>

39. </body>
40. </html>
The above code pulls the Location field records from database Garant. What I need to do is when a town is selected from the listbox, a new search thats finds all the places with that Location name. I can do the search stuff but how to get $areasearch valid?
Thanks for any help.
F
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
no mysql database included alongside test database... gaptain BOOK: Beginning MySQL 0 May 20th, 2009 01:17 PM
MySQL database neil.abachi07 MySQL 13 October 8th, 2007 03:23 PM
MySql Database Problem surongama JSP Basics 0 October 16th, 2006 09:01 AM
Listbox entry in Database acces 2003 BramuS Classic ASP Databases 15 June 14th, 2005 04:02 PM
Listbox being poplutaed with Access database. gisenberg VB.NET 2002/2003 Basics 5 July 23rd, 2004 09:20 PM



All times are GMT -4. The time now is 07:59 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc