简体   繁体   English

PHP表-如何在从数据库中提取的表的每一行上添加不同的超链接

[英]PHP Table - How to add different hyperlinks on each row of table which is extracted from database

Okay, my problem is that how can I set different hyperlinks to each row of a table in php? 好的,我的问题是如何在php中为表的每一行设置不同的超链接?

so far i've done this --> 到目前为止,我已经做到了->

<?php

$conn = mysqli_connect("localhost", "root", "", "makaut_colleges");
$result = mysqli_query($conn, "SELECT * FROM collegelist");

while ($row = mysqli_fetch_assoc($result)):

?>

<tr>
    <td><?php echo $row['College Name']; ?></td>
    <td><?php echo $row['College Address']; ?></td>
    <td><?php echo $row['College Code']; ?></td>
    <td><?php echo $row['Review']; ?></td>
</tr>

<?php endwhile; ?>

How can i add different hyperlinks to each row which will be extracted from database? 如何将不同的超链接添加到将从数据库中提取的每一行? i'm using 'College Code' as primary key. 我正在使用“大学代码”作为主键。

You can try something like this 你可以尝试这样的事情

Try this for making tr clickable 试试这个让tr可点击

 $dynamic_link = "dynamic.php";
    <tr onclick="document.location = '<?php echo $dynamic_link  ?>'">
        td code---------
    </tr>;

where $dynamic_link is dynamic based on your requirement Thier should be some logic or linking with url either save in table or create some link 其中$dynamic_link是根据您的要求动态的,应该是一些逻辑或与url的链接保存在表中或创建一些链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM