Ad

Php Mysql Content Load Like Facebook

- 1 answer

I wan to load data from mysql with PHP like Facebook (load data by scrolling down). I checked in many tutorial where everyone is doing by order by ID but I can't do so while my fetching query is like follows.

mysql_query("SELECT * FROM conferencecreate WHERE ccFlag = 1 AND ccStartingDate >= '$nowTime' GROUP BY ccTitle");

If I want to implement ORDER BY ccId DESC then its not working. Any Idea how to solve this issue?

I tried this :-

mysql_query("SELECT * FROM conferencecreate 
             WHERE ccFlag = 1 
               AND ccStartingDate >= '$nowTime' 
             GROUP BY ccTitle 
             ORDER BY ccId DESC"); 

But this produced the error

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

Ad

Answer

You really should not be using the mysql_ database extension any more but that said you need to learn how to process errors generated by any of the the mysql extensions

So try this

$res = mysql_query("SELECT * FROM conferencecreate 
                   WHERE ccFlag = 1 
                     AND ccStartingDate >= '$nowTime' 
                   GROUP BY ccTitle 
                   ORDER BY ccId DESC"); 

if ( ! $res ) {
    echo mysql_error();
    exit;
}

Now you should see an error message describing what is wrong with the query you have coded.

Please dont use the mysql_ database extensions, it is deprecated (gone for ever in PHP7) Especially if you are just learning PHP, spend your energies learning the PDO or mysqli_ database extensions, and here is some help to decide which to use

Ad
source: stackoverflow.com
Ad