Jump to content

Switch action


Charlie_paul

Recommended Posts

Hello everyone from a php newbie,

I have a option selections box and need to select an action depending on the results.

Its for an insert script for items into a Database and depending on the chosen option it add the picture to the DB table

The selection options are

 

<select name="extension" style="font-size:18px"><option value="pdf">PDF</option><option value="zip">ZIP</option><option value="powerpoint">PowerPoint</option></select>

 

the Swtich is

switch $_POST['extention']{
              case 'zip':
              echo $insert_image = $_POST['extension'].'winzip.gif';
              break;
              case 'powerpoint':
              echo $insert_image = $_POST['extension'].'ppt.gif';
              break;
              default:
              echo $insert_image = $_POST['extension'].'products/pdf.gif';
              }

 

Would someone please tell me if this is correct syntax?

Or have i got it horribly wrong!

 

Thank you for your a help

 

Charlie

Link to comment
Share on other sites

many people here are skilled at PHP. but no one has the ability to look at code, parse the code and run it in his/her head.

 

learning PHP involves making mistakes, fixing them, making more mistakes, fixing those mistakes, etc., ad infinitum. if you don't try anything, you will never learn.

Link to comment
Share on other sites

Hello,

I understand that, and i shall try it out later, have commented it out now, all i was asking really was whether the code looked ok as it was, i.e syntax was correct

i changed it now to an elseif statement that i know will work, just having a play with switch.

Thank you all for your help

Charlie

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.