You are here: Re: Selection menu help needed « All PHP « IT news, forums, messages
Re: Selection menu help needed

Posted by J.O. Aho on 05/20/07 07:51

steve wrote:
> Hi Guys,
>
>
> I have a selection menu that is generated via php and a backend database.
> the code is working.
>
>
> What I want to do is take a selection from the menu then select a table of
> results based on that key.
>
> I have the code to select & build the table, but i am having problems tieing
> the selection box to trigger the table update.
>
>
> Javascript is out , incase it is disabled, I have no Ajax , all i have is
> PHP.

Then you have only two options, reload the whole page or use frames, which is
better, that you should ask at alt.html or do as you feel is easiest.


Assuming we use one page (no frames), you need to give arguments to the links
in your menu

<a href="this.page?varibletobesent=1">The menu element 1</a>
<a href="this.page?varibletobesent=2">The menu element 2</a>
<a href="this.page?varibletobesent=3">The menu element 3</a>

In the page you need to take care of the value sent, IMHO it's easiest to do
that in a switch-case:

<?PHP
// place this where the table is supposed to be
$drawtable=true;
switch($_GET['varibletobesent']) {
case 1:
$query="SELECT * FROM Table1";
break;
case 2:
$query="SELECT * FROM Table2";
break;
case 3:
$query="SELECT * FROM Table3";
break;
default:
$drawtable=false;
break;
}

if($drawtable) {

//Do what you need to draw the table
} else {
if(isset($_GET['varibletobesent'])) {
//give some nice error message
}
// draw the page section as it should be without the table
}
?>

Of course you may need to do all the table drawing in the switch case if you
can't make a general drawing function for all tables.

If you need to send more than one variable, then the anchor-tag could look
something like:

<a href="this.page?varibletobesent=1&amp;nextpage=<? $nextpage?>">The menu
element 1</a>

the '&amp;' is what you put between the variables to be sent (it's just the &
character, but using the plain '&' will generate invalid code at w3c.


--

//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация