For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > November 2004 > Getting passed value for Switch









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Getting passed value for Switch
highway of diamonds

2004-11-30, 4:00 pm

At present I have webpage which is just a selection of 5 forms which
pass informaton to a .php files which update individual fields in a
database - i.e. price, details, type etc.

At present I'm using separate files for each form, which works well, but
I'm thinking about almalgamating them into one, which would be a more
elegant way of doing it.

I was going to use the switch function and then activate the required
code depending on which information was sent.

I can't figure out how to get the value of the sent information into the
switch variable.

Can anyone help?

TIA, Russ

pseudo code something like this:

<?php
$flag = value sent - could be $newdetail, $newprice etc..;

switch ($flag){
case $newprice:
action this code;
break;
case $newdetails:
action this code;
break;
etc...
}
?>


--
take out the trash to email
Hilarion

2004-11-30, 4:00 pm

You can use named "submit" inputs and decide what was submited by checking
which variable is set (coresponding to which button). You may also use
form names (when "submit" button is not named, and form is, then the browser
should send "submit" button value under the form name).

Hilarion


highway of diamonds

2004-11-30, 8:56 pm

Hilarion wrote:
> You can use named "submit" inputs and decide what was submited by checking
> which variable is set (coresponding to which button). You may also use
> form names (when "submit" button is not named, and form is, then the browser
> should send "submit" button value under the form name).
>
> Hilarion
>
>

Yep, obviously to close to it for too long... thanks,

coded as

switch (TRUE){
case $newprice:
action this code;
break;
case $newdetails:
action this code;
break;
etc...

works well!

R.
--
take out the trash to email
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com