0

私の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-->

新しく更新された画像を 1 つだけ取得しています。しかし、新しく更新された 4 つの画像を取得してページに表示したいのですが、これを達成できません。すべての行が同じ画像を取得しています。データベースの最新のエントリをループする方法は?

4

0 に答える 0