PHP代码在一个页面中显示 [英] PHP codes in one page to display
本文介绍了PHP代码在一个页面中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的代码。单击标题后,浏览器的地址栏将更改为books.php?choice = title。我的问题是我需要从标题运行排序这个表,所以我想在这个单独的php文件中添加排序标题php代码。我需要像header = books.php?choice = title然后在代码下面运行代码。请帮帮我。
Hi, Below is my code. Once click the Title, Address bar of the browser will be changed to books.php?choice=title. My problem is I need to run sort this table from title, so I want to add sort title php code inside this single php file. I need like header = books.php?choice=title then run the code else below code. Please help me.
<?php
$con=mysqli_connect("","","","");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM authors a, books b, publish p where p.authorid=a.authorid and p.bookid=b.bookid");
echo "<table border='1'>
<tr><th colspan='7'><a href=''>Add Book</a> |
<a href=''>Add Author</a></td></tr>
<tr>
<th><a href='books.php?choice=title'>Title</a></th>
<th><a href=''>Author Name</a></th>
<th><a href=''>Genre</a></th>
<th><a href=''>Country</a></th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['fname'] . "</td>";
echo "<td>" . $row['genre'] . "</td>";
echo "<td>" . $row['country'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
推荐答案
con = mysqli_connect( ,,,);
// 检查 连接
if (mysqli_connect_errno())
{ < span class =code-summarycomment>
< span class =code-summarycomment> echo 失败 connect to MySQL: 。 mysqli_connect_error();
}
con=mysqli_connect("","","",""); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
result = mysqli_query(
result = mysqli_query(
>
con, SELECT * FROM authors a, books b, publish p 其中 p.authorid = a.authorid 和 p.bookid = b.bookid );
echo < table border =' 1' >
< ; tr > < th colspan =' 7' > < a href =' ' > 添加图书< / a > |
< a < span class =code-attribute> href =' ' > 添加作者< / a > < / td > < / tr >
< tr >
< th > < a 跨度> href =' books.php?choice = title' > 标题< / a > < / th >
< th > < a href =' ' > 作者姓名< / a > < / th >
< th > < a href =' ' > 类型< < span class =code-leadattribute> / a > < / th >
< < span class =code-leadattribute> th > < a href ='跨度>' > 国家< / a > < / th >
< / tr > ;
while(
con,"SELECT * FROM authors a, books b, publish p where p.authorid=a.authorid and p.bookid=b.bookid"); echo "<table border='1'> <tr><th colspan='7'><a href=''>Add Book</a> | <a href=''>Add Author</a></td></tr> <tr> <th><a href='books.php?choice=title'>Title</a></th> <th><a href=''>Author Name</a></th> <th><a href=''>Genre</a></th> <th><a href=''>Country</a></th> </tr>"; while(
这篇关于PHP代码在一个页面中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文