gpt4 book ai didi

php - 将两个 href 显示到表中的单独列中

转载 作者:太空宇宙 更新时间:2023-11-03 23:03:46 25 4
gpt4 key购买 nike

我遇到了一个很难解决的问题。我有一个显示视频教程的系统。我下面的代码将视频名称 (eNISATQuestion) 和视频链接 (eNISATVideo) 显示为一个 href。

我想添加另一列以显示链接到评级页面,其布局与以下部分类似。

<tr>
<td>
<a href='{$row['eNISATVideo']}'>{$row['eNISATQuestion']}</a>
</td>
</tr>

具有值 (eNISATRateRef) 和 (eNISATRating)。

提前致谢

<?php

session_start();
include_once 'dbconnect.php';

if (!isset($_SESSION['user'])) header("Location: index.php");

$res = mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow = mysql_fetch_array( $res );

$userID = $_SESSION['user'];

$query = "SELECT eNISATQuestion, eNISATVideo, eNISATRateRef, eNISATRating FROM enisatquestion INNER JOIN enisatanswer WHERE
enisatanswer.eNISATID = enisatquestion.eNISATID AND user_id =
$userID AND eNISAT_watch = 1";

$result = mysql_query($query);

/* A default message if the query fails or there are no records */
$enisatquestion='<h2>Sorry, there are no records</h2>';

if($result) {/* if there is a recordset, proceed and generate html table */
$enisatquestion = "<table >";

while ($row = mysql_fetch_assoc($result)) {
**$enisatquestion .= "<tr><td><a href='{$row['eNISATVideo']}'>{$row['eNISATQuestion']}</a></td></tr>";**
}
$enisatquestion .= "</table>";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome - <?php echo $userRow['username']; ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
<div id="left">
<label>NHSCT eNISAT Tutorials</label>
</div>
<div id="right">
<div id="content">
Welcome <?php echo $userRow['forename']; ?>&nbsp;<a href="home.php?home">Return to Homepage</a>&nbsp;&nbsp;<a
href="logout.php?logout">Sign Out</a>
</div>
</div>
<br>
<br>
<br>
<br>
<p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg">
<br>
<br>
<center>
<h2>Click on the each link to open your tutorial in Windows Media Player<h2>
<br>
<?php
/* output the html table here, below your header */
echo $enisatquestion;
/* If the query failed then the default gets displayed */
?>
</div>
</body>
</html>

最佳答案

只需添加另一个 td 元素并添加您从数据库中获取的新数据。

**$enisatquestion .= "
<tr>
<td><a href='{$row['eNISATVideo']}'>{$row['eNISATQuestion']}</a></td>
<td><a href='{$row['eNISATRateRef']}'>{$row['eNISATRating']}</a></td>
</tr>";**

关于php - 将两个 href 显示到表中的单独列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35468137/

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