Monkuar Posted July 1, 2009 Share Posted July 1, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/164365-solved-variable/ Share on other sites More sharing options...
Adam Posted July 1, 2009 Share Posted July 1, 2009 Put this just before your query call: $asc = (isset($_GET['orderbyASC'])) ? 'ASC' : 'DESC'; Edit: Whoops, corrected a mistake! Quote Link to comment https://forums.phpfreaks.com/topic/164365-solved-variable/#findComment-867050 Share on other sites More sharing options...
trq Posted July 1, 2009 Share Posted July 1, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164365-solved-variable/#findComment-867051 Share on other sites More sharing options...
Monkuar Posted July 1, 2009 Author Share Posted July 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/164365-solved-variable/#findComment-867053 Share on other sites More sharing options...
Monkuar Posted July 1, 2009 Author Share Posted July 1, 2009 Ok so $asc = (isset($_GET['orderbyASC'])) ? 'ASC' : 'DESC'; So now i got index.php?act=mlogs&orderbyASC and i go there and it switches between ASC AND DESC for value ? Quote Link to comment https://forums.phpfreaks.com/topic/164365-solved-variable/#findComment-867054 Share on other sites More sharing options...
Adam Posted July 1, 2009 Share Posted July 1, 2009 If you supply "orderbyASC" it will order the results in ascending order, if you don't, descending. Quote Link to comment https://forums.phpfreaks.com/topic/164365-solved-variable/#findComment-867055 Share on other sites More sharing options...
Monkuar Posted July 1, 2009 Author Share Posted July 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/164365-solved-variable/#findComment-867056 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.