Re:Sql select based on a url parameter (1 viewing) (1) Guests
Sql select based on a url parameter
by jahflasher 11 Months, 3 Weeks ago
I know it can be done easily using php but i thought it would be a smaller _script_ to do a select using sql _base_d on a url parameter that is passed to it. The sql would have to do if , esle check thingie then select from a specifiec field _base_d on the result of the url parameter. is this posssible?
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:Sql select based on a url parameter
by cyberpunk 11 Months, 3 Weeks ago
yeh you can do it with if else statements but if there's alot of them things will get messy make use of the switch case logical operators.


if you mean you wanna do a query _base_d on a user selection on the previous page via a parameter set in the href element of the achor tag then yes its possible

example

Code: :

  <a href="deletemessage.php?method=shift_delete">hard delete</a> <a href="deletemessage.php?method="trash_delete">soft delete</a> <a href="deletemessage.php?method="archive">Move to archive</a>



say your in your message inbox and you wanna give 3 options for handing the messages for removal from inbox. on the processing page for this you'ld have your _script_ checking the method parametor of the url via the get array.

Code: :

 $_GET['method']; so you could use switch $parameter $_GET['method']; switch($parameter){    case 'shift_delete':                  do your delete query;          break;    case 'soft_delete':                  do your soft delete query;          break;    case 'archive':                  do your archive query;          break;     defualt:                 "go back and try that again"           break; } // end of switch



Good luck. if this is not what you meant please clarify
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:Sql select based on a url parameter
by jahflasher 11 Months, 3 Weeks ago
Thanks a million. i ended up doing some thing like this because as you said things can get messy using the if else in sql. Thanks a million for your help.
The administrator has disabled public write access. | Report to moderator   Logged Logged  
 
     
Powered by FireBoardget the latest posts directly to your desktop