|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Thu Sep 20 2007 - 01:51:49 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 20 Sep 2007 06:51:49 -0000 Issue 5028
Topics (messages 262252 through 262267):
Re: Page Numbering
262252 by: Dan Shirah
262253 by: Jim Lucas
262259 by: Andrew Wilson
262260 by: Jim Lucas
[SOLVED] Page Numbering
262254 by: Dan Shirah
262255 by: Jim Lucas
Format_number and input_object_tag
262256 by: Augusto Morais
Re: Finding next recored in a array
262257 by: brian
Open New URL window
262258 by: Andrew Prostko
262261 by: Jim Lucas
262262 by: Richard S. Crawford
262267 by: Andrew Prostko
Re: back on bug 42065 , strange behavior with ArrayObject
262263 by: Chris
Re: my paging task with PHP does not work. It uses cookie.
262264 by: Patrik Hasibuan
262265 by: Patrik Hasibuan
262266 by: Patrik Hasibuan
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Whenever the query has the NOT IN included in it, I get the following error:
Warning: mssql_query()
[function.mssql-query<http://develop1/credit%20card%20processing/Process/function.mssql-query>]:
message: Incorrect syntax near the keyword 'as'. (severity 15)
On 9/19/07, Jim Lucas <lists
cmsws.com> wrote:
>
> Dan Shirah wrote:
> > Hello all,
> >
> > I am having a problem with trying to display a set amount of records
> from my
> > result.
> > I have verified that the correct values for my variables are being
> passed to
> > the query.
> > The calculation for the records that should be displayed per page is
> > correct.
> > The total number of records returned from my query is correct.
> > And the calculated number of total pages to be displayed is correct.
> >
> > So, initially it displays the first 10 results as it should, and has the
> > pages numbers at the bottom. The problem is, when I click on a
> different
> > page number the same 10 results are ALWAYS displayed. Even though my
> $page
> > variable IS being updated.
> >
> > Any ideas why my results are not reflecting the page I select?
> >
>
> I would do it like this
>
> This assumes that 'credit_card_id' is unique,
>
> if it is not, then don't worry about reading the rest
>
> <?php
>
> # Get page number if passed to script
> $page = intval( empty($_GET['page']) ? 1 : $_GET['page'] );
>
> # Set number of rows to display from result set
> $max_results = 10;
>
> # Calculate the number of results that we have already looked at
> $page_results = intval(($page*$max_results)-$max_results);
>
> # Set your ORDER BY criteria. This needs to be the same for each SQL
> statement
> # This is why I have setup a variable, so no mistakes will be made
> $order_by_criteria = 'credit_card_id';
>
> # Figure out which SQL statement we need to use
> if ( $page === 1 ) {
>
> # Query for page 1
> $SQL = "SELECT TOP {$max_results}
> Value1, Value2
> FROM my_table
> ORDER BY {$order_by_criteria}";
>
> } else {
>
> # Query for page 2 and greater
> $SQL = "SELECT TOP {$max_results}
> Value1, Value2
> FROM my_table
> WHERE credit_card_id NOT IN (
> SELECT TOP {$page_results}
> credit_card_id
> FROM my_table
> WHERE my_table.column = 'P'
> ORDER BY {$order_by_criteria}
> ) AS newtbl
> ORDER BY {$order_by_criteria}";
>
> }
>
> ... run your $SQL statement here and work with the results
> ?>
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
>
>
attached mail follows:
Dan Shirah wrote:
> Whenever the query has the NOT IN included in it, I get the following error:
>
> Warning: mssql_query()
> [function.mssql-query<http://develop1/credit%20card%20processing/Process/function.mssql-query>]:
> message: Incorrect syntax near the keyword 'as'. (severity 15)
>
>>
>> <?php
>>
>> # Get page number if passed to script
>> $page = intval( empty($_GET['page']) ? 1 : $_GET['page'] );
>>
>> # Set number of rows to display from result set
>> $max_results = 10;
>>
>> # Calculate the number of results that we have already looked at
>> $page_results = intval(($page*$max_results)-$max_results);
>>
>> # Set your ORDER BY criteria. This needs to be the same for each SQL
>> statement
>> # This is why I have setup a variable, so no mistakes will be made
>> $order_by_criteria = 'credit_card_id';
>>
>> # Figure out which SQL statement we need to use
>> if ( $page === 1 ) {
>>
>> # Query for page 1
>> $SQL = "SELECT TOP {$max_results}
>> Value1, Value2
>> FROM my_table
>> ORDER BY {$order_by_criteria}";
>>
>> } else {
>>
>> # Query for page 2 and greater
>> $SQL = "SELECT TOP {$max_results}
>> Value1, Value2
>> FROM my_table
>> WHERE credit_card_id NOT IN (
>> SELECT TOP {$page_results}
>> credit_card_id
>> FROM my_table
>> WHERE my_table.column = 'P'
>> ORDER BY {$order_by_criteria}
>> ) AS newtbl
yup, sorry, missed that in the copy/paste remove the 'AS newtbl' part
>> ORDER BY {$order_by_criteria}";
>>
>> }
>>
>> ... run your $SQL statement here and work with the results
>> ?>
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
attached mail follows:
What do I have to do to get off this list. Murder someone?
Please take me off the list as I have already tried to unsubscribe several
times.
The email is registered under will
netwaynetworks.com.au
-----Original Message-----
From: Jim Lucas [mailto:lists
cmsws.com]
Sent: Thursday, September 20, 2007 4:03 AM
To: Dan Shirah
Cc: php-general
Subject: Re: [PHP] Page Numbering
Dan Shirah wrote:
> Whenever the query has the NOT IN included in it, I get the following
error:
>
> Warning: mssql_query()
>
[function.mssql-query<http://develop1/credit%20card%20processing/Process/fun
ction.mssql-query>]:
> message: Incorrect syntax near the keyword 'as'. (severity 15)
>
>>
>> <?php
>>
>> # Get page number if passed to script $page = intval(
>> empty($_GET['page']) ? 1 : $_GET['page'] );
>>
>> # Set number of rows to display from result set $max_results = 10;
>>
>> # Calculate the number of results that we have already looked at
>> $page_results = intval(($page*$max_results)-$max_results);
>>
>> # Set your ORDER BY criteria. This needs to be the same for each SQL
>> statement # This is why I have setup a variable, so no mistakes will
>> be made $order_by_criteria = 'credit_card_id';
>>
>> # Figure out which SQL statement we need to use if ( $page === 1 ) {
>>
>> # Query for page 1
>> $SQL = "SELECT TOP {$max_results}
>> Value1, Value2
>> FROM my_table
>> ORDER BY {$order_by_criteria}";
>>
>> } else {
>>
>> # Query for page 2 and greater $SQL = "SELECT TOP
>> {$max_results}
>> Value1, Value2
>> FROM my_table
>> WHERE credit_card_id NOT IN (
>> SELECT TOP {$page_results}
>> credit_card_id
>> FROM my_table
>> WHERE my_table.column = 'P'
>> ORDER BY {$order_by_criteria}
>> ) AS newtbl
yup, sorry, missed that in the copy/paste remove the 'AS newtbl' part
>> ORDER BY {$order_by_criteria}";
>>
>> }
>>
>> ... run your $SQL statement here and work with the results ?>
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
attached mail follows:
Andrew Wilson wrote:
> What do I have to do to get off this list. Murder someone?
> Please take me off the list as I have already tried to unsubscribe several
> times.
>
> The email is registered under will
netwaynetworks.com.au
>
> -----Original Message-----
> From: Jim Lucas [mailto:lists
cmsws.com]
> Sent: Thursday, September 20, 2007 4:03 AM
> To: Dan Shirah
> Cc: php-general
> Subject: Re: [PHP] Page Numbering
>
> Dan Shirah wrote:
>> Whenever the query has the NOT IN included in it, I get the following
> error:
>> Warning: mssql_query()
>>
> [function.mssql-query<http://develop1/credit%20card%20processing/Process/fun
> ction.mssql-query>]:
>> message: Incorrect syntax near the keyword 'as'. (severity 15)
>>
>>> <?php
>>>
>>> # Get page number if passed to script $page = intval(
>>> empty($_GET['page']) ? 1 : $_GET['page'] );
>>>
>>> # Set number of rows to display from result set $max_results = 10;
>>>
>>> # Calculate the number of results that we have already looked at
>>> $page_results = intval(($page*$max_results)-$max_results);
>>>
>>> # Set your ORDER BY criteria. This needs to be the same for each SQL
>>> statement # This is why I have setup a variable, so no mistakes will
>>> be made $order_by_criteria = 'credit_card_id';
>>>
>>> # Figure out which SQL statement we need to use if ( $page === 1 ) {
>>>
>>> # Query for page 1
>>> $SQL = "SELECT TOP {$max_results}
>>> Value1, Value2
>>> FROM my_table
>>> ORDER BY {$order_by_criteria}";
>>>
>>> } else {
>>>
>>> # Query for page 2 and greater $SQL = "SELECT TOP
>>> {$max_results}
>>> Value1, Value2
>>> FROM my_table
>>> WHERE credit_card_id NOT IN (
>>> SELECT TOP {$page_results}
>>> credit_card_id
>>> FROM my_table
>>> WHERE my_table.column = 'P'
>>> ORDER BY {$order_by_criteria}
>>> ) AS newtbl
>
> yup, sorry, missed that in the copy/paste remove the 'AS newtbl' part
>
>>> ORDER BY {$order_by_criteria}";
>>>
>>> }
>>>
>>> ... run your $SQL statement here and work with the results ?>
>
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
Well, it looks like you are using the wrong email address.
The email address that you used to send this email was from
andrew
netwaynetworks.com.au
and the email address that you are trying to unsubscribe is
will
netwaynetworks.com.au
which is it?
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
attached mail follows:
Awesome.
I just had to modify the outter query:
$SQL = "SELECT TOP {$max_results}
Value1, Value2
FROM my_table
WHERE credit_card_id NOT IN (
To read:
$SQL = "SELECT TOP {$max_results}
Value1, Value2
FROM my_table
WHERE my_table.column = 'P'
AND credit_card_id NOT IN (
And it works like a champ.
Thank you very much to everyone that helped me on this!
On 9/19/07, Jim Lucas <lists
cmsws.com> wrote:
>
> Dan Shirah wrote:
> > Whenever the query has the NOT IN included in it, I get the following
> error:
> >
> > Warning: mssql_query()
> > [function.mssql-query<
> http://develop1/credit%20card%20processing/Process/function.mssql-query>]:
> > message: Incorrect syntax near the keyword 'as'. (severity 15)
> >
> >>
> >> <?php
> >>
> >> # Get page number if passed to script
> >> $page = intval( empty($_GET['page']) ? 1 : $_GET['page'] );
> >>
> >> # Set number of rows to display from result set
> >> $max_results = 10;
> >>
> >> # Calculate the number of results that we have already looked at
> >> $page_results = intval(($page*$max_results)-$max_results);
> >>
> >> # Set your ORDER BY criteria. This needs to be the same for each SQL
> >> statement
> >> # This is why I have setup a variable, so no mistakes will be made
> >> $order_by_criteria = 'credit_card_id';
> >>
> >> # Figure out which SQL statement we need to use
> >> if ( $page === 1 ) {
> >>
> >> # Query for page 1
> >> $SQL = "SELECT TOP {$max_results}
> >> Value1, Value2
> >> FROM my_table
> >> ORDER BY {$order_by_criteria}";
> >>
> >> } else {
> >>
> >> # Query for page 2 and greater
> >> $SQL = "SELECT TOP {$max_results}
> >> Value1, Value2
> >> FROM my_table
> >> WHERE credit_card_id NOT IN (
> >> SELECT TOP {$page_results}
> >> credit_card_id
> >> FROM my_table
> >> WHERE my_table.column = 'P'
> >> ORDER BY {$order_by_criteria}
> >> ) AS newtbl
>
> yup, sorry, missed that in the copy/paste remove the 'AS newtbl' part
>
> >> ORDER BY {$order_by_criteria}";
> >>
> >> }
> >>
> >> ... run your $SQL statement here and work with the results
> >> ?>
>
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare
>
>
attached mail follows:
Dan Shirah wrote:
> Awesome.
>
> I just had to modify the outter query:
>
> $SQL = "SELECT TOP {$max_results}
> Value1, Value2
> FROM my_table
> WHERE credit_card_id NOT IN (
>
> To read:
>
> $SQL = "SELECT TOP {$max_results}
> Value1, Value2
> FROM my_table
> WHERE my_table.column = 'P'
> AND credit_card_id NOT IN (
>
> And it works like a champ.
>
> Thank you very much to everyone that helped me on this!
>
>
>
> On 9/19/07, Jim Lucas <lists
cmsws.com> wrote:
>> Dan Shirah wrote:
>>> Whenever the query has the NOT IN included in it, I get the following
>> error:
>>> Warning: mssql_query()
>>> [function.mssql-query<
>> http://develop1/credit%20card%20processing/Process/function.mssql-query>]:
>>> message: Incorrect syntax near the keyword 'as'. (severity 15)
>>>
>>>> <?php
>>>>
>>>> # Get page number if passed to script
>>>> $page = intval( empty($_GET['page']) ? 1 : $_GET['page'] );
>>>>
>>>> # Set number of rows to display from result set
>>>> $max_results = 10;
>>>>
>>>> # Calculate the number of results that we have already looked at
>>>> $page_results = intval(($page*$max_results)-$max_results);
>>>>
>>>> # Set your ORDER BY criteria. This needs to be the same for each SQL
>>>> statement
>>>> # This is why I have setup a variable, so no mistakes will be made
>>>> $order_by_criteria = 'credit_card_id';
>>>>
>>>> # Figure out which SQL statement we need to use
>>>> if ( $page === 1 ) {
>>>>
>>>> # Query for page 1
>>>> $SQL = "SELECT TOP {$max_results}
>>>> Value1, Value2
>>>> FROM my_table
>>>> ORDER BY {$order_by_criteria}";
>>>>
>>>> } else {
>>>>
>>>> # Query for page 2 and greater
>>>> $SQL = "SELECT TOP {$max_results}
>>>> Value1, Value2
>>>> FROM my_table
>>>> WHERE credit_card_id NOT IN (
>>>> SELECT TOP {$page_results}
>>>> credit_card_id
>>>> FROM my_table
>>>> WHERE my_table.column = 'P'
>>>> ORDER BY {$order_by_criteria}
>>>> ) AS newtbl
>> yup, sorry, missed that in the copy/paste remove the 'AS newtbl' part
>>
>>>> ORDER BY {$order_by_criteria}";
>>>>
>>>> }
>>>>
>>>> ... run your $SQL statement here and work with the results
>>>> ?>
>>
>> --
>> Jim Lucas
>>
>> "Some men are born to greatness, some achieve greatness,
>> and some have greatness thrust upon them."
>>
>> Twelfth Night, Act II, Scene V
>> by William Shakespeare
>>
>>
>
just noticed that I missed that where clause in the page 1 query also. make sure you add that.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
attached mail follows:
Hi,
I have 2 problems.
First: When an user type a number that have comma the numbers after of
comma doesnt safe.
example:
the user wants save the number:
10,85
I dont know but the symfony just save the number 10. The 85 is ignored.
How i fix it ?
Second problem:
i'm trying format a number in the object_input_tag . How i do it ?
<?php $value = object_input_tag($estoque_entrada, 'getPrecoUnitario',
array (
'size' => 23,
'control_name' => 'estoque_entrada[preco_unitario]',
)); echo $value ? $value : ' ' ?>
the correct way is change the getPrecoUnitario function in
actions.class.php ?
thanks
Augusto Morais
attached mail follows:
tedd wrote:
> At 11:52 AM -0400 9/17/07, brian wrote:
>
>> tedd wrote:
>>
>>> Richard Kurth wrote:
>>>
>>>> $Campaign_array| = array('0','1','3','5','8','15','25');|
>>>> I know that I can find the next recored in a array using next. What
>>>> I do not understand is if I know the last number was say 5 how do I
>>>> tell the script that that is the current number so I can select the
>>>> next record
>>>
>>>
>>>
>>> What the next record?
>>>
>>> Try:
>>>
>>> $array = array('0','1','3','5','8','15','25');
>>> $val = "5";
>>>
>>> echo($array[array_search($val, $array)+1]);
>>>
>>> Cheers,
>>>
>>> tedd
>>
>>
>> Not quite:
>>
>> $array = array('0','1','3','5','8','15','25');
>> $val = "25";
>>
>> echo($array[array_search($val, $array)+1]);
>>
>> Notice: Undefined offset: 7 ...
>>
>> brian
>
>
> Duh?
>
> You program for that -- you want me to write the entire code?
>
~sigh~
Grasshopper, the point i was trying to make is that your example
displays what *not* to do with array_search(). Though a wonderful
teaching aid in itself, it falls somewhat short of being a reasonable
solution for the OP.
brian
attached mail follows:
I am new to PHP and to email lists so I apologize in advance.
What I am trying to do is to take a password from user input, check
it to make sure it is == to something, say “burgers”
My problem is, I do not know how to make the Else statement...
How do I get it to open a new url?
I want it IF yes open this page, else open this page
or
If it is not correct then Say the password is incorrect or
something…
Else
Open a different webpage
My last attempt:
---------------
<BODY onLoad="top.window.focus()">
<?php
// Define your password
$password = "burgers";
if ($_POST['pw'] != $password) {
?>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR>
<TD ROWSPAN=2 WIDTH=50%>
<img src="images/charlee.gif">
</TD>
<TD WIDTH=50% ALIGN=CENTER VALIGN=MIDDLE>
<FONT FACE="ARIAL" SIZE=2><B>You'll need a password to get in here. We're
tryin' to keep out the
riff-raff.</B></FONT><BR>
</TD>
</TR>
<TR>
<TD WIDTH=50% ALIGN=CENTER VALIGN=BOTTOM>
<CENTER>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<br />
Name: <input type="text" name="Name" />
<br />
Email: <input type="text name="email" />
<br />
What is the Current Coupon Password?: <input type="text" name="pw" />
<input type="submit" value="Get Coupon!"/>
</form>
<A HREF="index.html" TARGET="_blank"><B>Return to Char-lees</B></A></FONT>
</CENTER>
</TD>
</TR>
</TABLE>
<?php
}
else{
$file = fopen("http://www.google.com/","r";
?>
<?php
} ?>
---------------
This creates a nice small form with an image to the left.
My problem is, I do not know how to make the Else statement...
How do I get it to open a new url?
I want it IF yes open this page, else open this page
Andrew Prostko
AProstko
verizon.net
attached mail follows:
Andrew Prostko wrote:
> I am new to PHP and to email lists so I apologize in advance.
>
>
> What I am trying to do is to take a password from user input, check
> it to make sure it is == to something, say “burgers”
>
> My problem is, I do not know how to make the Else statement...
> How do I get it to open a new url?
> I want it IF yes open this page, else open this page
> or
> If it is not correct then Say the password is incorrect or
> something…
> Else
> Open a different webpage
>
> My last attempt:
> ---------------
> <BODY onLoad="top.window.focus()">
>
> <?php
>
> // Define your password
> $password = "burgers";
>
> if ($_POST['pw'] != $password) {
>
> ?>
> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
>
> <TR>
> <TD ROWSPAN=2 WIDTH=50%>
>
> <img src="images/charlee.gif">
> </TD>
> <TD WIDTH=50% ALIGN=CENTER VALIGN=MIDDLE>
> <FONT FACE="ARIAL" SIZE=2><B>You'll need a password to get in here. We're
> tryin' to keep out the
>
> riff-raff.</B></FONT><BR>
> </TD>
> </TR>
> <TR>
> <TD WIDTH=50% ALIGN=CENTER VALIGN=BOTTOM>
> <CENTER>
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
> <br />
> Name: <input type="text" name="Name" />
> <br />
> Email: <input type="text name="email" />
> <br />
> What is the Current Coupon Password?: <input type="text" name="pw" />
> <input type="submit" value="Get Coupon!"/>
> </form>
> <A HREF="index.html" TARGET="_blank"><B>Return to Char-lees</B></A></FONT>
> </CENTER>
> </TD>
> </TR>
> </TABLE>
>
> <?php
> }
> else{
>
> $file = fopen("http://www.google.com/","r";
>
> ?>
>
> <?php
> } ?>
> ---------------
>
> This creates a nice small form with an image to the left.
>
> My problem is, I do not know how to make the Else statement...
> How do I get it to open a new url?
> I want it IF yes open this page, else open this page
>
> Andrew Prostko
> AProstko
verizon.net
>
>
You might be in need of the header() function in php
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
attached mail follows:
On Wednesday 19 September 2007 15:50:08 Andrew Prostko wrote:
> My problem is, I do not know how to make the Else statement...
> How do I get it to open a new url?
> I want it IF yes open this page, else open this page
Andrew,
try the header() function:
<?php
if ($_POST['pw'] != $password) {
?>
...show your form...
<?php
} else {
header ("otherpage.php");
}
One problem you might be having is that the < body > tag at the very top might
be sending headers to your browser before your else statement has a chance to
kick in, generating an error which reads something like, "Headers already
sent..." Try moving it to after the conditional, like this:
<?php
if ($_POST['pw'] != $password) {
?>
< BODY onLoad="top.window.focus()" >
...rest of your form...
<?php
} else {
...and so on.
--
Richard S. Crawford
Editor-in-chief, Daikaijuzine (http://www.daikaijuzine.com)
Personal website: http://www.mossroot.com
http://www.myspace.com/underpope / underpope.livejournal.com
"We are here to help each other get through this thing, whatever it is."
(Kurt Vonnegut, 1922 - 2007)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQBG8bwj0Q4njIwYM+oRAnx7AJ9Mdo/5qjv+GfAhZQEaQAEmmw46ywCfQ/g+
DIMmu/4IGtcWWZEU97Y7o0E=
=RGOr
-----END PGP SIGNATURE-----
attached mail follows:
Ok, so I started using the header code that was suggested:
And I get this error:
Parse error: parse error, unexpected '{' in
/home/char-lee/public_html/beta/1.php on line 3
This is the code:
-----------
<?php
if ($_POST['pw'] != burgers
{
header("Location: password.php");
}
else
{
header("Location: sept-coupon07.html");
}
?>
-----------
attached mail follows:
Julien Pauli wrote:
> Wow, all right ; that's why casting to (array) before passing the
> variable , thus making a copy of it, works.
> Thanks for that short but effective answer ;-)
>
> However, except in the comments, this is not said in the original doc.
> It should be written
> ArrayObject ArrayObject::__construct ( mixed &$input )
> shouldn't it ?
I guess it's time to post a documentation bug :) I'm sure they'd also
appreciate a patch if possible.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Hi Arvid,
thank you very much for your remark. It is useful for me.
===
On Fri, 14 Sep 2007 12:01:40 +0300
"Arvids Godjuks" <arvids.godjuks
gmail.com> wrote:
> Don't use SQL_CALC_FOUND ROWS on simple queries, when you have to run a
> simple query on one or two (with join) tables with a simple WHERE. Especialy
> if tables are big. I found out that single SELECT COUNT(id) FROM table is
> far more faster when query has simple WHERE conditions. I use
> SQL_CALC_FOUND_ROWS only with a rather complex queries - that
> SQL_CALC_FOUND_ROWS doesn't affect query execution at all (well, it affects
> ofcourse, but affect is so small, you can't see it).
>
--
Patrik Hasibuan <patrikh
penguin-teknologi.com>
Junior Programmer
attached mail follows:
Dear Brian,
My problem is solved. thank you very much for your help.
===
On Wed, 12 Sep 2007 14:04:11 -0400
brian <phplist
subtropolix.org> wrote:
> Patrik Hasibuan wrote:
> > Dear my friends...
> >
> > I am trying to display the content of a table. Each page must content
> > only 5 records maximum. Each page has "Previous" and "Next" buttons
> > (made from anchor).
> >
> > I dump the primary of the working table and keep it in a cookie. So
> > than the paging task work with the index of cookie array. But the
> > $curguruescomidiklan stays "0" each time I click "Next" button.
> >
>
> Patrick, i can't say what the problem is, but i recommend using the PEAR
> Pager package for this if you have PEAR available. It takes care of a
> lot of the heavy lifting and is very configurable.
>
> http://pear.php.net/package/Pager
>
> This does not require setting any cookies.
>
> brian
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
Patrik Hasibuan <patrikh
penguin-teknologi.com>
Junior Programmer
attached mail follows:
Dear mike,
your thread solved my problem.
I really appreciate your help.
Thank you very much.
On Thu, 13 Sep 2007 14:49:29 -0700
mike <mike503
gmail.com> wrote:
> warning: this is VERY UGLY CODE. i wrote it 3-4 years ago now i think
> and it just keeps working.
>
> you call it this way:
>
> # pagination.
> if(isset($_GET['pg'])) {
> $page = intval($_GET['pg']);
> } else {
> $page = 1;
> }
> $page = sprintf("%02d",$page);
>
> $query = Array(
> 'query' => "SELECT foo FROM bar",
> 'itemsperpage' => 50,
> 'maxdisplay' => 20,
> 'linkprefix' => "$_SERVER[PHP_SELF]?f=$forum_id&pg="
> );
> list($pages,$numpages,$items,$threads) = paginate_sql($page,$query);
>
> $pages is the html formatted links
> $numpages is the total number of pages
> i dont actually use $items much but i think it just tells you how many
> items (which is the same as itemsperpage... i believe)
> $threads is the mysql rows resource (you can use mysql_fetch_rows on it)
>
>
>
> function paginate_sql(&$thispage,$options) {
> $offset = $options['itemsperpage'] * ($thispage - 1);
> if(isset($options['server'])) {
> $results = db_query(eregi_replace("^SELECT","SELECT
> SQL_CALC_FOUND_ROWS",$options['query'])."LIMIT
> $offset,$options[itemsperpage]",$options['server']);
> $rows = db_query("SELECT FOUND_ROWS()",$options['server']);
> } else {
> $results = db_query(eregi_replace("^SELECT","SELECT
> SQL_CALC_FOUND_ROWS",$options['query'])."LIMIT
> $offset,$options[itemsperpage]");
> $rows = db_query("SELECT FOUND_ROWS()");
> }
> list($totalitems) = db_rows($rows);
> db_free($rows);
> $html = "";
> $numpages = ceil($totalitems / $options['itemsperpage']);
> if(isset($options['maxpages']) && $numpages >
> $options['maxpages']) { $numpages = $options['maxpages']; }
> if($thispage < 1 || $totalitems < $options['itemsperpage']) {
> $thispage = sprintf("%02d",1); }
> if($thispage > $numpages && $numpages > 0) {
> header(sprintf("Location: %s01",
> str_replace("&","&",$options['linkprefix'])));
> exit();
> }
> $start = (ceil($thispage / $options['maxdisplay'])-1) *
> $options['maxdisplay'] + 1;
> if($start == 1) {
> $html .= "«";
> } else {
> $html .= sprintf("<a href=\"%s%02d\">«</a>",
> $options['linkprefix'], $start-1);
> }
> if(isset($options['maxdisplay']) && $options['maxdisplay'] !=
> 0 && $numpages > $options['maxdisplay']) {
> $numlist = $options['maxdisplay'] + $start - 1;
> } else {
> $numlist = $numpages + $start - 1;
> }
> if($numlist > $numpages) { $numlist = $numpages; }
> for($x=$start; $x<=$numlist; $x++) {
> if($x == $thispage) {
> $html .= sprintf(" %02d", $x);
> } else {
> $html .= sprintf(" <a
> href=\"%s%02d\">%02d</a>", $options['linkprefix'], $x, $x);
> }
> }
> if($numlist == $numpages) {
> $html .= " »";
> } else {
> $html .= sprintf(" <a href=\"%s%02d\">»</a>",
> $options['linkprefix'], $numlist+1);
> }
> if($totalitems <= $options['itemsperpage']) { $html = ""; }
> return Array($html,sprintf("%02d",$numpages),$totalitems,$results);
> }
>
> On 9/13/07, Patrik Hasibuan <patrikh
penguin-teknologi.com> wrote:
> > Hi Mike,
> >
> > I am intrested for the solution you gave me. But I am confused of the way in implementing "select FOUND_ROWS()".
> >
> > I wrote another very simple codes as the first step for understanding this threat:
> > <?php
> > $konek=mysql_connect("127.0.0.1","root","mypassword");
> > if ($konek){
> > for ($i=0;$i<2;$i++){
> > $sqlku="select SQL_CALC_FOUND_ROWS id_iklan from lowongan limit 5;";
> > $sqlkupage="select FOUND_ROWS()";
> > $mybd=mysql_select_db("headhunter",$konek);
> > $kueri=mysql_query($sqlku,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] '.mysql_error($konek));
> > $kueri=mysql_query($sqlkupage,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] '.mysql_error($konek));
> > while($brs=mysql_fetch_row($kueri)){
> > list($idiklan)=$brs;
> > echo "FirstItem <a href=\"showit.php?id=$idiklan\">$idiklan</a><br>";
> > }
> > }
> > }else{
> > echo "I can't talk to the server<br>";
> > exit();
> > }
> > ?>
> >
> > I've put nine records into the table of "lowongan", idiklan 1 to 9.
> > Look I get of course only one record, namely the: '9'.
> >
> > This is the output of my codes in my internet browser.
> > ===
> > FirstItem 9
> > FirstItem 9
> > ===
> > The output what I am expecting suppose to be:
> > on the $i=0
> > "
> > FirstItem 1
> > FirstItem 2
> > FirstItem 3
> > FirstItem 4
> > FirstItem 5
> > "
> > and on the $i=1
> > "
> > FirstItem 6
> > FirstItem 7
> > FirstItem 8
> > FirstItem 9
> > FirstItem 9
> > "
> >
> > I read on the documentation of MySQL but I couldn't find any code of sample also in the php.net.
> >
> > Would be so kind to give me a very simple code of sample?
> >
> > Thank you very much in advance.
> > On Wed, 12 Sep 2007 11:58:04 -0700
> > mike <mike503
gmail.com> wrote:
> >
> > > On 9/12/07, Patrik Hasibuan <patrikh
penguin-teknologi.com> wrote:
> > > > Dear my friends...
> > > >
> > > > I am trying to display the content of a table. Each page must content only 5 records maximum. Each page has "Previous" and "Next" buttons (made from anchor).
> > > >
> > > > I dump the primary of the working table and keep it in a cookie. So than the paging task work with the index of cookie array. But the $curguruescomidiklan stays "0" each time I click "Next" button.
> > >
> > > yeah there is no reason to be using cookies for this.
> > >
> > > just using query string parameters should work. for pagination you need to know:
> > >
> > > total number of items
> > > number of items per page
> > >
> > > after that you know how many pages (numitems / itemsperpage) and work
> > > out the links appropriately (i.e. page1 has no previous, $maxpage has
> > > no next) and you can put the number of pages down how you want (if you
> > > want to do prev 3 4 5 next, or next 1 2 3 4 5 6 7 8 9 prev, there's a
> > > ton of strategies to print out what pages to show, and next, previous,
> > > jump to end, jump to beginning, etc)
> > >
> > > i've never used the PEAR class or anything else, i made a function a
> > > long time ago that actually works in conjunction with mysql's SELECT
> > > FOUND_ROWS() and uses a LIMIT offset,number to save the overhead of
> > > fetching every row from the database to only show the ones for that
> > > page. it's actually worked well for 4 years now without a single
> > > change...
> > >
> > > at some point perhaps i'll clean it up and post it somewhere, and
> > > someone might be able to make it even better.
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > >
> >
> >
> > --
> > Patrik Hasibuan <patrikh
penguin-teknologi.com>
> > Junior Programmer
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
Patrik Hasibuan <patrikh
penguin-teknologi.com>
Junior Programmer
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]