troubleshooting Question

SPLIT MYSQL OUTPUT TO SEVERAL PAGES...

Avatar of cgustaf
cgustaf asked on
PHPMySQL Server
53 Comments1 Solution472 ViewsLast Modified:
I have a query that outputs payments to more than one vendor.  It is attached.

The output looks as follows:

id: 1 BIBLE TRANSLATION IN THE TUVIN LANGUAGE. $1,333.00
id: 1 BIBLE TRANSLATION IN THE UZBEK LANGUAGE. $1,222.00
id: 2 GENERAL SUPPORT OF BIBLE TRANSLATION.$1,555.00

There are two different vendor IDs in the above example -- two items for id #1, and one item for item #2.  There could be more vendors.

I would like to paginate the output so that the payments for each different vendor is printed on a separate page -- in the above example, the first page will display the two items for vendor id1, and the second page the one item for vendor id2.  That is, the payments to the vendors are paginated on the vendor id.  (In the query, this id is called t_expend.expend_id.)

The database is in MySQL, and I wonder if this pagination can be done in SQL -- if so, how?  Or, should it be done some other way?
mysql_select_db($database_ibt_dbc, $ibt_dbc);
$query_rs1 = "SELECT t_desig.prefix_id, t_desig.lang_id, t_desig.postscr_id , CONCAT_WS(' ',t_prefix.prefix,t_lang.lang,t_postscr.postscr) designtn, t_desig.desig_id, t_recip.recip_id,t_recip.recipnt,t_expend.paid_date, t_expend.exp_ref,t_expend.exp_done, t_expend.expend_id, t_expend.exp_done2,t_expend.exp_amt FROM t_desig  LEFT JOIN t_lang      ON t_desig.lang_id = t_lang.lang_id   LEFT JOIN t_prefix      ON t_desig.prefix_id = t_prefix.prefix_id    LEFT JOIN t_postscr     ON t_desig.postscr_id = t_postscr.postscr_id  LEFT JOIN t_expend     ON t_desig.desig_id = t_expend.desig_id  LEFT JOIN t_recip     ON t_recip.recip_id = t_expend.recip_id WHERE t_desig.desig_id = t_expend.desig_id AND t_expend.recip_id = t_recip.recip_id AND t_expend.exp_done = 'Y' AND t_expend.paid_date = CURDATE() ORDER BY  t_expend.recip_id, t_desig.desig_id ASC";
$rs1 = mysql_query($query_rs1, $ibt_dbc) or die(mysql_error());
$row_rs1 = mysql_fetch_assoc($rs1);
$totalRows_rs1 = mysql_num_rows($rs1);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 53 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 53 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros