techker Posted April 19, 2010 Share Posted April 19, 2010 Hey guys i have this pagination script that im using and i need to add a specific user to it.so it does not select every thing from the databse but only the user loggin. SELECT COUNT(*) as num FROM $tbl_name WHERE Date = (SELECT MAX( date ) FROM $tbl_name need to add `Dealer_ID`=$ID thx!! Quote Link to comment https://forums.phpfreaks.com/topic/199005-insert-id-in-query/ Share on other sites More sharing options...
taquitosensei Posted April 19, 2010 Share Posted April 19, 2010 If you had just thought about this for about 2 seconds longer you probably would have had it. SELECT COUNT(*) as num FROM $tbl_name WHERE Date = (SELECT MAX( date ) FROM $tbl_name where `Dealer_ID`=$ID but you'll want to escape the $tbl_name and $ID with mysql_real_escape_string Quote Link to comment https://forums.phpfreaks.com/topic/199005-insert-id-in-query/#findComment-1044564 Share on other sites More sharing options...
techker Posted April 19, 2010 Author Share Posted April 19, 2010 thx true...lol Quote Link to comment https://forums.phpfreaks.com/topic/199005-insert-id-in-query/#findComment-1044575 Share on other sites More sharing options...
techker Posted April 19, 2010 Author Share Posted April 19, 2010 funny cause now it says my fetch array is no good? $sql = "SELECT * FROM $tbl_name WHERE Date = (SELECT MAX( date ) FROM $tbl_name) WHERE Dealer_ID='$_SESSION[user_id]' LIMIT $start, $limit"; $result = mysql_query($sql); [/php Quote Link to comment https://forums.phpfreaks.com/topic/199005-insert-id-in-query/#findComment-1044584 Share on other sites More sharing options...
taquitosensei Posted April 19, 2010 Share Posted April 19, 2010 you've got too many where's use an AND instead of your second WHERE $sql = "SELECT * FROM $tbl_name WHERE Date = (SELECT MAX( date ) FROM $tbl_name) AND Dealer_ID='$_SESSION[user_id]' LIMIT $start, $limit"; $result = mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/199005-insert-id-in-query/#findComment-1044659 Share on other sites More sharing options...
techker Posted April 19, 2010 Author Share Posted April 19, 2010 oh ok..i will try it.thx! Quote Link to comment https://forums.phpfreaks.com/topic/199005-insert-id-in-query/#findComment-1044873 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.