Jump to content

[SOLVED] &Variable?


Monkuar

Recommended Posts

Ok this is what I want to do,

 

I have a link..

 

index.php?act=mlogs

 

I want to beable to do

 

index.php?act=mlogs&orderbyASC

 

And, so then when people click on that link my MYSQL Below updates to ORDER BY ASC

 

$DB->query("SELECT * FROM ibf_logs WHERE receiver_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' or sender_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' order by id $asc");
    

 

I made $asc a Variable but how do I read it from people going to &orderbyASC at the end of my URL?

 

Thanks!

 

So.. if people click on my link that has the &orderbyASC at the end, the &orderbyASC will update my Variable called $asc to ASC so it fits in Query!!

 

Possible?

Link to comment
Share on other sites

Probably better making the link index.php?act=mlogs&orderby=asc, then simply grab the $_GET['orderby'] variable.

 

Of course, you'll want to clean and validate it before using it within any query though.

Link to comment
Share on other sites

Put this just before your query call:

 

$asc = (isset($_GET['orderbyASC'])) ? 'ASC' : 'DESC';

 

Edit: Whoops, corrected a mistake!

 

it gives me parse errorr..

 

syntax error, unexpected ':' in /home3/gxforums/public_html/24-7GT.com/forums/sources/shop/logs.php on line 55

 

and that'st the line lol

Link to comment
Share on other sites

If you supply "orderbyASC" it will order the results in ascending order, if you don't, descending.

 

Thanks alot, i cant wait ima do this with a whole bunch of variables! PHP is awesome.. epic win mayne Thanks bro!! TOPIC solved <33333

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.