gpt4 book ai didi

php - 我如何在 php 中使用 sql 进行编辑

转载 作者:行者123 更新时间:2023-11-30 01:31:45 26 4
gpt4 key购买 nike

我的代码 -

<?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
}
?>

作为原始输出,详细信息将出现在这样的列表中 -

Image1
Video name1
Author name1
Category1
Description1

<hr>

Image2
Video name2
Author name2
Category2
Description2

现在想要 make put <div>图片、作者​​、视频名称之间的标签和标签

我该如何放置?因为当我编辑“<br>”并插入“<div class="thumb"></div><br>

It shows error ! - Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/servin/public_html/upload/view.php on line 14

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

最佳答案

你不能使用双引号 <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 } ?>

关于php - 我如何在 php 中使用 sql 进行编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17368783/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com