English 中文(简体)
5. 纳维盖特·贝特·米苏克·沃伦德
原标题:Navigate Throught MySQL Result
  • 时间:2011-11-22 23:58:31
  •  标签:
  • php
  • mysql

我在任何地方都进行了搜查,但找不到任何东西。 假设情况是,当我从MySQL/PHP那里做过一次选择发言时,我要使用“善后”和“善后”;前纽州通过结果来纠正后退。

Does anyone know how I can accomplish this? Here s how I run the query: select everything from members where hair = black;

这一回报是8,我有一个网页,如<代码>details.php?id=3,该网页请上和显示细节。

我希望能够不断点击下顿,从结果转向另一个id。

我如何做到这一点?

感谢你的援助。

问题回答

如果你打算用下顿语显示每页1个产品细节,那么

1) Get the total rows from table
2) Find total number of pages like
$totalPages = $totalRows; //since 1 record per page
3) Loop thru $totalPages value to generate next links
4) Get the id of product from page url $_GET
5) Query sql using te product id obtained frm GET

祝福,希望你们能够做到这一点。

假设你在<条码>上有所有女胎,就象这样:

<?php
$id = (int) $_GET[ id ];
$key = array_search($id, $allIds);
$nextId = $allIds[$key+1];
?>

在这里,你有两种不同的处理范围,首先,当你问你是PHP/Server。 PHP获得一些数据,处理数据,向你们了解问题,然后将其送往浏览器。

Next, you have the client scope, where the client has the HTML rendered to his screen and has the possibility to click NEXT and PREVIOUS. When he does that, he issues a request to the server to get the NEXT or PREVIOUS record based on the current one.

你们有两种情况:

(1) 将全部数据记录在记忆中,并扫描,以找到你目前的立场,看看是否有一个NEXT和PREVIOUS要素,并回应用户的要求。 如果用户要求提交《国家空间报》,那么简单地转去一个记录。 如果用户要求PREVIOUS项目,那么当使用WHILE或 FOR/FOREACH进行扫描时,你总是记得你所看到的“最后项目”,你就可以将这一“最后项目”作为你的PREVIOUS项目。

2) 如果你有许多(如1 000多件)物品,那么你需要使用很少的子座,并利用KQ进行这项工作。

select everything from members where hair = black AND id = XYZ ORDER BY id LIMIT 2;

这将使你回到正文和内容。 随后又再次提出同样的问题,但此时此刻,命令其放弃,使你的两个项目成为常设和常设机构。

select everything from members where hair = black AND id = XYZ ORDER BY id DESC LIMIT 2;

请注意,你可以下令采取这种方式,目标是取得静态结果,这种结果总是以同样的方式出现,以便你能够扭转这种局面,把物品放在所选项目周围。

我希望这能帮助你。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签