猿问

在表格中插入链接按钮

我是 mysqli 的新手,我想我已经掌握了基本知识,但我正在努力争取我可以执行的表格中的一个按钮。


这是我的代码:


while($row = mysqli_fetch_array($result))

{

echo "<tr align='left'>";

echo "<td>" . $row['id'] . "</td>";

echo "<td>" . $row['sysdate'] . "</td>";

echo "<td>" . $row['systime'] . "</td>";

echo "<td>" . $row['controller'] . "</td>";

echo "<td>" . $row['sla_client'] . "</td>";

echo "<td>" . $row['notes'] . "</td>";

echo "<td>" **BUTTON TO BE INSERTED HERE** "</td>";

echo "</tr>"; 

}

下面的代码显然在上表中不起作用


<button onclick="window.location.href = '../master.php';">Click Here</button>


GCT1015
浏览 117回答 2
2回答

ABOUTYOU

您可能会找到以下解决方案:while($row = mysqli_fetch_array($result)){ ?>&nbsp; &nbsp; <tr align='left'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><?php echo $row['id']; ?></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><?php echo $row['sysdate']; ?></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><?php echo $row['systime']; ?></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><?php echo $row['controller']; ?></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><?php echo $row['sla_client']; ?></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><?php echo $row['notes']; ?></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><?php echo $row['id']; ?></td>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<td><a href="<?php echo $row['link of the BUTTON']; ?>">BUTTON text TO BE INSERTED HERE</a></td>&nbsp; &nbsp; </tr><?php }简介: 只是不要在 PHP 中放置过多的 HTML,这是不好的做法。

茅侃侃

我建议:您可以将类似的内容与 HTML "href" tag 一起使用。以下是如何执行此操作的示例:while($row = mysqli_fetch_array($result))&nbsp; &nbsp;echo "<tr align='left'>";&nbsp; &nbsp; &nbsp; echo "<td>".$row['id'] . "</td>";&nbsp; &nbsp; &nbsp; echo "<td>".$row['sysdate'] . "</td>";&nbsp; &nbsp; &nbsp; echo "<td>".$row['systime'] . "</td>";&nbsp; &nbsp; &nbsp; echo "<td>".$row['controller'] . "</td>";&nbsp; &nbsp; &nbsp; echo "<td>".$row['sla_client'] . "</td>";&nbsp; &nbsp; &nbsp; echo "<td>".$row['notes'] . "</td>";&nbsp; &nbsp; &nbsp; /* you could also use something like this with HTML href Tag */&nbsp; &nbsp; &nbsp; echo "<td><a href=master.php><button>Click Here</button></a></td>";&nbsp; &nbsp;echo "</tr>";}
随时随地看视频慕课网APP
我要回答