LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-27-2006, 03:21 PM   #1
tangle
Senior Member
 
Registered: Apr 2002
Location: Smithville, TN
Distribution: Slackware
Posts: 1,745

Rep: Reputation: 71
Dynamically select data from MySQL tables


I wrote a webpage in PHP that allows a user to select a customer from a drop down list that queries a MySQL table. It works fine, but the list of customers has groan and it is a pain to scroll through the list.

I would like to make it so when the user starts to type the name of the customers, the selection in the drop down box narrows. So if Mi is typed, names that start with Mi are the only ones dispalyed.

Can someone direct me to an artical or how to on how to do this? I searched the web and didn't find anything. May be my terminology is not right. Thanks
 
Old 02-27-2006, 04:58 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,063

Rep: Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761
It already exists in IE and firefox. Typing mi as in your example will jump down the list but not narrow the selection. I am not sure about other browsers. Since PHP is server based so I do not think it possible.

Last edited by michaelk; 02-27-2006 at 05:22 PM.
 
Old 02-27-2006, 11:29 PM   #3
tangle
Senior Member
 
Registered: Apr 2002
Location: Smithville, TN
Distribution: Slackware
Posts: 1,745

Original Poster
Rep: Reputation: 71
It must be my script. I can hit the first letter and it will drop down, but will not go any further. It will only recognize the first letter.

My code looks like this:
Code:
  echo "<tr><td width='25%'>";
  echo "<font size=4>Customer Name: </font></td>";
  echo "<td align='left'>";
  $query = "SELECT CustName FROM CustName";
  $result = mysql_query($query);
  if(mysql_num_rows($result)) 
    {
      echo "<select name=cname>";
      while($row = mysql_fetch_row($result))
        {
          print("<option value=\"$row[0]\">$row[0]</option>");
          echo "<br>";
        }
    }
  else 
    {
      print("<option value=\"\">No users created yet</option>");
    }
  echo "</td></tr>";
It will show all data in the CustName in a drop down list. I can not type in any characters. I guess I'll look around on dynamic drop down lists. Thanks
 
Old 02-28-2006, 02:04 AM   #4
airswit
Member
 
Registered: Dec 2005
Distribution: Fedora 4
Posts: 89

Rep: Reputation: 15
i think you are going to want to look into javascript for this. you can create the javascript array with php, then with the onchange event of the input, you can alter the showing list of options. could be a pretty neat little feature.

ps, it is grown, not groan ;-)
 
Old 02-28-2006, 08:11 AM   #5
tangle
Senior Member
 
Registered: Apr 2002
Location: Smithville, TN
Distribution: Slackware
Posts: 1,745

Original Poster
Rep: Reputation: 71
Thanks for the info. I'll start looking a java scripts today.

Quote:
Originally Posted by airswit
ps, it is grown, not groan ;-)
Didn't see that. That is what I get for typing things in a hurry. That is why I always went over my college papers 5 or 6 times. lol
 
Old 02-28-2006, 05:01 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 12,063

Rep: Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761Reputation: 761
I retract my statement Firefox does but IE does not. java is what you want.
 
Old 02-28-2006, 06:48 PM   #7
tangle
Senior Member
 
Registered: Apr 2002
Location: Smithville, TN
Distribution: Slackware
Posts: 1,745

Original Poster
Rep: Reputation: 71
I am going to buy a Java Script book this weekend. Thanks for the replies.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql reinstallation distorted by previous tables in /var/mysql mad4linux Linux - Software 0 10-04-2005 02:39 PM
select on simple data type? Thinking Programming 1 08-20-2005 08:56 PM
Changing a table contents dynamically based on select box rose_bud4201 Programming 4 01-13-2005 11:48 AM
SELECT data from Table Gerardoj Programming 2 04-17-2004 12:50 AM
mysql tables noord28 Linux - Newbie 0 02-20-2003 03:56 AM


All times are GMT -5. The time now is 07:11 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration