Display data from another php site

狂风中的少年 提交于 2019-12-25 00:37:37

问题


I am having trouble to display my bookISBN in another php site. Actually my first php page I have tabulated the data into a table form. And now I want to let the user to click on the book title and open a new php page where it shows the books details.

This is my first php page code:

echo "<table width = \"1000px\" border = \"1\" cellpadding = \"1\" cellspacing=\"1\">";
echo "<tr>";
echo "<th>".'Book ISBN'."</th>";;
echo "<th>".'Book Title'."</th>";
echo "<th>".'Book Year'."</th>";
echo "<th>".'Category ID'."</th>";
echo "<th>".'Category Description'."</th>";
echo "<th>".'Book Price'."</th>";
echo "<tr>";

if($booknum >= 1 ){
echo "<div style='margin: 0 0 10px 0; font-weight: bold;'>$booknum record(s) found!</div>";
while ($row = mysqli_fetch_assoc($bookrs)) {
    echo "<tr>";
    echo "<td><center>" . $row['bookISBN']."</center></td>";
    echo "<td><center><a href=\"bookdetails.php\">" .$row['bookTitle']. "</a></center></td>";
    echo "<td><center>" . $row['bookYear']."</center></td>";
    echo "<td><center>" . $row['catID']."</center></td>";
    echo "<td><center>" . $row['catDesc']."</center></td>";
    echo "<td><center>" . $row['bookPrice']."</center></td>";
    echo "</tr>";
}

Now I want to know how to retrieve the book ISBN number so that i can display in my second php page. I would be glad if someone can help me with it.


回答1:


echo "<td><center><a href=\"bookdetails.php?book=".$row['bookISBN']."\">" .$row['bookTitle']. "</a></center></td>";

bookdetails.php you can access with $_REQUEST['book']

Refrence site




回答2:


Add a new parameter in the url.

echo '<td><center><a href="bookdetails.php?bookISBN=' . $row['bookISBN'] . '">' .$row['bookTitle']. '</a></center></td>';

And in bookdetails.php, retrieve it using

$bookISBN = ! empty($_GET['bookISBN']) ? $_GET['bookISBN'] : '';



回答3:


Add a Query string in href link

 echo "<td><center><a href=\"bookdetails.php?bookid=" .$row['bookId']. "\">" .$row['bookTitle']. "</a></center></td>";


来源:https://stackoverflow.com/questions/27602687/display-data-from-another-php-site

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!