gpt4 book ai didi

php - 记录未入库时如何设置空余空间

转载 作者:行者123 更新时间:2023-11-30 23:20:54 25 4
gpt4 key购买 nike

我创建了 html 表单,当我单击提交按钮时,我从数据库中获取记录,但如果数据不在数据库中,则打印

    http://bukkyolu.com/mp3/upload/ 

这不是来自数据库,它只是我在下面的声明中打印的静态值

    http://bukkyolu.com/mp3/upload/".$row['2']."'> ,
if the .$row['2'].is not in to database

我想要空白而不是打印的默认链接

<?php
$category=$_POST["category"];
$month=$_POST["month"];

$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "bukkyolu_mp3";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die("Opps some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");

$query = "SELECT title,Amp3,Bmp3,Cmp3 FROM mp3_data WHERE`category` = '$category' and `month` = '$month' ";
$result1 = mysql_query($query);
$row = mysql_fetch_array($result1);
//echo $row['s_id'];

echo "<table border='1' align='center' >";

while ($row = mysql_fetch_row($result1)){
// echo "<td><a href='#' onclick='someFunction()'>" .$row['0']. "</a> </td>";
echo "<tr><th>Title:</th><td>".$row['0']."</td></tr>";
echo "<tr><th>African:</th><td><a href 'http://bukkyolu.com/mp3/upload/".$row['1']."'>http://bukkyolu.com/mp3/upload/".$row['0']."</a></td></tr>";
echo "<tr><th>British:</th><td><a href 'http://bukkyolu.com/mp3/upload/".$row['2']."'>http://bukkyolu.com/mp3/upload/".$row['0']."</a></td></tr>";
echo "<tr><th>Caribbean:</th><td><a href 'http://bukkyolu.com/mp3/upload/".$row['3']."'>http://bukkyolu.com/mp3/upload/".$row['3']."</a></td></tr>";
echo "<tr></tr>";
echo "<tr></tr>";
}
echo "</table>";

?>

最佳答案

检查如下值。

if(isset($row['0']) && $row['0'] != "")
{
echo "<tr><th>African:</th><td><a href 'http://bukkyolu.com/mp3/upload/".$row['1']."'>http://bukkyolu.com/mp3/upload/".$row['0']."</a></td></tr>";
}
else
{
echo "<tr><th>African:</th><td>...</td></tr>";
}

对其他人做同样的事情。

创建函数更像是一种良好的编程习惯。

function checkForValue($value)
{
$response = "&nbsp";// you can also add ... or anything
if(isset($value) && $value != "")
{
$response = $value;
}
return $response;
}

并将其命名为 .

echo "<tr><th>Title:</th><td>".checkForValue($row['0'])."</td></tr>";  

关于php - 记录未入库时如何设置空余空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15492153/

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