如何显示新更新的四张图像?

时间:2013-11-10 18:39:54

标签: php fetch

我的PHP代码是 -

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'moviefone';
$con = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $con);    // Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$data = mysql_query("SELECT * FROM new_hindi") or die(mysql_error());
$info=NULL;
while ($row = mysql_fetch_array($data))
  {
  $info=$row;    
  }
?>

和html是

<div id="main_column">    <div class="column-1">
<div class="sub-column1">
<a href="#" class="new_movies"><span>New</span></a>
  <a href="#"><img src="<?php echo $info["images"];?>" width="140" height="200" class="new-img" /></a>
  <a href="#" class="img_titles"><?php echo $info["title"];?></a>
  <a href="#" class="new_english"><span>New</span></a>
</div>
<div class="sub-column1"> 
  <a href="#"> <img src="#" width="140" height="200" class="new-img" /></a>
  <a href="#" class="img_titles">nothing</a>
  <a href="#" class="theater"><span>In THEATERS</span></a> 
   </div>
   <div class="sub-column1">
   <a href="#"><img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200" class="new-img" /></a>
   <a href="#" class="img_titles">Example8</a>
   <a href="#" class="upcoming"><span>Upcoming</span></a>
   </div>
   <div class="sub-column1"> 
   <a href="#"> <img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200"  class="new-img"/></a>
   <a href="#" class="img_titles">Example12</a>
    </div> 
  </div>
<div class="column-2">
<div class="sub-column1">
  <a href="#"><img src="<?php echo $info["images"];?>" width="140" height="200" class="new-img" /></a>
  <a href="#" class="img_titles"><?php echo $info["title"];?></a>
</div>
<div class="sub-column1"> 
  <a href="#"> <img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200" class="new-img" /></a>
  <a href="#" class="img_titles">Example5</a> 
   </div>
   <div class="sub-column1">
   <a href="#"><img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200" class="new-img" /></a>
   <a href="#" class="img_titles">Example9</a>
   </div>
   <div class="sub-column1"> 
   <a href="#"> <img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200"  class="new-img"/></a>
   <a href="#" class="img_titles">Example13</a>
    </div> 
</div>
<div class="column-3">
<div class="sub-column1">
  <a href="#"><img src="<?php echo $info["images"];?>" width="140" height="200" class="new-img" /></a>
  <a href="#" class="img_titles"><?php echo $info["title"];?></a>
</div>
<div class="sub-column1"> 
  <a href="#"> <img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200" class="new-img" /></a> 
  <a href="#" class="img_titles">Example6</a>
   </div>
   <div class="sub-column1">
   <a href="#"><img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200" class="new-img" /></a>
   <a href="#" class="img_titles">Example10</a>
   </div>
   <div class="sub-column1"> 
   <a href="#"> <img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200"  class="new-img"/></a>
   <a href="#" class="img_titles">Example14</a>
    </div> 
</div>
<div class="column-4">
<div class="sub-column1">
  <a href="#"><img src="<?php echo $info["images"];?>" width="140" height="200" class="new-img" /></a>
  <a href="#" class="img_titles"><?php echo $info["title"];?></a>
</div>
<div class="sub-column1"> 
  <a href="#"> <img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200" class="new-img" /></a>
  <a href="#" class="img_titles">Example7</a> 
   </div>
   <div class="sub-column1">
   <a href="#"><img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200" class="new-img" /></a>
   <a href="#" class="img_titles">Example11</a>
   </div>
   <div class="sub-column1"> 
   <a href="#"> <img src="images/packshot._UX140_CR0,0,140,200_V1349717863_Lovefilmgb169343_.jpg" width="140" height="200"  class="new-img"/></a>
   <a href="#" class="img_titles">Example15</a>
    </div> 
</div>
</div><!--main cloumn-->

只提取了一个新更新的图像。但是我想要在页面上提取并显示四个新更新的更新图像。我无法实现这一点。每一行都获取相同的图像。如何循环数据库的最新条目?

0 个答案:

没有答案