0

我的代码 -

<?php
 //Retrieves data from MySQL 
$data = mysql_query("SELECT * FROM employees ORDER BY id DESC") or die(mysql_error()); 
 //Puts it into an array 
 while($info = mysql_fetch_array( $data )) 
 { 

 //Outputs the image and other data


 Echo "<img src=http://www.mywebsite.com/upload/".$info['video'] ."> <br>";  //This is the name of my Video URL in MySQL
 Echo "<b>Video</b> ".$info['Video'] . "<br> ";        //This is the name of my Video Name in MySQL
 Echo "<b>Author</b> ".$info['Author'] . "<br> ";        //This is the name of my USER in MySQL
 Echo "<b>Category</b> ".$info['category'] . "<br> ";    //This is the name of Video Category in MySQL
 Echo "<b>Description</b> ".$info['Description'] . "<hr>";       //This is the name of Description in MySQL
 }
 ?>

作为原始输出,详细信息将像这样出现在 List 中 -

Image1
Video name1
Author name1
Category1
Description1

<hr>

Image2
Video name2
Author name2
Category2
Description2

现在想<div>在图像、作者、视频名称之间添加标签和标签

我怎么能放?因为当我编辑“ <br>”并插入“ <div class="thumb"></div><br>”时

它显示错误!- 解析错误:语法错误,意外的 T_STRING,期待 ',' 或 ';' 在第 14 行的 /home/servin/public_html/upload/view.php

我如何编辑 mysql php 代码以便我可以添加 html 代码 + 所有详细信息也必须像这样显示

4

1 回答 1

0

你不能使用双引号,<div class="thumb"> 你应该像<div class='thumb'>使用单引号一样使用它。因为你已经在使用它 echo ,试试这个:

    <?php
   //Retrieves data from MySQL 
  $data = mysql_query("SELECT * FROM employees ORDER BY id DESC") or die(mysql_error()); 
 //Puts it into an array 
 while($info = mysql_fetch_array( $data )) 
 { 

 //Outputs the image and other data


  echo "<div class='thumb'><img src='http://www.mywebsite.com/upload/".$info['video'] ." ' /> </div><br>";  //This is the name of my Video URL in MySQL
  echo "<div class='thumb'><b>Video</b> ".$info['Video'] . "<br /> ";        //This is   the name of my Video Name in MySQL
  echo "<div class='thumb'><b>Author</b> ".$info['Author'] . "<br /> ";        //This is the name of my USER in MySQL
  echo "<div class='thumb'><b>Category</b> ".$info['category'] . "<br /> ";    //This is the name of Video Category in MySQL
  echo "<div class='thumb'><b>Description</b> ".$info['Description'] . "<hr>";         //This is the name of Description in MySQL
 }
 ?>

编辑:如果你想在这里使用 html 更好的方法

   <?php
   //Retrieves data from MySQL 
    $data = mysql_query("SELECT * FROM employees ORDER BY id DESC") or die(mysql_error()); 
   //Puts it into an array 
   while($info = mysql_fetch_array( $data )) 
   { 

   //Outputs the image and other data
   ?>

   <div class='thumb'><img src='http://www.mywebsite.com/upload/<?php echo $info['video']; ?> ' /> </div><br /> 
   <div class='thumb'><b>Video</b><?php echo $info['Video'] ;?><br />         
   <div class='thumb'><b>Author</b><?php echo $info['Author'] ;?><br />       
   <div class='thumb'><b>Category</b><?php echo $info['category'] ; ?><br />   
   <div class='thumb'><b>Description</b><?php echo $info['Description'] ; ?><hr />      
  <?php  } ?>
于 2013-06-28T15:58:41.630 回答