[PHP-DB] Next, prev, records in MySql. Handler Function
Dear all: I have been exploring about this issue quite a lot, and find no solution: Platform: Debian, MySql 4.1.11, PHP 4.3.10-2, Apache. Is there any way I can retrieve a set of values depending in a where clause: For example: from a set of values in one field: 1,2,5,8,9,11,13 I'd like to retrieve a record (8) and also the previous one (5) and the next one (9) (so the record set would be: 5,8,9) I have found the "Handler" function in the Manual, but it and keeps giving me errors (I have also checked in the manual and it seems to work with MySql 4.1.x) /* --Start example - HANDLER tbl_sm04_indicador READ PK_indicador_id { FIRST | NEXT | PREV | LAST } WHERE PK_indicador_id=8 LIMIT 0, 3 -- --End example (I know, I am completely lost)*/ Does anybody has tried this function before?. Is it useful for the result I would like to accomplish? Could anybody could share an example of how to use this function? Thanks and best regards. Alvaro Cobo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Next ---- Previous Button/Function????
Hi all, I need some help with navigation in an array. The plan is to display a row and by using a 'Next" or 'Previous' button to display, on the same form, the next or previous row from that array. The array is populated correctly and when the script runs it displays all twelve elements, followed by the 'Next' button. How can it be fixed that the 'Next' button triggers the display of the next row in an array? Here is the code, please help me out. + %s\n", $message); } //echo ($userName); //echo ($userPassword); //echo ($foundKey); if (!($link = mysql_connect ($DB_SERVER,$DB_LOGIN, $DB_PASSWORD))) { DisplayErrMsg(sprintf("internal error %s %d:%s\n",$DB_SERVER, $DB, mysql_errno(), mysql_error())); return 0 ; } $sqlStmt="SELECT * FROM $tableName WHERE CustomerId='$foundKey'"; mysql_select_db($DB,$link); if (!($result = mysql_query($sqlStmt, $link))): DisplayErrMsg(sprintf("Error in executing %s stmt", $sqlStmt)); DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))); exit(); endif; $idx=0; while ($row = mysql_fetch_object($result)){ $rSet[$idx]=$row; ++$idx; } $rowCount=mysql_num_rows($result); echo ("$rowCount \n"); THE ARRAY IS POULATED CORRECTLY. ?> Customer Product ID CustomerProductId); ?> +++ Thanks, Dick Davis Skyline Data Systems Professional IT Solutions. [EMAIL PROTECTED]
RE: [PHP-DB] Next/Prev 10 lines
First you have to find how many rows would make your SELECT query in case you would not use "LIMIT from, num". Then you have to divide this by number of rows per page and use it in the SELECT query. Then to your number of pages displayed on your page you add links to the first number of the LIMIT part in your query. Maybe something like this: YOUR rows displayed ... 1) { echo "GO TO PAGE NUMBER: "; for($i = 1; $i <= ($num_pages); $i++) { if($set_page_start == $page_start) { echo "$i "; } else { echo "$i "; } $set_page_start = $set_page_start + $page_limit; } ?> If you want to use PREV, NEXT instead of page numbers, just modify a little the second code paragraph. Merry Christmas to all ! Hynek Hynek Semecký www.semecky.com www.perlickovekoupele.cz Profi Web Hosting: http://www.web4u.cz/index.php?page=Programy&rid=2837 -Original Message- From: Steve Dodkins [mailto:[EMAIL PROTECTED]] Sent: 20. prosince 2002 16:16 To: [EMAIL PROTECTED] Subject: [PHP-DB] Next/Prev 10 lines Has anyone got some code that will correctly display the next 10 line of a table with prev and next working? Or point me in the right direction for help? Regards Steve Dodkins IMPORTANT NOTICE The information in this e-mail is confidential and should only be read by those persons to whom it is addressed and is not intended to be relied upon by any person without subsequent written confirmation of its contents. ebm-ZIEHL (UK) Ltd. cannot accept any responsibility for the accuracy or completeness of this message as it has been transmitted over a public network. Furthermore, the content of this e-mail is the personal view of the sender and does not represent the advice, views or opinion of our company. Accordingly, our company disclaim all responsibility and accept no liability (including in negligence) for the consequences of any person acting, or refraining from acting, on such information prior to the receipt by those persons of subsequent written confirmation. In particular (but not by way of limitation) our company disclaims all responsibility and accepts no liability for any e-mails which are defamatory, offensive, racist or in any other way are in breach of any third party's rights, including breach of confidence, privacy or other rights. If you have received this e-mail message in error, please notify me immediately by telephone. Please also destroy and delete the message from your computer. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message is strictly prohibited. If you have received this E-mail in error, or suspect that the message may have been intercepted or amended, please notify ebm-ZIEHL (UK) Ltd on +44(0)1245 468555. ebm-ZIEHL (UK) Ltd Chelmsford Business Park, Chelmsford, Essex CM2 5EZ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Next/Prev 10 lines
check out php.weblogs.com ADODB does this for you. =C= * * Cal Evans * The Virtual CIO * http://www.calevans.com * -Original Message- From: Steve Dodkins [mailto:[EMAIL PROTECTED]] Sent: Friday, December 20, 2002 9:16 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Next/Prev 10 lines Has anyone got some code that will correctly display the next 10 line of a table with prev and next working? Or point me in the right direction for help? Regards Steve Dodkins IMPORTANT NOTICE The information in this e-mail is confidential and should only be read by those persons to whom it is addressed and is not intended to be relied upon by any person without subsequent written confirmation of its contents. ebm-ZIEHL (UK) Ltd. cannot accept any responsibility for the accuracy or completeness of this message as it has been transmitted over a public network. Furthermore, the content of this e-mail is the personal view of the sender and does not represent the advice, views or opinion of our company. Accordingly, our company disclaim all responsibility and accept no liability (including in negligence) for the consequences of any person acting, or refraining from acting, on such information prior to the receipt by those persons of subsequent written confirmation. In particular (but not by way of limitation) our company disclaims all responsibility and accepts no liability for any e-mails which are defamatory, offensive, racist or in any other way are in breach of any third party's rights, including breach of confidence, privacy or other rights. If you have received this e-mail message in error, please notify me immediately by telephone. Please also destroy and delete the message from your computer. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message is strictly prohibited. If you have received this E-mail in error, or suspect that the message may have been intercepted or amended, please notify ebm-ZIEHL (UK) Ltd on +44(0)1245 468555. ebm-ZIEHL (UK) Ltd Chelmsford Business Park, Chelmsford, Essex CM2 5EZ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Next/Prev 10 lines
On Friday 20 December 2002 23:16, Steve Dodkins wrote: > Has anyone got some code that will correctly display the next 10 line of a > table with prev and next working? > Or point me in the right direction for help? Search the archives. This kind of question gets asked (and sometimes answered) every other day (or so it seems). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Nihilism should commence with oneself. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Next/Prev 10 lines
Has anyone got some code that will correctly display the next 10 line of a table with prev and next working? Or point me in the right direction for help? Regards Steve Dodkins IMPORTANT NOTICE The information in this e-mail is confidential and should only be read by those persons to whom it is addressed and is not intended to be relied upon by any person without subsequent written confirmation of its contents. ebm-ZIEHL (UK) Ltd. cannot accept any responsibility for the accuracy or completeness of this message as it has been transmitted over a public network. Furthermore, the content of this e-mail is the personal view of the sender and does not represent the advice, views or opinion of our company. Accordingly, our company disclaim all responsibility and accept no liability (including in negligence) for the consequences of any person acting, or refraining from acting, on such information prior to the receipt by those persons of subsequent written confirmation. In particular (but not by way of limitation) our company disclaims all responsibility and accepts no liability for any e-mails which are defamatory, offensive, racist or in any other way are in breach of any third party's rights, including breach of confidence, privacy or other rights. If you have received this e-mail message in error, please notify me immediately by telephone. Please also destroy and delete the message from your computer. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message is strictly prohibited. If you have received this E-mail in error, or suspect that the message may have been intercepted or amended, please notify ebm-ZIEHL (UK) Ltd on +44(0)1245 468555. ebm-ZIEHL (UK) Ltd Chelmsford Business Park, Chelmsford, Essex CM2 5EZ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Next N Interface
> That would actually work for just getting a certain number of records from > a > query, but you would have to execute another query to figure out the > navigational > links he said he wants on the bottom...like google has, << 1 2 3 4 5 >>. > So, > when I attacked it I figured one query is better then two even if it > returns a > whole bunch of records in the result that you are not using for that page. > How is > that for performance? which would be better? Or even, is there an > alternative > way to figureing out how many records are in a database? Always more then > one > way to skin a cat. Use two queries. A count(*) query and a LIMIT query to only return X rows. If you have a smaller table, it might be okay to do it with on and seek the rows you want, but it's inefficient and not scalable for large tables. Previous/Next links are pretty simple with MySQL. Just pass a $page variable between pages. Increment it with Next, decrement it with Previous. Then, use it in your query like this: $result1 = mysql_query("SELECT COUNT(*) FROM your_table WHERE ... "); $records = mysql_result($result,0); $num_per_page = 5; $start = $page * $num_per_page; $num_pages = ceil($records / $num_per_page); $result = mysql_query("SELECT * FROM your_table WHERE ... LIMIT $start, $num_per_page"); Add in a little logic so $page isn't below zero and doesn't go above your max pages, and you're golden... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Next N Interface
That would actually work for just getting a certain number of records from a query, but you would have to execute another query to figure out the navigational links he said he wants on the bottom...like google has, << 1 2 3 4 5 >>. So, when I attacked it I figured one query is better then two even if it returns a whole bunch of records in the result that you are not using for that page. How is that for performance? which would be better? Or even, is there an alternative way to figureing out how many records are in a database? Always more then one way to skin a cat. -Brad Mark Lee wrote: > How about appending " LIMIT _GET[startrow],5" to the end of your query. > > The first parameter to LIMIT is the start position and the second is > the number of rows to return. > > Does this help, or am I misunderstanding your question? > > Mark > > Lucas Novæ Matrix wrote: > > >Hello, > > > >I am trying to create a "next n" interface through php4, using results from > >a mysql query. I did this in the past easily with ColdFusion, but this time > >it's a bit more complicated. > > > >What I need to do basicaly is to have only 5 results per page. The first > >page displays the 5 results and "Next Page >>>" at the bottom, the second > >page displays results 6 to 10 and displays "<<< Previous Page | Next Page > > > " , up until the last page that displays only the previous page, and the > > >last results (from 1 to 5). > > > >I don't necessarely need to have each page as a number at the bottom, just > >the previous and next links. All I need basically is to either get or output > >only 5 rows at a time, with only needing the $_GET['startrow'] variable. > > > >Can anyone help me? (or just throw me a link to an existing page/script) > > > >Thanks, > >Éric. > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Next N Interface
How about appending " LIMIT _GET[startrow],5" to the end of your query. The first parameter to LIMIT is the start position and the second is the number of rows to return. Does this help, or am I misunderstanding your question? Mark Lucas Novæ Matrix wrote: >Hello, > >I am trying to create a "next n" interface through php4, using results from >a mysql query. I did this in the past easily with ColdFusion, but this time >it's a bit more complicated. > >What I need to do basicaly is to have only 5 results per page. The first >page displays the 5 results and "Next Page >>>" at the bottom, the second >page displays results 6 to 10 and displays "<<< Previous Page | Next Page > " , up until the last page that displays only the previous page, and the >last results (from 1 to 5). > >I don't necessarely need to have each page as a number at the bottom, just >the previous and next links. All I need basically is to either get or output >only 5 rows at a time, with only needing the $_GET['startrow'] variable. > >Can anyone help me? (or just throw me a link to an existing page/script) > >Thanks, >Éric. > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Next N Interface
I did something like this with a photo gallery I made. The approach I took is the execute a query, get the number of rows, and divide that number by how ever many records I wanted on that page. Then that would give me the number of total pages I would have for my navigational links at the bottom. Then I would pass a page number from page to page and multiply this by the number of records which would give me the first record to display from the same query. Soem sample code: (I displayed 4 pictures/records per page) $num_rows = mysql_num_rows($result); //Check to see if any rows are present if ($num_rows <= 0) { echo "No Pictures Available in this Album"; exit(1); } $x = ($num_rows/4); $y = intval($x); if ($x > $y) { $num_pages= $y+1; } else { $num_pages= $x; } $curr_row = ($curr_page*4); if ($DEBUG > 0) { echo "Curr_row is: $curr_row"; } mysql_data_seek($result, $curr_row); HTH -Brad "Lucas Novæ Matrix" wrote: > Hello, > > I am trying to create a "next n" interface through php4, using results from > a mysql query. I did this in the past easily with ColdFusion, but this time > it's a bit more complicated. > > What I need to do basicaly is to have only 5 results per page. The first > page displays the 5 results and "Next Page >>>" at the bottom, the second > page displays results 6 to 10 and displays "<<< Previous Page | Next Page > >>>" , up until the last page that displays only the previous page, and the > last results (from 1 to 5). > > I don't necessarely need to have each page as a number at the bottom, just > the previous and next links. All I need basically is to either get or output > only 5 rows at a time, with only needing the $_GET['startrow'] variable. > > Can anyone help me? (or just throw me a link to an existing page/script) > > Thanks, > Éric. > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Next N Interface
Hello, I am trying to create a "next n" interface through php4, using results from a mysql query. I did this in the past easily with ColdFusion, but this time it's a bit more complicated. What I need to do basicaly is to have only 5 results per page. The first page displays the 5 results and "Next Page >>>" at the bottom, the second page displays results 6 to 10 and displays "<<< Previous Page | Next Page >>>" , up until the last page that displays only the previous page, and the last results (from 1 to 5). I don't necessarely need to have each page as a number at the bottom, just the previous and next links. All I need basically is to either get or output only 5 rows at a time, with only needing the $_GET['startrow'] variable. Can anyone help me? (or just throw me a link to an existing page/script) Thanks, Éric. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] next prev links for search result
> -Original Message- > From: Smita Manohar [mailto:[EMAIL PROTECTED]] > Sent: Monday, August 26, 2002 8:26 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] next prev links for search result > > > hiii.. > > i want page no. and next prev links while displaying search > result. the > script which im using presently, needs to run the search > query 2 times for > each search operation. > > first time it finds all the records matching the query string, > Change this query: > ie, select * from table where field like '%$search_string %' > To SELECT COUNT(*) AS num_hits FROM table WHERE field LIKE '%$search_string%' and let your MySQL-server do the counting. No need to transfer all data to PHP just to count the rows. You still have to run two queries, but I don't think you need to worry too much about performance issues, unless you have a really, really huge table. Regards Joakim Andersson -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] next prev links for search result
hiii.. i want page no. and next prev links while displaying search result. the script which im using presently, needs to run the search query 2 times for each search operation. first time it finds all the records matching the query string, ie, select * from table where field like '%$search_string %' then script stores total no. of records found. then it calculates no. of pages required to display the result using total no. of records and limit(no of records per page) then i need to run the same search query using limit. ie, select * from table where field like '%$search_sting %' limit $offset, $limit which find first few records (as per limit) to display. then loops have been used to display page no. and next previous navigation. in next prev links, i call the same file (php_self). that time i need to pass some values ie, $limt, $search_string. otherwise these values get vanish while running same script again. in case of simple search form i need to pass only $search_string. but im also having advance search form. now finding it difficult to pass the values which user selects for adv. search. and its becoming too complecated. also i don't want to run the same query 2 times. the solution for this which i'm thinking is like this after accepting search options from user, run the query and store the result in array. suppose that array contains 10 rows, means 10 records are found. and limit (no of records per page ) is 2. while displaying first page get only first 2 records from array (as per the limit) for the next link, get next 2 records ie, 3,4 from array and same way for prev link. with this logic i need to run the query once, and no need to pass any argument while running same script again. i don't know much abt array in php. so can't implement this idea. need solution and suggestions for this. hope, i could have explain my problem well :-) thnx and regds, smita. _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Next birthday?
On Fri, 8 Mar 2002, Robert V. Zwink wrote: > The simple answer might be: > > SELECT member.* > FROM `member` > WHERE DAYOFYEAR(member_dob) >= DAYOFYEAR(CURDATE()) > ORDER BY member_dob DESC LIMIT 1 > > Seems to work for me. Not for me. I think it should be ordered like this: ORDER BY DAYOFYEAR(member_dob) ASC Otherwise it will display the person who was born on 25th of March 1988 instead of the one born 11th of March 1980. Pls. correct me if I am wrong. Thanks & Cheers, Kristjan P.S. Pls. CC to [EMAIL PROTECTED] - I am only on the digest. > The problem is that it wouldn't support members that > have a birthday on the same day :) To solve that I would select the next > birthday from the 'member' table, then go back and select all the members > that have that birthday. It also would not support selecting January > birthdays in December (which might be a problem Dec 31). > > so you would actually need three queries: > SELECT member_dob > FROM `member` > WHERE DAYOFYEAR(member_dob) >= DAYOFYEAR(CURDATE()) > ORDER BY member_dob DESC LIMIT 1 > > if that returns 0 results, then you would likely be in December trying to > show the next birthday in January. Go back to the database starting with > January 1 and select brithdays starting at the begining of the year. > > SELECT member_dob > FROM `member` > WHERE DAYOFYEAR(member_dob) >= 0 > ORDER BY member_dob DESC LIMIT 1 > > then take that result and: > > SELECT member.* > FROM `member` > WHERE member_dob = '$result_from_previous_query' > ORDER BY last_name > > This really seems like overkill. This query would be much simpler if you > just showed everyone's birthday next month (or something like that). > > Robert Zwink > http://www.zwink.net/daid.php > > -Original Message- > From: Kristjan Kanarik [mailto:[EMAIL PROTECTED]] > Sent: Friday, March 08, 2002 5:30 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Next birthday? > > > I have a table called 'members' with a field (among many others) > 'member_dob' - the birthday of a particular member. The data type of this > field is date (-mm-dd). > > What I'd like to do now is to fetch one particular row from the database > (I am using MySQL 3.23.37) - namely the row of the member who is the next > one to have a birthday. Can this be done only with a advanced query or > should I fetch all rows and use PHP to find out who is the next one to > have a birthday? I'd prefer letting MySQL to do the job... > > Any ideas? > > TIA, > Kristjan > > P.S. Pls. CC to [EMAIL PROTECTED] as well - I am only on the digest. > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Next birthday?
The simple answer might be: SELECT member.* FROM `member` WHERE DAYOFYEAR(member_dob) >= DAYOFYEAR(CURDATE()) ORDER BY member_dob DESC LIMIT 1 Seems to work for me. The problem is that it wouldn't support members that have a birthday on the same day :) To solve that I would select the next birthday from the 'member' table, then go back and select all the members that have that birthday. It also would not support selecting January birthdays in December (which might be a problem Dec 31). so you would actually need three queries: SELECT member_dob FROM `member` WHERE DAYOFYEAR(member_dob) >= DAYOFYEAR(CURDATE()) ORDER BY member_dob DESC LIMIT 1 if that returns 0 results, then you would likely be in December trying to show the next birthday in January. Go back to the database starting with January 1 and select brithdays starting at the begining of the year. SELECT member_dob FROM `member` WHERE DAYOFYEAR(member_dob) >= 0 ORDER BY member_dob DESC LIMIT 1 then take that result and: SELECT member.* FROM `member` WHERE member_dob = '$result_from_previous_query' ORDER BY last_name This really seems like overkill. This query would be much simpler if you just showed everyone's birthday next month (or something like that). Robert Zwink http://www.zwink.net/daid.php -Original Message- From: Kristjan Kanarik [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 5:30 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Next birthday? I have a table called 'members' with a field (among many others) 'member_dob' - the birthday of a particular member. The data type of this field is date (-mm-dd). What I'd like to do now is to fetch one particular row from the database (I am using MySQL 3.23.37) - namely the row of the member who is the next one to have a birthday. Can this be done only with a advanced query or should I fetch all rows and use PHP to find out who is the next one to have a birthday? I'd prefer letting MySQL to do the job... Any ideas? TIA, Kristjan P.S. Pls. CC to [EMAIL PROTECTED] as well - I am only on the digest. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Next birthday?
I have a table called 'members' with a field (among many others) 'member_dob' - the birthday of a particular member. The data type of this field is date (-mm-dd). What I'd like to do now is to fetch one particular row from the database (I am using MySQL 3.23.37) - namely the row of the member who is the next one to have a birthday. Can this be done only with a advanced query or should I fetch all rows and use PHP to find out who is the next one to have a birthday? I'd prefer letting MySQL to do the job... Any ideas? TIA, Kristjan P.S. Pls. CC to [EMAIL PROTECTED] as well - I am only on the digest. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Next
Pass the current question number in a parameter to the next page in the URL. In the following, the PHP variable would track your current page: print "Next"; - then, in myform.php3: -Original Message- From: Peter Allum [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 14, 2001 3:38 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Next I am writing a questionaire, am gonna include java timer etc... and it is written in PHP 4 and Mysql running on Apache. I have my questionaire database full of questions I randomly select say 40 questions. But rather than display the whole array on the screen I would like to have 1 question per page and a next button. I hope that makes sense any ideas anyone? Many thanks for you halp in advance. Peter -- Regards, Peter Allum Connect U Ltd ** Confidentiality: This email and its attachments are intended for the above name only and may be confidential. If they have come to you in error you must take no action based upon them, nor must you copy or show them to anyone. Please reply to this email and highlight the error. Security Warning: Please note that this email has been created in the knowledge that Internet email is not a 100% secure medium. We advise that you understand and observe this lack of security when emailing us. Viruses: Although we have taken steps to ensure that this email and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free. [EMAIL PROTECTED] ** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Next
Use sessions. (session_start() and session_register()), and at the start of the test save row_ids(question_ids) in arrray which you make with session_register a session variable. On other pages you do session_start() and after that you have access to the array. Regards, Andrey Hristov IcyGEN Corporation http://www.icygen.com BALANCED SOLUTIONS - Original Message - From: "Peter Allum" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 14, 2001 11:37 AM Subject: [PHP-DB] Next > I am writing a questionaire, am gonna include java timer etc... and it is > written in PHP 4 and Mysql running on Apache. > > I have my questionaire database full of questions I randomly select say 40 > questions. But rather than display the whole array on the screen I would > like to have 1 question per page and a next button. I hope that makes sense > any ideas anyone? > > Many thanks for you halp in advance. > > Peter > > -- > Regards, > > > > > Peter Allum > Connect U Ltd > > ** > Confidentiality: This email and its attachments are intended for the above > name only and may be confidential. If they have come to you in error you > must take no action based upon them, nor must you copy or show them to > anyone. > Please reply to this email and highlight the error. > Security Warning: Please note that this email has been created in the > knowledge that Internet email is not a 100% secure medium. > We advise that you understand and observe this lack of security when > emailing us. > Viruses: Although we have taken steps to ensure that this email and > attachments are free from any virus, we advise that in keeping with good > computing practice the recipient should ensure they are actually virus free. > [EMAIL PROTECTED] > > ** > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Next
I am writing a questionaire, am gonna include java timer etc... and it is written in PHP 4 and Mysql running on Apache. I have my questionaire database full of questions I randomly select say 40 questions. But rather than display the whole array on the screen I would like to have 1 question per page and a next button. I hope that makes sense any ideas anyone? Many thanks for you halp in advance. Peter -- Regards, Peter Allum Connect U Ltd ** Confidentiality: This email and its attachments are intended for the above name only and may be confidential. If they have come to you in error you must take no action based upon them, nor must you copy or show them to anyone. Please reply to this email and highlight the error. Security Warning: Please note that this email has been created in the knowledge that Internet email is not a 100% secure medium. We advise that you understand and observe this lack of security when emailing us. Viruses: Although we have taken steps to ensure that this email and attachments are free from any virus, we advise that in keeping with good computing practice the recipient should ensure they are actually virus free. [EMAIL PROTECTED] ** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] NEXT - PREVIOUS coding
rough and readysomething like this should work... $pagesize = 20; $page = $page ? $page : 1; $pages = ceil(mysql_num_rows( $results ) / $pagesize ); mysql_data_seek( $results, ($page - 1) * $pagesize ); while( ($row = mysql_fetch_object( $results )) && ( $counter++ < $pagesize) ) { // print rows of data etc etc } if( ($page > 1) ) { print "Next"; } if( ($page < $pages) && ( $pages > 1 ) ) { print "Next"; } -Original Message- From: Pranot Kokate [mailto:[EMAIL PROTECTED]] Sent: 16 July 2001 09:40 To: [EMAIL PROTECTED] Subject: [PHP-DB] NEXT - PREVIOUS coding hi.. friends i have a database (mysql) in which their r many records. Through PHP i want them to display on the page. Main requirement is that there should be a NEXT - PREVIOUS facility. So if there r 20 records and suppose only 10 should show up on scren at a time, then a NEXT link should be visible which could show the remaining 10 records. Their can be n no. of records. Pls help. Kind Regards, Pranot -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] NEXT - PREVIOUS coding
hi.. friends i have a database (mysql) in which their r many records. Through PHP i want them to display on the page. Main requirement is that there should be a NEXT - PREVIOUS facility. So if there r 20 records and suppose only 10 should show up on scren at a time, then a NEXT link should be visible which could show the remaining 10 records. Their can be n no. of records. Pls help. Kind Regards, Pranot
Re: [PHP-DB] next & previous record
I don't know about "Cursors" but I think you can use the same approach we discussed on navigate record by record, " retrieval of NEXT, PREV records" was the subject. If set an order by clause and search for the first record you can use a where clause like this : ... $current = $row["field"] ; // for next row $query = "select * from table where field_name > '$current' limit 1"; // for previous row $query = "select * from table where field_name < '$current' limit 1"; HTH Jayme. www.conex.com.br/jjeffman/antispam.html -Mensagem Original- De: Andrew Hill <[EMAIL PROTECTED]> Para: Dreamvale <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Enviada em: quinta-feira, 22 de fevereiro de 2001 14:10 Assunto: RE: [PHP-DB] next & previous record > You want to use Cursors, and I don't believe MySQL supports cursors yet, > although I could be wrong. > > Best regards, > Andrew > -- > Andrew Hill - OpenLink Software > Director Technology Evangelism > eBusiness Infrastructure Technology > http://www.openlinksw.com > > > > -Original Message----- > > From: Dreamvale [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, February 22, 2001 11:42 AM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] next & previous record > > > > > > I was not refering pagination. > > > > suppossing there are these 3 records > > > > ABC > > DEF > > GHI > > LJK > > > > now a search is done by entering D, which using like & %, and limit would > > return the record DEF. The "next" would forward to GHI and > > "previous" would > > backward to ABC. > > > > any idea? > > > > thanks. > > > > > > - Original Message - > > From: "Brunner, Daniel" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Friday, February 23, 2001 12:12 AM > > Subject: FW: [PHP-DB] next & previous record > > > > > > > > Check this link out... > > > > http://www.oreillynet.com/pub/a/php/2000/11/02/next_previous.html?page > > > > =1 > > > > > > > > It's about Next/previous links... > > > > > > > > It does work, but I've yet to get to get it to work completely with > > > > displaying the records (rows) and the links at the same time... > > > > > > > > It just takes some time to find how to use the mysql_query variable to > > > > print out the rows, with every click of the link.. > > > > > > > > If you get any head way let me know... > > > > > > > > It's great code > > > > > > > > Dan > > > > > > > > > > > > > > > > -- > > > > From: Dreamvale > > > > Sent: Thursday, February 22, 2001 9:55 AM > > > > To: [EMAIL PROTECTED] > > > > Subject: [PHP-DB] next & previous record > > > > > > > > hi all, > > > > > > > > need to implement record scrolling, one at a time -either forward or > > > > backward, on MySQL. The key is a char (32) containing part numbers. > > > > > > > > anyone has done this before? > > > > > > > > thanks in advance. > > > > > > > > dreamvale > > > > > > > > > > > > -- > > > > PHP Database Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > To contact the list administrators, e-mail: > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] next & previous record
Keep a counter of the rows you have fetched. so when you want to go back call mysql_data_seek ($Result, Counter-1); then mysql_fetch and you've got the previous row. Lennin Arriola [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] next & previous record
You want to use Cursors, and I don't believe MySQL supports cursors yet, although I could be wrong. Best regards, Andrew -- Andrew Hill - OpenLink Software Director Technology Evangelism eBusiness Infrastructure Technology http://www.openlinksw.com > -Original Message- > From: Dreamvale [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 22, 2001 11:42 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] next & previous record > > > I was not refering pagination. > > suppossing there are these 3 records > > ABC > DEF > GHI > LJK > > now a search is done by entering D, which using like & %, and limit would > return the record DEF. The "next" would forward to GHI and > "previous" would > backward to ABC. > > any idea? > > thanks. > > > - Original Message - > From: "Brunner, Daniel" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, February 23, 2001 12:12 AM > Subject: FW: [PHP-DB] next & previous record > > > > > Check this link out... > > > http://www.oreillynet.com/pub/a/php/2000/11/02/next_previous.html?page > > > =1 > > > > > > It's about Next/previous links... > > > > > > It does work, but I've yet to get to get it to work completely with > > > displaying the records (rows) and the links at the same time... > > > > > > It just takes some time to find how to use the mysql_query variable to > > > print out the rows, with every click of the link.. > > > > > > If you get any head way let me know... > > > > > > It's great code > > > > > > Dan > > > > > > > > > > > > -- > > > From: Dreamvale > > > Sent: Thursday, February 22, 2001 9:55 AM > > > To: [EMAIL PROTECTED] > > > Subject: [PHP-DB] next & previous record > > > > > > hi all, > > > > > > need to implement record scrolling, one at a time -either forward or > > > backward, on MySQL. The key is a char (32) containing part numbers. > > > > > > anyone has done this before? > > > > > > thanks in advance. > > > > > > dreamvale > > > > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > To contact the list administrators, e-mail: > > > [EMAIL PROTECTED] > > > > > > > > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] next & previous record
I was not refering pagination. suppossing there are these 3 records ABC DEF GHI LJK now a search is done by entering D, which using like & %, and limit would return the record DEF. The "next" would forward to GHI and "previous" would backward to ABC. any idea? thanks. - Original Message - From: "Brunner, Daniel" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, February 23, 2001 12:12 AM Subject: FW: [PHP-DB] next & previous record > > Check this link out... > > http://www.oreillynet.com/pub/a/php/2000/11/02/next_previous.html?page > > =1 > > > > It's about Next/previous links... > > > > It does work, but I've yet to get to get it to work completely with > > displaying the records (rows) and the links at the same time... > > > > It just takes some time to find how to use the mysql_query variable to > > print out the rows, with every click of the link.. > > > > If you get any head way let me know... > > > > It's great code.... > > > > Dan > > > > > > > > -- > > From: Dreamvale > > Sent: Thursday, February 22, 2001 9:55 AM > > To: [EMAIL PROTECTED] > > Subject: [PHP-DB] next & previous record > > > > hi all, > > > > need to implement record scrolling, one at a time -either forward or > > backward, on MySQL. The key is a char (32) containing part numbers. > > > > anyone has done this before? > > > > thanks in advance. > > > > dreamvale > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: > > [EMAIL PROTECTED] > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
FW: [PHP-DB] next & previous record
> Check this link out... > http://www.oreillynet.com/pub/a/php/2000/11/02/next_previous.html?page > =1 > > It's about Next/previous links... > > It does work, but I've yet to get to get it to work completely with > displaying the records (rows) and the links at the same time... > > It just takes some time to find how to use the mysql_query variable to > print out the rows, with every click of the link.. > > If you get any head way let me know... > > It's great code > > Dan > > > > -- > From: Dreamvale > Sent: Thursday, February 22, 2001 9:55 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] next & previous record > > hi all, > > need to implement record scrolling, one at a time -either forward or > backward, on MySQL. The key is a char (32) containing part numbers. > > anyone has done this before? > > thanks in advance. > > dreamvale > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: > [EMAIL PROTECTED] > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] next & previous record
hi all, need to implement record scrolling, one at a time -either forward or backward, on MySQL. The key is a char (32) containing part numbers. anyone has done this before? thanks in advance. dreamvale -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]