Jump to content

Is This a Proper Use of fetch_all () or Is There an Alternative?


Glese

Recommended Posts

if (isset($select_category) || isset($most_liked)) {
// ALL but NO OTHER
if (((($select_category == 'All') || (!isset($select_category)))) && (!isset($most_liked))) {

           
	$query	= "SELECT * FROM con, user WHERE con.user_id = user.user_id ORDER BY contribution_date DESC";

	fetch_all ($dbc, $query);


// CATEGORY but NOT most_liked	
} elseif (isset($select_category) && !isset($most_liked)) {

	$query = "SELECT * FROM con, user WHERE con.user_id = user.user_id AND category = '$select_category' ORDER BY contribution_date DESC";

	fetch_all ($dbc, $query);

// CATEGORY and MOST_LIKED
} elseif (($select_category != 'All') && (isset($select_category) && isset($most_liked))) {

	$query = "SELECT * FROM con, user WHERE con.user_id = user.user_id AND category = '$select_category' ORDER BY likes DESC";

	fetch_all ($dbc, $query); 

// ALL or NO CATEGORY but MOST LIKED 
} elseif ((($select_category == 'All') || (!isset($select_category))) && (isset($most_liked))) {

	$query = "SELECT * FROM con, user WHERE con.user_id = user.user_id ORDER BY likes DESC";
	fetch_all ($dbc, $query); 

} 

}

 

What I am basically trying to accomplish is, choose a category through a drop down list, select that category and then go through all the rows in the database and print the content out.

 

As of now it is working for me, I am also using a pagination script to print out everything in a table.

 

The problem I am having is that fetch_all function is also printing the query out together with the content. Any ideas why it does that?

 

Did I use this function the right way?

 

If you need more information let me know.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.