我有2个文件fourm.php和viewfourm.php
首先是fourm.php
<?php
$host="mysql13.000webhost.com"; // Host name
$username="a2670376_Users"; // Mysql username
$password="PASS"; // Mysql password
$db_name="a2670376_Pass"; // Database name
$tbl_name="fourm"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// select record from mysql
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<table>
<tr>
<td align="center"><strong>Post Number</strong></td>
<td align="center"><strong>UserName</strong></td>
<td align="center"><strong>Topic</strong></td>
<td align="center"><strong>Date</strong></td>
<td align="center"><strong>View</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['fourmid']; ?> </td>
<td><? echo $rows['username']; ?> </td>
<td><? echo $rows['fourmname']; ? > </td>
<td><? echo $rows['date']; ?> </td>
<td><a href="viewfourm.php?id=<? echo $rows['fourmid']; ?>">View Topic</a></td>
<?php
// close while loop
}
?>
</tr>
</table>
<?php
// close connection;
mysql_close();
?>
<hr width='67%' color='#29001F' size='3'/>
</center>
现在viewfourm.php
<?php
$host="mysql13.000webhost.com"; // Host name
$username="a2670376_Users"; // Mysql username
$password="PASS"; // Mysql password
$db_name="a2670376_Pass"; // Database name
$tbl_name="fourm"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// select record from mysql
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<table>
<tr>
<td align="center"><strong>Post Number</strong></td>
<td align="center"><strong>UserName</strong></td>
<td align="center"><strong>Topic</strong></td>
<td align="center"><strong>Date</strong></td>
<td align="center"><strong>View</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['fourmid']; ? > </td>
<td><? echo $rows['username']; ?> </td>
<td><? echo $rows['fourmname']; ? > </td>
<td><? echo $rows['date']; ?> </td>
<td><a href="fourm.php">back/a></td>
<?php
// close while loop
}
?>
</tr>
</table>
<?php
// close connection;
mysql_close();
?>
<hr width='67%' color='#29001F' size='3'/>
</center>
现在在forum.php上当我从MySql数据库中选择什么“论坛”时我想查看它加载我要修复的所有论坛我知道为什么它这样做因为它的第一个脚本与刚刚修改过的相同一点点,但我做了我能做的事情。我在MySql数据库中选择论坛的thrue fourmid标签,这是什么“&gt;查看主题是关于它应该加载论坛选择的ID
答案 0 :(得分:0)
在viewfourm.php中修改你的sql查询$sql="SELECT * FROM $tbl_name";
,如下所示
$fourmid= $_POST['fourmid']; //if passing using get method use $_GET['fourmid'];
$sql = "SELECT * FROM $tbl_name WHERE
{fourmid {1}}
此外,您必须将fourm.php中的fourmid传递给viewfourm.php
修改强>
建立这样的链接
= '$fourmid'";
答案 1 :(得分:0)
从
获取值a href="viewfourm.php?id=<? echo $rows['fourmid']; ?>">View Topic</a>
// viewform.php
$ fourmid = $ _REQUEST [' id '];。
$ sql =“SELECT * FROM $ tbl_name WHERE fourmid ='$ fourmid'”;
试试..