https://www.webslesson.info/2016/05/how-to-search-multiple-words-at-a-time-in-mysql-php.html
在此站点上显示如何在Mysql ph中一次搜索多个单词的示例 我想对该示例进行改进。就像在显示重用(video_title)后,如果我单击result(video_title)后,它显示www.whatever.com(video_link)。
$condition = substr($condition, 0, -4);
$sql_query = "SELECT * FROM tbl_video WHERE " . $condition;
$result = mysqli_query($connect, $sql_query);
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
echo '<tr><td>'.$row["video_title"].'</td></tr>';
}
}
else
{
echo '<label>Data not Found</label>';
}
}
答案 0 :(得分:1)
我猜您的列名称为video_link
因此,您应该使用
echo '<tr><td><a href="' . $row["video_link"] . '">' . $row["video_title"] . '</a></td></tr>';
带有可选文本:
if( !empty($row) ){
echo '<tr><td><a href="' . $row["video_link"] . '">' . $row["video_title"] . $row["video_optionnal_text"] . '</a></td></tr>';
} else {
echo '<tr><td><a href="' . $row["video_link"] . '">' . $row["video_title"] . '</a></td></tr>';
}