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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -