php - Which is the query i should do so that i could fetch the previous from last row? -
i want read last 3 rows of table seperate , place them in 3 different div's of slider. problem cant use 'where id=xxx' because insert rows dynamically every time make post item.
if use query('select * news order id desc limit 3') , loop while ($result->fetch_assoc()) have last 3 rows.
my problem want place every row in different div have 3 divs. suppose must 3 different queries dont know how.
i have 1 right now.
$result = $mydb->query('select * news order id desc'); while ($ni = $result->fetch_assoc()) { $title = $ni['title']; $date = $ni['date']; $author = $ni['author']; $mainobjective = $ni['mainobjective']; $contents = $ni['contents']; $keywords = $ni['keywords'];
and have html use of echo place every variable in div want.
it sounds problem describing more php code, haven't posted, mysql. don't read them separately. use single query 3 , iterate through them separately php.
you can use query had:
$result = $mydb->query('select * news order id desc limit 0,3');
make sure placing results in separate containers in php:
foreach($result $row) { echo "<div>".$row."</div>"; }
Comments
Post a Comment