|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
How are the urls for the links supposed to look? I'm not sure if I understand.
|
|
#3
|
||||
|
||||
|
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; |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
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:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Look For page depending option selected in list menu PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|