Multiple arrays after a while

I need help with the solution: I need to make a table with the value of 4 different of my sql arrays, for example:

$sql = mysql_query("select * from tbl_work where work_category = 1 
 ORDER BY note DESC");

$sql2 = mysql_query("select * from tbl_work where work_category = 2 
 ORDER BY note DESC");

$sql3 = mysql_query("select * from tbl_work where work_category = 3 
 ORDER BY note DESC");

$sql4 = mysql_query("select * from tbl_work where work_category = 4 
 ORDER BY note DESC");

      

And I am making four arrays with each one:

$find1 = mysql_fetch_array($sql);

$find2 = mysql_fetch_array($sql2);

$find3 = mysql_fetch_array($sql3);

$find4 = mysql_fetch_array($sql4);

      

Now I need to render 10 times, a table with the value of all these arrays, but need to have order, no repetition and side by side, separated by category.

Like the 4 columns, each has an order and a different meaning work_category

.

Thank!

+3


source to share


1 answer


Why not modify your query to get all the results at once:

SELECT * FROM tbl_work WHERE work_category IN (1,2,3,4) ORDER BY note DESC  

      



PS: Use PDO

is mysql_*

out of date.

+6


source







All Articles