PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 26th, 2003, 12:26 AM
nestorvaldez nestorvaldez is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 40 nestorvaldez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 21 sec
Reputation Power: 7
Look For page depending option selected in list menu PHP

function BuscaTipoJuego()
{
$sql = mysql_query("SELECT id, juego FROM tipojueg");
echo "<select name=\"juego\">";
while(list($id, $juego)=mysql_fetch_array($sql))
{
$juego= stripslashes($juego);
echo "<option value=\"$juego\"";
echo ">$juego</option>";
}
echo "</select>";
mysql_free_result($sql);
}
?>

I'm using this code to get value from my table, (only two values in the table) with a List/menu, but I need that when I select one it go to any page.
Example: in the table I only have two value 1=House, and 2=Depto, and i want If I select HOUSE it go to House Page, and If I select Depto it go to Depto Page.. I want it execute selecting the opcion in the list menu or selecting it and then clicking a submit butom, what ever, but I need it go to any page depending in the option selected..

NVM

Reply With Quote
  #2  
Old September 26th, 2003, 03:00 AM
avit avit is offline
Not Yet Perfect
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Squamish, BC
Posts: 111 avit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to avit
How are the urls for the links supposed to look? I'm not sure if I understand.

Reply With Quote
  #3  
Old September 26th, 2003, 07:44 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You'll need to add a URL column to your table. When building your select box, use the URL as the value and the juego as the display name. Then you'll need to add something like this to your <select> tag:

Code:

onchange=document.location.href=this.[this.selectedIndex].value;

Reply With Quote
  #4  
Old September 26th, 2003, 08:50 AM
nestorvaldez nestorvaldez is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 40 nestorvaldez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 21 sec
Reputation Power: 7
Look For page depending option selected in list menu PHP

function BuscaTipoJuego()
{
$sql = mysql_query("SELECT id, juego FROM tipojueg");
echo "<select name=\"juego\">";
while(list($id, $juego)=mysql_fetch_array($sql))
{
$juego= stripslashes($juego);
echo "<option value=\"$juego\"";
echo ">$juego</option>";
}
echo "</select>";
mysql_free_result($sql);
}
?>


onchange=document.location.href=this.[this.selectedIndex].value;
How I going to put this code.. Give me example with my script.. I'm confused...

I'm taking the value from a table, and I only use two records in the table(that's not matter, it must be more....) The only to records I use ares ID=1 Name=House
ID=2 Name=Depto
Only this two records with two fields : ID, and Name...
Ok.. In showing it pefectly in the Site with this script, but I need when I select one option of the List/menu it open a Page, but the page is depending the option I selected..
This means, If I have to records, I will have two differents pages, One for HOUSES and other for DEPTOS.. the Name of the pages are:
house.php
deptos.php

If I select House from list menu it open house.php
If I select Depto from list menu it open deptos.php

IN the Line code you give me, I can't understand How to specify the conditions within my script...

Help me with this. Please...

NVM

Reply With Quote
  #5  
Old September 26th, 2003, 09:15 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Try this. I'm just adding an onchange javascript event to the select box and telling the page to look at the selected value of the select box and jump to that page. This assumes that the page name will be the juego value plus ".php" and that the given file is in the current directory. Depending on your OS, this may be case-sensitive. Also, you can prepend a directory or full HTTP path to the filename if need be. I'm not sure the javascript will work as is, but this should get you moving in the right direction.

PHP Code:
function BuscaTipoJuego(){
    
$sql mysql_query("SELECT id, juego FROM tipojueg");
    echo 
"<select name=\"juego\" onchange=\"document.location.href=this[selectedIndex].value + '.php'\">";
        while(list(
$id,$juego)=mysql_fetch_array($sql)){
        
$juegostripslashes($juego);
        echo 
"<option value=\"$juego\"";
        echo 
">$juego</option>";
    }
    echo 
"</select>";
    
mysql_free_result($sql);
}
?> 

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Look For page depending option selected in list menu PHP


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
Stay green...Green IT