Cara Mendapatkan Record Sebelum dan Sesudahnya (PHP MySQL)

Berikut adalah contoh sederhana bagaimana mendapatkan record sebelum dan sesudah. Meskipun sederhana namun ini adalah cara efektif untuk mendapatkan record sebelum dan sesudah pada database mysql kamu.

Next Record
$idd = 10; // supposed this is the current/selected record
$qry2 = mysql_query(“select * from product where product_id > $idd order by product_id asc”);
$rr = mysql_fetch_array($qry2);
$nxt= $rr['product_id'];


Previous record
$idd = 10; // supposed that this is the current/selected record
$qry2 = mysql_query(“select * from product where product_id < $idd order by product_id desc”);
$rr = mysql_fetch_array($qry2);
$prv= $rr['product_id'];
Sumber: http://www.joxtechnology.com/

0 Comments

Post a Comment