0

PHP配列をいくつかのdivクラスでhtmlに変換する必要があります。

これが私のコードです:

<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
  {    die('Could not connect: ' . mysql_error());
  }
mysql_select_db("asd", $con);

$result = mysql_query("SELECT * FROM asd");
$something = array(); 
while ($row = mysql_fetch_assoc($result)) { 
$something[] = array("title"=>$row['title'], 
       "name"=>$row['name'], 
       "content"=>$row['content'],
       "image" => 
           array(
             "cls"=>"slide-image",
             "_src"=>$row['src'],
             "source"=>$row['source']                
             )   
       );
}
mysql_close($con);
?>

このような出力が欲しい

<div class="class1"> Here title goes</div>
Here name with some class
Here content with some class

何か助けてください?

4

1 に答える 1

0
<?php
mysql_connect("localhost","root","root") or die (mysql_error());
mysql_select_db("asd") or die (mysql_error());

$result = mysql_query("SELECT * FROM asd") or die (mysql_error());
while ($row = mysql_fetch_array($result)) { 
       $title = $row['title']; 
       $name = $row['name'] ;
       $content = $row['content'];
       echo "<div class=title>" . $title . "</div>";
}
mysql_close($con);
?>
于 2012-12-03T02:30:31.450 に答える