简体   繁体   English

在第二页显示mysql数据库查询结果

[英]Display mysql database query result on second pages

  1. I have a mysql database with some data.here i display data on one page Now I want to display this data on next page please give me suggestion how I can do this ......... I need some modifications in this code like I want to display table this table on next page(book.php page that is populated with the database)......我有一个包含一些数据的 mysql 数据库。在这里我在一页上显示数据现在我想在下一页显示这些数据请给我建议我如何做到这一点.........我需要在这方面进行一些修改代码就像我想在下一页上显示这个表(用数据库填充的book.php页面)......

  2. Second thing that I need to know is it possible to store the value of calendar in session variable (is it ???than how?)我需要知道的第二件事是可以将日历的值存储在会话变量中(它是 ??? 而不是如何?)

 <?php if(isset($_POST['search'])){ $from = $_POST['from']; $to = $_POST['to']; $query = mysql_query("select * from schedule where Destinatio='$from' AND Arriva ='$to'"); $c = mysql_num_rows($query); if (!$query) { die('Invalid query: ' . mysql_error()); } if($c>0) { ?> <table> <tr align="center"><td width="120"><span class="style23">Destination</span> </td> <td width="57"><span class="style23">Arrival</span></td> <td width="121"><span class="style23">Departure time</span></td> <td width="98"><span class="style23">Arrival Time</span></td> <td width="44"><span class="style23">Fare</span></td> <td width="85"><span class="style23">Bus_type</span></td> <td width="84"><span class="style23">Total_Seats</span></td> <td width="81"><span class="style23">Available</span></td> <td width="52">&nbsp;</td> </tr> </section> <?php while($r1 = mysql_fetch_array($query)) { $schedule= $r1['id']; $Destinatio = $r1['Destinatio']; $Arriva= $r1['Arriva']; $Departure_time = $r1['Departure_time']; $Arrival_time = $r1['Arrival_time']; $Fare = $r1['Fare']; $Bus_type = $r1['Bus_type']; $Total_Seats = $r1['Total_Seats']; $bust = $schedule.'schedule'; $query1 = mysql_query("SELECT * from $bust where status='Available'"); echo $query1; if (!$query1) { die('Invalid query: ' . mysql_error()); } $c = mysql_num_rows($query1); ?> <tr align="center"><td><?php echo $Destinatio;?></td><td><?php echo $Arriva;?></td><td><?php echo $Departure_time;?></td><td><?php echo $Arrival_time;?></td><td><?php echo $Fare;?></td><td nowrap="nowrap"><?php echo $Bus_type;?></td><td><?php echo $c;?></td><td><a href="book.php?id=<?php echo $uid;?>&bus=<?php echo $schedule;?>">Book</a> </td> </tr></table> </form>

There are three main ways to pass variables:传递变量的方式主要有以下三种:

  1. Using a form button using $_POST variables to pass the content (generally best when you also have user input).使用使用 $_POST 变量的表单按钮来传递内容(通常最好是当您还有用户输入时)。
  2. Using an HTML anchor link to pass the variables through $_GET使用 HTML 锚链接通过 $_GET 传递变量
  3. Using a SESSION variable that can be accessed on all pages on your site.使用可以在您网站上的所有页面上访问的 SESSION 变量。

Using SESSION variables is the more secure way, but it the data isn't secret use the $_GET method.使用 SESSION 变量是更安全的方式,但数据不是秘密的,使用 $_GET 方法。

To store something in a SESSION variable you need to use:要将某些内容存储在 SESSION 变量中,您需要使用:

start_session();
$_SESSION['varname'] = value;

on the following page, you can read your SESSION variable just by using it's name.在下一页上,您可以仅通过使用它的名称来读取您的 SESSION 变量。 For example:例如:

start_session();
echo $_SESSION['varname'];

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

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