mysql - Get three element from database using mysql_fetch_array and php -
i've got in database example 7 columns 5 rows (id,title , date,text,img), want title , img last 3 colums , did this:
<?$queryt = "select * mainpage order id desc limit 1"; $resultt = mysql_query($queryt) or die(mysql_error()."[".$queryt."]"); $queryi = "select * mainpage order id desc limit 1"; $resulti = mysql_query($queryi) or die(mysql_error()."[".$queryi."]"); ?> <?while ($rowt = mysql_fetch_array($resultt, mysql_both)){ while ($rowi = mysql_fetch_array($resulti, mysql_both)){ ?> <ul class="bjqs"> <li><img src="<?php echo $rowi["img"]; ?>" title="<?php echo $rowt["title"]; ?>" class="sidernews"></li> <li><img src="<?php echo $rowi["img"]; ?>" title="<?php echo $rowt["title"]; ?>" class="sidernews"></li> <li><img src="<?php echo $rowi["img"]; ?>" title="<?php echo $rowt["title"]; ?>" class="sidernews"></li> </ul> <? } } ?>
but it's printing me , 3 times information last column only. use , print information in slider.
try this:
<?php $queryt = "select * mainpage order id desc limit 0,3"; $resultt = mysql_query($queryt) or die(mysql_error()."[".$queryt."]"); ?> <ul class="bjqs"> <?php while($rowt = mysql_fetch_array($resultt, mysql_both)) { ?> <li><img src="<?php echo $rowt["img"]; ?>" title="<?php echo $rowt["title"]; ?>" class="sidernews"></li> <?php } ?> </ul>
Comments
Post a Comment