Charlie_paul Posted February 16, 2011 Share Posted February 16, 2011 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 https://forums.phpfreaks.com/topic/227915-switch-action/ Share on other sites More sharing options...
Pikachu2000 Posted February 16, 2011 Share Posted February 16, 2011 What happened when you tried it? Link to comment https://forums.phpfreaks.com/topic/227915-switch-action/#findComment-1175234 Share on other sites More sharing options...
Charlie_paul Posted February 16, 2011 Author Share Posted February 16, 2011 Hello and thank you for replying so fast i have not tried it out yet, i was just wondering if it looked like it might work lol To try it out will take me about an hour getting stuff ready maybe longer, does it look OK to you please Thank you Charlie x Link to comment https://forums.phpfreaks.com/topic/227915-switch-action/#findComment-1175237 Share on other sites More sharing options...
BlueSkyIS Posted February 16, 2011 Share Posted February 16, 2011 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 https://forums.phpfreaks.com/topic/227915-switch-action/#findComment-1175265 Share on other sites More sharing options...
Charlie_paul Posted February 16, 2011 Author Share Posted February 16, 2011 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 https://forums.phpfreaks.com/topic/227915-switch-action/#findComment-1175278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.