|
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: Wed Sep 19 2007 - 12:47:20 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 19 Sep 2007 17:47:20 -0000 Issue 5027
Topics (messages 262225 through 262251):
Re: setup help in IIS6
262225 by: Bastien Koert
Re: trouble trying to connect to gmail server.
262226 by: Chris
setting the document root path in linux
262227 by: tbt
262228 by: Chris
262242 by: Jim Lucas
back on bug 42065 , strange behavior with ArrayObject
262229 by: Julien Pauli
262230 by: Chris
262231 by: Julien Pauli
Re: Try to find a solution, when restart Apache with PHP Script
262232 by: Rodolfo De Nadai
Undefined class constant
262233 by: Puiu Hrenciuc
262234 by: T.Lensselink
262236 by: Puiu Hrenciuc
262237 by: Puiu Hrenciuc
262241 by: T.Lensselink
262243 by: Puiu Hrenciuc
Page Numbering
262235 by: Dan Shirah
262238 by: T.Lensselink
262239 by: Dan Shirah
262240 by: T.Lensselink
262244 by: Dan Shirah
262245 by: T.Lensselink
262246 by: Dan Shirah
262247 by: Dan Shirah
262248 by: Ben
262249 by: Zoltán Németh
262250 by: Jim Lucas
Re: Finding next recored in a array
262251 by: tedd
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:
Have you created the .php file type in the IIS and pointed IIS to the php.exe?
Bastien> Date: Tue, 18 Sep 2007 22:39:07 -0400> From: cchidekel
verizon.net> To: php-general
lists.php.net> Subject: [PHP] setup help in IIS6> > Hello,> > I have installed the latest PHP on my windows server 2003 IIS6 machine. From > the DOS command line interface (when in the C:\PHP directory) if I type PHP > phpinfo.php, the file runs. However I cannot get it to work on the browser > on the server our out on the web using my URL. I'm sure it's just an II6 > issue, but what am I doing wrong?> > Thanks! > > -- > PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
attached mail follows:
Fábio Generoso wrote:
> I have a little trouble while trying to connect to gmail server.
> I already enabled POP on gmail.
> After experience a lots of errors with the command below, now I'm
> seeing no more errors, but it still doesn't working, the page stay
> processing and just is broke after this command.
>
> $mbox = imap_open('{pop.gmail.com:995/pop3}INBOX',
> 'my_login
gmail.com', 'my_pass');
What is $mbox at this point? A resource or false?
print_r(imap_alerts());
print_r(imap_errors());
anything in those?
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Hi
I'm a newbie to php and I'm using
require_once($_SERVER['DOCUMENT_ROOT']."/includes/class.announcement.php");
to import pages in php. This works fine on a windows environment. However
when I move this application to a linux environment the files dont get
imported properly. This is because in a windows environment
$_SERVER['DOCUMENT_ROOT'] returns c:/xampp/htdocs etc.
but in a linux environment returns /home/servers etc.
How can this be rectified so that the path is properly picked up in a linux
environment
--
View this message in context: http://www.nabble.com/setting-the-document-root-path-in-linux-tf4479174.html#a12771923
Sent from the PHP - General mailing list archive at Nabble.com.
attached mail follows:
tbt wrote:
> Hi
>
> I'm a newbie to php and I'm using
>
> require_once($_SERVER['DOCUMENT_ROOT']."/includes/class.announcement.php");
>
> to import pages in php. This works fine on a windows environment. However
> when I move this application to a linux environment the files dont get
> imported properly. This is because in a windows environment
> $_SERVER['DOCUMENT_ROOT'] returns c:/xampp/htdocs etc.
> but in a linux environment returns /home/servers etc.
>
> How can this be rectified so that the path is properly picked up in a linux
> environment
Don't rely on document root.
I'm surprised it worked on windows, you were lucky - 90% of the time
it's not there or not correct anyway.
If it's in the same directory as the current file, do:
require(dirname(__FILE__) . '/includes/class.announcement.php');
__FILE__ is a built in constant that tells you the full path to the
current file.
dirname() takes the filename out of that and gives you just the current
directory (see http://www.php.net/dirname ).
Then add the rest of the on the end.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
tbt wrote:
> Hi
>
> I'm a newbie to php and I'm using
>
> require_once($_SERVER['DOCUMENT_ROOT']."/includes/class.announcement.php");
>
> to import pages in php. This works fine on a windows environment. However
> when I move this application to a linux environment the files dont get
> imported properly. This is because in a windows environment
> $_SERVER['DOCUMENT_ROOT'] returns c:/xampp/htdocs etc.
> but in a linux environment returns /home/servers etc.
>
> How can this be rectified so that the path is properly picked up in a linux
> environment
are you running apache on windows and linux?
if so, setup a .htaccess file that has a line in it that modifies the php include path
place that .htaccess at your web root and you won't have to play with paths, you would call
require_once 'includes/class.announcement.php'; instead
Fix your include paths and you wont have to worry if the system will have what it should in the
$_SERVER['DOCUMENT_ROOT'].
--
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, at first, read that bug report : http://bugs.php.net/bug.php?id=42065
I would like to say that it doesn't seem to be fixed as it's said.
When I execute the bug 42065 test case, it still fails.
In reality, another code brought me to that bug, please consider this :
<?php
class a
{
public $array = array('key'=>'2');
public function getArray()
{
return $this->array;
}
}
$a = new a;
$tab = $a->getArray();
$tab['key'] = 5;
print_r($a);
print_r($tab);
Outputs :
a Object
(
[array] => Array
(
[key] => 2
)
)
Array
(
[key] => 5
)
No problem, that's expected.
Now consider that :
$a = new a;
$tab = new ArrayObject($a->getArray());
$tab['key'] = 5;
print_r($a);
print_r($tab);
Outputs :
a Object
(
[array] => Array
(
[key] => 5
)
)
ArrayObject Object
(
[key] => 5
)
So, the original array, inside the 'a' object has been modified, but it
souldn't have.
This behavior is like the one described in bug 42065
Plateform : Windows
PHP : latest 5.2 snapshot - Apache SAPI.
If you really want the original array not to be modified, you should act
like this :
$tab = new ArrayObject((array)$a->getArray());
Strange isn't it ?
attached mail follows:
Julien Pauli wrote:
> Hi, at first, read that bug report : http://bugs.php.net/bug.php?id=42065
>
> I would like to say that it doesn't seem to be fixed as it's said.
> When I execute the bug 42065 test case, it still fails.
>
> In reality, another code brought me to that bug, please consider this :
http://www.php.net/manual/en/function.ArrayObject-construct.php#77235
Says it all :)
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
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 ?
2007/9/19, Chris <dmagick
gmail.com>:
>
> Julien Pauli wrote:
> > Hi, at first, read that bug report :
> http://bugs.php.net/bug.php?id=42065
> >
> > I would like to say that it doesn't seem to be fixed as it's said.
> > When I execute the bug 42065 test case, it still fails.
> >
> > In reality, another code brought me to that bug, please consider this :
>
> http://www.php.net/manual/en/function.ArrayObject-construct.php#77235
>
> Says it all :)
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
attached mail follows:
Hello James,
in future we will implement the script with cron, i've already talk to
the support server guys... and i think this would be the best pratice...
But for now i was wondering if there's a workaround... because in the
moment my boss tell me to not change anything that could delay the
software more than 1 or 2 days...
So i'm looking for a dirty solution for now...
thanks
James Ausmus escreveu:
> On 9/17/07, Rodolfo De Nadai <rodolfo.denadai
ima.sp.gov.br> wrote:
>
>> Hi all...
>>
>> I'm facing a serious problem with my application. I have a script write
>> in PHP that starts in Internet Explorer, this script keep on running
>> until a varible value change on my MySQL database.
>> The problem is that when i restart Apache, the process child initalized
>> isn't kill... then the apache can't be start because the script is use
>> the port 80.
>>
>
> Hi Rodolfo-
>
> I think you are going about this the wrong way. You shoud not have the
> PHP script itself execute the forever running task, it should just
> trigger the separate starting/stopping of the task. There are several
> ways to do this, the first two that spring to mind are:
>
> 1. Create a custom init-script in /etc/init.d (or wherever your
> distribution has init scripts) that the PHP process triggers with a
> start command (/etc/init.d/myprog start). This will require root
> privileges for the PHP process (or no-password sudo privileges for
> that command).
>
> --or--
>
> 2. Have a cron job running as a user that has appropriate permissions.
> This cron job should look for the presence of specific files - if it
> sees them, it takes the appropriate action, and then deletes the
> trigger file. For example, have the cron job watch for the presence of
> /tmp/startMyProg.marker - when it sees it, it starts the program and
> deletes /tmp/startMyProg.marker. Also have it watch for the presence
> of /tmp/stopMyProg.marker, when it sees that, it would stop the
> running program, and delete the marker file. At this point, all your
> PHP script has to do is create the appropriate file in /tmp (could be
> as simple as a exec("touch /tmp/startMyProg.marker") call).
>
> Hope that sends you a workable direction-
>
> James
>
>
>
--
* Rodolfo De Nadai *
* Analista de Sistema Jr. - Desenvolvimento *
*Informática de Municípios Associados S.A.*
Seu governo mais inteligente
rodolfo.denadai
ima.sp.gov.br <mailto:rodolfo.denadai
ima.sp.gov.br> -
www.ima.sp.gov.br <http://www.ima.sp.gov.br/>
Fone: (19) 3739-6000 / Ramal: 1307
attached mail follows:
Hi everyone,
I'm having a hard time dealing with an error that appeared overnight
in one of my PHP script:
Fatal error: Undefined class constant 'self::TYPE_HIDDEN' in
/#########/classes/framework/HTML/HTMLForm.php on line 120
HTMLForm.php snippet:
.........
// Creates the HTMLFormFields
foreach ($this->Record->Columns as $_column)
{
// Add only visible columns
if ($_column->IsVisible)
{
// Default field type
$_type=HTMLFormField::ELEMENT_TYPE_TEXT ;
// Adjust default type based on Column type
switch ($_column->Type)
{
case Column::TYPE_AUTONUMBER:
$_type=HTMLFormField::ELEMENT_TYPE_HIDDEN ;
break;
case Column::TYPE_BOOLEAN :
$_type=HTMLFormField::ELEMENT_TYPE_CHECKBOX ;
break;
default:
break;
117: }
118:
119: // Add the column to the list of fields
120: $this->Fields[$_column->Name]=new
121: HTMLFormField($this->Name,$_column,$_type);
122:
123: }
}
As you can see there is no refference to any TYPE_HIDDEN constant
at line 120, nor in the HTMLFormField's constructor.
I searched the net, but I just can't find the reason of this.
Can someone please help me ?
Thanks,
Puiu
attached mail follows:
On Wed, 19 Sep 2007 15:56:22 +0300, Puiu Hrenciuc <hpuiu
xentra.ro> wrote:
> Hi everyone,
>
> I'm having a hard time dealing with an error that appeared overnight
> in one of my PHP script:
>
> Fatal error: Undefined class constant 'self::TYPE_HIDDEN' in
> /#########/classes/framework/HTML/HTMLForm.php on line 120
>
> HTMLForm.php snippet:
>
> .........
> // Creates the HTMLFormFields
> foreach ($this->Record->Columns as $_column)
> {
> // Add only visible columns
> if ($_column->IsVisible)
> {
> // Default field type
> $_type=HTMLFormField::ELEMENT_TYPE_TEXT ;
>
> // Adjust default type based on Column type
> switch ($_column->Type)
> {
> case Column::TYPE_AUTONUMBER:
> $_type=HTMLFormField::ELEMENT_TYPE_HIDDEN ;
> break;
>
> case Column::TYPE_BOOLEAN :
> $_type=HTMLFormField::ELEMENT_TYPE_CHECKBOX ;
> break;
> default:
> break;
> 117: }
> 118:
> 119: // Add the column to the list of fields
> 120: $this->Fields[$_column->Name]=new
> 121: HTMLFormField($this->Name,$_column,$_type);
> 122:
> 123: }
>
> }
>
> As you can see there is no refference to any TYPE_HIDDEN constant
> at line 120, nor in the HTMLFormField's constructor.
>
> I searched the net, but I just can't find the reason of this.
> Can someone please help me ?
>
> Thanks,
> Puiu
When the error happens. What are the contents of 120: $_column->Name ?
attached mail follows:
Here are the content for all used variables:
$_this->Name: (string) "FilterForm"
$_column:
StringColumn Object
(
[Table] => Roles
[Name] => RoleName
[Function] => like
[Type] => 4
[Min] =>
[Max] =>
[RegEx] =>
[AllowedValues] => Array
(
)
[IsValid] =>
[IsVisible] => 1
[Sorted] => 0
[Primary] =>
[Foreign] =>
[Negated] =>
[GroupBy] =>
[Aggregate] =>
[_value:protected] =>
)
$_type: (int) 1
T . Lensselink wrote:
> On Wed, 19 Sep 2007 15:56:22 +0300, Puiu Hrenciuc <hpuiu
xentra.ro> wrote:
>> Hi everyone,
>>
>> I'm having a hard time dealing with an error that appeared overnight
>> in one of my PHP script:
>>
>> Fatal error: Undefined class constant 'self::TYPE_HIDDEN' in
>> /#########/classes/framework/HTML/HTMLForm.php on line 120
>>
>> HTMLForm.php snippet:
>>
>> .........
>> // Creates the HTMLFormFields
>> foreach ($this->Record->Columns as $_column)
>> {
>> // Add only visible columns
>> if ($_column->IsVisible)
>> {
>> // Default field type
>> $_type=HTMLFormField::ELEMENT_TYPE_TEXT ;
>>
>> // Adjust default type based on Column type
>> switch ($_column->Type)
>> {
>> case Column::TYPE_AUTONUMBER:
>> $_type=HTMLFormField::ELEMENT_TYPE_HIDDEN ;
>> break;
>>
>> case Column::TYPE_BOOLEAN :
>> $_type=HTMLFormField::ELEMENT_TYPE_CHECKBOX ;
>> break;
>> default:
>> break;
>> 117: }
>> 118:
>> 119: // Add the column to the list of fields
>> 120: $this->Fields[$_column->Name]=new
>> 121: HTMLFormField($this->Name,$_column,$_type);
>> 122:
>> 123: }
>>
>> }
>>
>> As you can see there is no refference to any TYPE_HIDDEN constant
>> at line 120, nor in the HTMLFormField's constructor.
>>
>> I searched the net, but I just can't find the reason of this.
>> Can someone please help me ?
>>
>> Thanks,
>> Puiu
>
> When the error happens. What are the contents of 120: $_column->Name ?
attached mail follows:
Here are the content for all used variables:
$_this->Name: (string) "FilterForm"
$_column:
StringColumn Object
(
[Table] => Roles
[Name] => RoleName
[Function] => like
[Type] => 4
[Min] =>
[Max] =>
[RegEx] =>
[AllowedValues] => Array
(
)
[IsValid] =>
[IsVisible] => 1
[Sorted] => 0
[Primary] =>
[Foreign] =>
[Negated] =>
[GroupBy] =>
[Aggregate] =>
[_value:protected] =>
)
$_type: (int) 1
T . Lensselink wrote:
> On Wed, 19 Sep 2007 15:56:22 +0300, Puiu Hrenciuc <hpuiu
xentra.ro> wrote:
>> Hi everyone,
>>
>> I'm having a hard time dealing with an error that appeared overnight
>> in one of my PHP script:
>>
>> Fatal error: Undefined class constant 'self::TYPE_HIDDEN' in
>> /#########/classes/framework/HTML/HTMLForm.php on line 120
>>
>> HTMLForm.php snippet:
>>
>> .........
>> // Creates the HTMLFormFields
>> foreach ($this->Record->Columns as $_column)
>> {
>> // Add only visible columns
>> if ($_column->IsVisible)
>> {
>> // Default field type
>> $_type=HTMLFormField::ELEMENT_TYPE_TEXT ;
>>
>> // Adjust default type based on Column type
>> switch ($_column->Type)
>> {
>> case Column::TYPE_AUTONUMBER:
>> $_type=HTMLFormField::ELEMENT_TYPE_HIDDEN ;
>> break;
>>
>> case Column::TYPE_BOOLEAN :
>> $_type=HTMLFormField::ELEMENT_TYPE_CHECKBOX ;
>> break;
>> default:
>> break;
>> 117: }
>> 118:
>> 119: // Add the column to the list of fields
>> 120: $this->Fields[$_column->Name]=new
>> 121: HTMLFormField($this->Name,$_column,$_type);
>> 122:
>> 123: }
>>
>> }
>>
>> As you can see there is no refference to any TYPE_HIDDEN constant
>> at line 120, nor in the HTMLFormField's constructor.
>>
>> I searched the net, but I just can't find the reason of this.
>> Can someone please help me ?
>>
>> Thanks,
>> Puiu
>
> When the error happens. What are the contents of 120: $_column->Name ?
attached mail follows:
On Wed, 19 Sep 2007 17:13:02 +0300, Puiu Hrenciuc <hpuiu
xentra.ro> wrote:
> Here are the content for all used variables:
>
> $_this->Name: (string) "FilterForm"
> $_column:
> StringColumn Object
> (
> [Table] => Roles
> [Name] => RoleName
> [Function] => like
> [Type] => 4
> [Min] =>
> [Max] =>
> [RegEx] =>
> [AllowedValues] => Array
> (
> )
>
> [IsValid] =>
> [IsVisible] => 1
> [Sorted] => 0
> [Primary] =>
> [Foreign] =>
> [Negated] =>
> [GroupBy] =>
> [Aggregate] =>
> [_value:protected] =>
> )
>
> $_type: (int) 1
>
> T . Lensselink wrote:
>> On Wed, 19 Sep 2007 15:56:22 +0300, Puiu Hrenciuc <hpuiu
xentra.ro>
> wrote:
>>> Hi everyone,
>>>
>>> I'm having a hard time dealing with an error that appeared overnight
>>> in one of my PHP script:
>>>
>>> Fatal error: Undefined class constant 'self::TYPE_HIDDEN' in
>>> /#########/classes/framework/HTML/HTMLForm.php on line 120
>>>
>>> HTMLForm.php snippet:
>>>
>>> .........
>>> // Creates the HTMLFormFields
>>> foreach ($this->Record->Columns as $_column)
>>> {
>>> // Add only visible columns
>>> if ($_column->IsVisible)
>>> {
>>> // Default field type
>>> $_type=HTMLFormField::ELEMENT_TYPE_TEXT ;
>>>
>>> // Adjust default type based on Column type
>>> switch ($_column->Type)
>>> {
>>> case Column::TYPE_AUTONUMBER:
>>> $_type=HTMLFormField::ELEMENT_TYPE_HIDDEN ;
>>> break;
>>>
>>> case Column::TYPE_BOOLEAN :
>>> $_type=HTMLFormField::ELEMENT_TYPE_CHECKBOX
> ;
>>> break;
>>> default:
>>> break;
>>> 117: }
>>> 118:
>>> 119: // Add the column to the list of fields
>>> 120: $this->Fields[$_column->Name]=new
>>> 121: HTMLFormField($this->Name,$_column,$_type);
>>> 122:
>>> 123: }
>>>
>>> }
>>>
>>> As you can see there is no refference to any TYPE_HIDDEN constant
>>> at line 120, nor in the HTMLFormField's constructor.
>>>
>>> I searched the net, but I just can't find the reason of this.
>>> Can someone please help me ?
>>>
>>> Thanks,
>>> Puiu
>>
>> When the error happens. What are the contents of 120: $_column->Name ?
What happens inside the constructor when you create a new instance of
HTMLFormField?
Maybe the $_type is validated there. Or i'm missing something in this
snippet.
attached mail follows:
Here is the HTMLFormField constructor, it is pretty simple :
/**
* Creates a new HTMLFormField object
*
*
param string $_formName Name of the form this field belongs to
*
param Column $_column Record object this column derives from
*
param int $_type Type of field, this determines the type of
HTML element that will be rendered
*
param string $_class Class name for the HTML element
*
param array $_values Array of display values for combos,
lists, radios
*
param string $_label Label to be displayed next to a radio,
check box
*
param string $_nullMessage Message that will be displayed
when a required field was not filled
*
param string $_invalidMessage Message that will be displayed
when the data entered is invalid
*
param string $_tooShortMessage Message displayed when the
field value is bellow minimum value or length
*
param string $_tooLongMessage Message displayed when the
field value is above maximum value or length
*/
public function
__construct($_formName,$_column=null,$_type=0,$_class=''
,$_fieldValues=null,$_label="",$_nullMessage='',$_invalidMessage='',$_tooShortMessage='',$_tooLongMessage='')
{
// Copy column's properties and save passed parameters
into local properties
if ($_column instanceof Column )
{
$this->Name=$_column->Name;
$this->RegEx=$_column->RegEx;
$this->Min=$_column->Min;
$this->Max=$_column->Max;
$this->Type=$_column->Type;
$this->Value=$_column->Value;
}
$this->FormName=$_formName;
$this->NullMessage=$_nullMessage;
$this->InvalidDataMessage=$_invalidMessage;
$this->TooLongMessage=$_tooShortMessage;
$this->TooLongMessage=$_tooLongMessage;
$this->Class=$_class;
$this->FieldValues=$_fieldValues;
$this->FieldType=$_type;
}
Trust me, it doesn't have any logical explanation :)
Puiu
T.Lensselink wrote:
> On Wed, 19 Sep 2007 17:13:02 +0300, Puiu Hrenciuc <hpuiu
xentra.ro> wrote:
>
>> Here are the content for all used variables:
>>
>> $_this->Name: (string) "FilterForm"
>> $_column:
>> StringColumn Object
>> (
>> [Table] => Roles
>> [Name] => RoleName
>> [Function] => like
>> [Type] => 4
>> [Min] =>
>> [Max] =>
>> [RegEx] =>
>> [AllowedValues] => Array
>> (
>> )
>>
>> [IsValid] =>
>> [IsVisible] => 1
>> [Sorted] => 0
>> [Primary] =>
>> [Foreign] =>
>> [Negated] =>
>> [GroupBy] =>
>> [Aggregate] =>
>> [_value:protected] =>
>> )
>>
>> $_type: (int) 1
>>
>> T . Lensselink wrote:
>>
>>> On Wed, 19 Sep 2007 15:56:22 +0300, Puiu Hrenciuc <hpuiu
xentra.ro>
>>>
>> wrote:
>>
>>>> Hi everyone,
>>>>
>>>> I'm having a hard time dealing with an error that appeared overnight
>>>> in one of my PHP script:
>>>>
>>>> Fatal error: Undefined class constant 'self::TYPE_HIDDEN' in
>>>> /#########/classes/framework/HTML/HTMLForm.php on line 120
>>>>
>>>> HTMLForm.php snippet:
>>>>
>>>> .........
>>>> // Creates the HTMLFormFields
>>>> foreach ($this->Record->Columns as $_column)
>>>> {
>>>> // Add only visible columns
>>>> if ($_column->IsVisible)
>>>> {
>>>> // Default field type
>>>> $_type=HTMLFormField::ELEMENT_TYPE_TEXT ;
>>>>
>>>> // Adjust default type based on Column type
>>>> switch ($_column->Type)
>>>> {
>>>> case Column::TYPE_AUTONUMBER:
>>>> $_type=HTMLFormField::ELEMENT_TYPE_HIDDEN ;
>>>> break;
>>>>
>>>> case Column::TYPE_BOOLEAN :
>>>> $_type=HTMLFormField::ELEMENT_TYPE_CHECKBOX
>>>>
>> ;
>>
>>>> break;
>>>> default:
>>>> break;
>>>> 117: }
>>>> 118:
>>>> 119: // Add the column to the list of fields
>>>> 120: $this->Fields[$_column->Name]=new
>>>> 121: HTMLFormField($this->Name,$_column,$_type);
>>>> 122:
>>>> 123: }
>>>>
>>>> }
>>>>
>>>> As you can see there is no refference to any TYPE_HIDDEN constant
>>>> at line 120, nor in the HTMLFormField's constructor.
>>>>
>>>> I searched the net, but I just can't find the reason of this.
>>>> Can someone please help me ?
>>>>
>>>> Thanks,
>>>> Puiu
>>>>
>>> When the error happens. What are the contents of 120: $_column->Name ?
>>>
>
> What happens inside the constructor when you create a new instance of
> HTMLFormField?
> Maybe the $_type is validated there. Or i'm missing something in this
> snippet.
>
>
>
attached mail follows:
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?
<?php
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 10;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
echo $from."FROM";
$page_results = $max_results + $from;
echo $page_results."PAGE RESULTS";
// Query the table and load all of the records into an array.
$sql = "SELECT DISTINCT * FROM (
SELECT TOP $max_results Value1, Value2 FROM (
SELECT TOP $page_results Value1,
FROM my_table
WHERE my_table.column = 'P'
) as newtbl order by credit_card_id desc
) as newtbl2 order by credit_card_id asc";
print_r ($sql);
$result = mssql_query($sql) or die(mssql_error());
//print_r ($result);
$number_rows = mssql_num_rows($result);
?>
<table width='780' border='1' align='center' cellpadding='2' cellspacing='2'
bordercolor='#000000'>
<?php
if(!empty($result)) {
while ($row = mssql_fetch_array($result)) {
$id = $row['credit_card_id'];
$dateTime = $row['date_request_received'];
//print_r ($id_child);
?>
<tr>
<td width='88' height='13' align='center' class='tblcell'><div
align='center'><?php echo "<a href='javascript:editRecord($id)'>$id</a>"
?></div></td>
<td width='224' height='13' align='center' class='tblcell'><div
align='center'><?php echo "$dateTime" ?></div></td>
<td width='156' height='13' align='center' class='tblcell'><div
align='center'><?php echo "To Be Processed" ?></div></td>
<td width='156' height='13' align='center' class='tblcell'><div
align='center'><?php echo "Last Processed By" ?></div></td>
</tr>
<?php
}
}
?>
</table>
<table align="center" width="780" cellpadding="2" cellspacing="2"
border="0">
<tr>
<td width='780' height='15' align='center' class='tblcell'><div
align='center'><strong>Results: </strong><?php echo "$number_rows";
?></div></td>
</tr>
</table>
<?php
// Figure out the total number of results in DB:
$sql_total= "SELECT * FROM my_table WHERE my_table.column = 'P'";
$tot_result = mssql_query($sql_total) or die(mssql_error());
$total_results = mssql_num_rows($tot_result) or die(mssql_error());
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
echo $max_results."Results";
echo $total_results."Total";
echo $total_pages."pages";
// Build Page Number Hyperlinks
echo "<center>Select a Page<br />";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
}
echo "</center>";
?>
attached mail follows:
On Wed, 19 Sep 2007 10:05:40 -0400, "Dan Shirah" <mrsquash2
gmail.com>
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?
>
>
> <?php
> if(!isset($_GET['page'])){
> $page = 1;
> } else {
> $page = $_GET['page'];
> }
> // Define the number of results per page
> $max_results = 10;
> // Figure out the limit for the query based
> // on the current page number.
> $from = (($page * $max_results) - $max_results);
> echo $from."FROM";
> $page_results = $max_results + $from;
> echo $page_results."PAGE RESULTS";
> // Query the table and load all of the records into an array.
> $sql = "SELECT DISTINCT * FROM (
> SELECT TOP $max_results Value1, Value2 FROM (
> SELECT TOP $page_results Value1,
> FROM my_table
> WHERE my_table.column = 'P'
> ) as newtbl order by credit_card_id desc
> ) as newtbl2 order by credit_card_id asc";
>
> print_r ($sql);
> $result = mssql_query($sql) or die(mssql_error());
> //print_r ($result);
> $number_rows = mssql_num_rows($result);
> ?>
> <table width='780' border='1' align='center' cellpadding='2'
> cellspacing='2'
> bordercolor='#000000'>
> <?php
> if(!empty($result)) {
> while ($row = mssql_fetch_array($result)) {
> $id = $row['credit_card_id'];
> $dateTime = $row['date_request_received'];
> //print_r ($id_child);
> ?>
> <tr>
> <td width='88' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "<a href='javascript:editRecord($id)'>$id</a>"
> ?></div></td>
> <td width='224' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "$dateTime" ?></div></td>
> <td width='156' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "To Be Processed" ?></div></td>
> <td width='156' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "Last Processed By" ?></div></td>
> </tr>
> <?php
> }
> }
> ?>
> </table>
> <table align="center" width="780" cellpadding="2" cellspacing="2"
> border="0">
> <tr>
> <td width='780' height='15' align='center' class='tblcell'><div
> align='center'><strong>Results: </strong><?php echo "$number_rows";
> ?></div></td>
> </tr>
> </table>
> <?php
> // Figure out the total number of results in DB:
> $sql_total= "SELECT * FROM my_table WHERE my_table.column = 'P'";
> $tot_result = mssql_query($sql_total) or die(mssql_error());
> $total_results = mssql_num_rows($tot_result) or die(mssql_error());
> // Figure out the total number of pages. Always round up using ceil()
> $total_pages = ceil($total_results / $max_results);
> echo $max_results."Results";
> echo $total_results."Total";
> echo $total_pages."pages";
> // Build Page Number Hyperlinks
> echo "<center>Select a Page<br />";
> // Build Previous Link
> if($page > 1){
> $prev = ($page - 1);
> echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a>
> ";
> }
>
> for($i = 1; $i <= $total_pages; $i++){
> if(($page) == $i){
> echo "$i ";
> } else {
> echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
> }
> }
> // Build Next Link
> if($page < $total_pages){
> $next = ($page + 1);
> echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
> }
> echo "</center>";
> ?>
I think it returns the same 10 records because of TOP $max_results.
This will always get the first 10 records. Probably better to use LIMIT.
Why are there so much subqueries needed to get the result set?
Why not something like this:
SELECT DISTINCT * FROM my_table WHERE my_table.column = 'p' ORDER BY
credit_card_id DESC LIMIT $page_results, $max_results
attached mail follows:
Becase I am using MSSQL not MYSQL. MSSQL does not have anything easy to use
like LIMIT in MYSQL. So, to achieve the same functionality you have to use
the subqueries.
Having the largest number as the inner most subquery value tells the query
to retrieve the records that are equal to that number minus 10(my results
per page)
So, if the inner most query has has a value of 30, the outer query will
select records 21-30.
And, it does this just fine because if I echo out my variables I see the
numbers changing. But for whatever reason, the data being displayed is not
changing.
On 9/19/07, T. Lensselink <dev
lenss.nl> wrote:
>
> On Wed, 19 Sep 2007 10:05:40 -0400, "Dan Shirah" <mrsquash2
gmail.com>
> 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?
> >
> >
> > <?php
> > if(!isset($_GET['page'])){
> > $page = 1;
> > } else {
> > $page = $_GET['page'];
> > }
> > // Define the number of results per page
> > $max_results = 10;
> > // Figure out the limit for the query based
> > // on the current page number.
> > $from = (($page * $max_results) - $max_results);
> > echo $from."FROM";
> > $page_results = $max_results + $from;
> > echo $page_results."PAGE RESULTS";
> > // Query the table and load all of the records into an array.
> > $sql = "SELECT DISTINCT * FROM (
> > SELECT TOP $max_results Value1, Value2 FROM (
> > SELECT TOP $page_results Value1,
> > FROM my_table
> > WHERE my_table.column = 'P'
> > ) as newtbl order by credit_card_id desc
> > ) as newtbl2 order by credit_card_id asc";
> >
> > print_r ($sql);
> > $result = mssql_query($sql) or die(mssql_error());
> > //print_r ($result);
> > $number_rows = mssql_num_rows($result);
> > ?>
> > <table width='780' border='1' align='center' cellpadding='2'
> > cellspacing='2'
> > bordercolor='#000000'>
> > <?php
> > if(!empty($result)) {
> > while ($row = mssql_fetch_array($result)) {
> > $id = $row['credit_card_id'];
> > $dateTime = $row['date_request_received'];
> > //print_r ($id_child);
> > ?>
> > <tr>
> > <td width='88' height='13' align='center' class='tblcell'><div
> > align='center'><?php echo "<a href='javascript:editRecord($id)'>$id</a>"
> > ?></div></td>
> > <td width='224' height='13' align='center' class='tblcell'><div
> > align='center'><?php echo "$dateTime" ?></div></td>
> > <td width='156' height='13' align='center' class='tblcell'><div
> > align='center'><?php echo "To Be Processed" ?></div></td>
> > <td width='156' height='13' align='center' class='tblcell'><div
> > align='center'><?php echo "Last Processed By" ?></div></td>
> > </tr>
> > <?php
> > }
> > }
> > ?>
> > </table>
> > <table align="center" width="780" cellpadding="2" cellspacing="2"
> > border="0">
> > <tr>
> > <td width='780' height='15' align='center' class='tblcell'><div
> > align='center'><strong>Results: </strong><?php echo "$number_rows";
> > ?></div></td>
> > </tr>
> > </table>
> > <?php
> > // Figure out the total number of results in DB:
> > $sql_total= "SELECT * FROM my_table WHERE my_table.column = 'P'";
> > $tot_result = mssql_query($sql_total) or die(mssql_error());
> > $total_results = mssql_num_rows($tot_result) or die(mssql_error());
> > // Figure out the total number of pages. Always round up using ceil()
> > $total_pages = ceil($total_results / $max_results);
> > echo $max_results."Results";
> > echo $total_results."Total";
> > echo $total_pages."pages";
> > // Build Page Number Hyperlinks
> > echo "<center>Select a Page<br />";
> > // Build Previous Link
> > if($page > 1){
> > $prev = ($page - 1);
> > echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a>
> > ";
> > }
> >
> > for($i = 1; $i <= $total_pages; $i++){
> > if(($page) == $i){
> > echo "$i ";
> > } else {
> > echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
> > }
> > }
> > // Build Next Link
> > if($page < $total_pages){
> > $next = ($page + 1);
> > echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
> > }
> > echo "</center>";
> > ?>
>
> I think it returns the same 10 records because of TOP $max_results.
> This will always get the first 10 records. Probably better to use LIMIT.
>
> Why are there so much subqueries needed to get the result set?
> Why not something like this:
>
> SELECT DISTINCT * FROM my_table WHERE my_table.column = 'p' ORDER BY
> credit_card_id DESC LIMIT $page_results, $max_results
>
>
>
attached mail follows:
On Wed, 19 Sep 2007 10:23:58 -0400, "Dan Shirah" <mrsquash2
gmail.com>
wrote:
> Becase I am using MSSQL not MYSQL. MSSQL does not have anything easy to
> use
> like LIMIT in MYSQL. So, to achieve the same functionality you have to
use
> the subqueries.
>
> Having the largest number as the inner most subquery value tells the
query
> to retrieve the records that are equal to that number minus 10(my results
> per page)
>
> So, if the inner most query has has a value of 30, the outer query will
> select records 21-30.
>
> And, it does this just fine because if I echo out my variables I see the
> numbers changing. But for whatever reason, the data being displayed is
not
> changing.
>
>
> On 9/19/07, T. Lensselink <dev
lenss.nl> wrote:
>>
>> On Wed, 19 Sep 2007 10:05:40 -0400, "Dan Shirah" <mrsquash2
gmail.com>
>> 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?
>> >
>> >
>> > <?php
>> > if(!isset($_GET['page'])){
>> > $page = 1;
>> > } else {
>> > $page = $_GET['page'];
>> > }
>> > // Define the number of results per page
>> > $max_results = 10;
>> > // Figure out the limit for the query based
>> > // on the current page number.
>> > $from = (($page * $max_results) - $max_results);
>> > echo $from."FROM";
>> > $page_results = $max_results + $from;
>> > echo $page_results."PAGE RESULTS";
>> > // Query the table and load all of the records into an array.
>> > $sql = "SELECT DISTINCT * FROM (
>> > SELECT TOP $max_results Value1, Value2 FROM (
>> > SELECT TOP $page_results Value1,
>> > FROM my_table
>> > WHERE my_table.column = 'P'
>> > ) as newtbl order by credit_card_id desc
>> > ) as newtbl2 order by credit_card_id asc";
>> >
>> > print_r ($sql);
>> > $result = mssql_query($sql) or die(mssql_error());
>> > //print_r ($result);
>> > $number_rows = mssql_num_rows($result);
>> > ?>
>> > <table width='780' border='1' align='center' cellpadding='2'
>> > cellspacing='2'
>> > bordercolor='#000000'>
>> > <?php
>> > if(!empty($result)) {
>> > while ($row = mssql_fetch_array($result)) {
>> > $id = $row['credit_card_id'];
>> > $dateTime = $row['date_request_received'];
>> > //print_r ($id_child);
>> > ?>
>> > <tr>
>> > <td width='88' height='13' align='center' class='tblcell'><div
>> > align='center'><?php echo "<a
> href='javascript:editRecord($id)'>$id</a>"
>> > ?></div></td>
>> > <td width='224' height='13' align='center' class='tblcell'><div
>> > align='center'><?php echo "$dateTime" ?></div></td>
>> > <td width='156' height='13' align='center' class='tblcell'><div
>> > align='center'><?php echo "To Be Processed" ?></div></td>
>> > <td width='156' height='13' align='center' class='tblcell'><div
>> > align='center'><?php echo "Last Processed By" ?></div></td>
>> > </tr>
>> > <?php
>> > }
>> > }
>> > ?>
>> > </table>
>> > <table align="center" width="780" cellpadding="2" cellspacing="2"
>> > border="0">
>> > <tr>
>> > <td width='780' height='15' align='center' class='tblcell'><div
>> > align='center'><strong>Results: </strong><?php echo "$number_rows";
>> > ?></div></td>
>> > </tr>
>> > </table>
>> > <?php
>> > // Figure out the total number of results in DB:
>> > $sql_total= "SELECT * FROM my_table WHERE my_table.column = 'P'";
>> > $tot_result = mssql_query($sql_total) or die(mssql_error());
>> > $total_results = mssql_num_rows($tot_result) or die(mssql_error());
>> > // Figure out the total number of pages. Always round up using ceil()
>> > $total_pages = ceil($total_results / $max_results);
>> > echo $max_results."Results";
>> > echo $total_results."Total";
>> > echo $total_pages."pages";
>> > // Build Page Number Hyperlinks
>> > echo "<center>Select a Page<br />";
>> > // Build Previous Link
>> > if($page > 1){
>> > $prev = ($page - 1);
>> > echo "<a
> href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a>
>> > ";
>> > }
>> >
>> > for($i = 1; $i <= $total_pages; $i++){
>> > if(($page) == $i){
>> > echo "$i ";
>> > } else {
>> > echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a>
> ";
>> > }
>> > }
>> > // Build Next Link
>> > if($page < $total_pages){
>> > $next = ($page + 1);
>> > echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
>> > }
>> > echo "</center>";
>> > ?>
>>
>> I think it returns the same 10 records because of TOP $max_results.
>> This will always get the first 10 records. Probably better to use LIMIT.
>>
>> Why are there so much subqueries needed to get the result set?
>> Why not something like this:
>>
>> SELECT DISTINCT * FROM my_table WHERE my_table.column = 'p' ORDER BY
>> credit_card_id DESC LIMIT $page_results, $max_results
>>
Dan,
Thanx for the explenation. I should have asked what DB you are using.
So if you wanna select rows from 10 to 20 with a limit of 10 the query will
be
something like this?
SELECT DISTINCT * FROM (
SELECT TOP 10 Value1, Value2 FROM (
SELECT TOP 20 Value1,
FROM my_table
WHERE my_table.column = 'P'
) as newtbl order by credit_card_id desc
) as newtbl2 order by credit_card_id asc
If you watch at the output of print_r($result) you get different results
for every page?
attached mail follows:
Actually, the query you mentioned will select records 11-20 because it
counts 10 records backwards starting with record 20.
print_r($result) onyl returns "Resource id #3" and not the actual data.
On 9/19/07, T. Lensselink <dev
lenss.nl> wrote:
>
> On Wed, 19 Sep 2007 10:23:58 -0400, "Dan Shirah" <mrsquash2
gmail.com>
> wrote:
> > Becase I am using MSSQL not MYSQL. MSSQL does not have anything easy to
> > use
> > like LIMIT in MYSQL. So, to achieve the same functionality you have to
> use
> > the subqueries.
> >
> > Having the largest number as the inner most subquery value tells the
> query
> > to retrieve the records that are equal to that number minus 10(my
> results
> > per page)
> >
> > So, if the inner most query has has a value of 30, the outer query will
> > select records 21-30.
> >
> > And, it does this just fine because if I echo out my variables I see the
> > numbers changing. But for whatever reason, the data being displayed is
> not
> > changing.
> >
> >
> > On 9/19/07, T. Lensselink <dev
lenss.nl> wrote:
> >>
> >> On Wed, 19 Sep 2007 10:05:40 -0400, "Dan Shirah" <mrsquash2
gmail.com>
> >> 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?
> >> >
> >> >
> >> > <?php
> >> > if(!isset($_GET['page'])){
> >> > $page = 1;
> >> > } else {
> >> > $page = $_GET['page'];
> >> > }
> >> > // Define the number of results per page
> >> > $max_results = 10;
> >> > // Figure out the limit for the query based
> >> > // on the current page number.
> >> > $from = (($page * $max_results) - $max_results);
> >> > echo $from."FROM";
> >> > $page_results = $max_results + $from;
> >> > echo $page_results."PAGE RESULTS";
> >> > // Query the table and load all of the records into an array.
> >> > $sql = "SELECT DISTINCT * FROM (
> >> > SELECT TOP $max_results Value1, Value2 FROM (
> >> > SELECT TOP $page_results Value1,
> >> > FROM my_table
> >> > WHERE my_table.column = 'P'
> >> > ) as newtbl order by credit_card_id desc
> >> > ) as newtbl2 order by credit_card_id asc";
> >> >
> >> > print_r ($sql);
> >> > $result = mssql_query($sql) or die(mssql_error());
> >> > //print_r ($result);
> >> > $number_rows = mssql_num_rows($result);
> >> > ?>
> >> > <table width='780' border='1' align='center' cellpadding='2'
> >> > cellspacing='2'
> >> > bordercolor='#000000'>
> >> > <?php
> >> > if(!empty($result)) {
> >> > while ($row = mssql_fetch_array($result)) {
> >> > $id = $row['credit_card_id'];
> >> > $dateTime = $row['date_request_received'];
> >> > //print_r ($id_child);
> >> > ?>
> >> > <tr>
> >> > <td width='88' height='13' align='center' class='tblcell'><div
> >> > align='center'><?php echo "<a
> > href='javascript:editRecord($id)'>$id</a>"
> >> > ?></div></td>
> >> > <td width='224' height='13' align='center' class='tblcell'><div
> >> > align='center'><?php echo "$dateTime" ?></div></td>
> >> > <td width='156' height='13' align='center' class='tblcell'><div
> >> > align='center'><?php echo "To Be Processed" ?></div></td>
> >> > <td width='156' height='13' align='center' class='tblcell'><div
> >> > align='center'><?php echo "Last Processed By" ?></div></td>
> >> > </tr>
> >> > <?php
> >> > }
> >> > }
> >> > ?>
> >> > </table>
> >> > <table align="center" width="780" cellpadding="2" cellspacing="2"
> >> > border="0">
> >> > <tr>
> >> > <td width='780' height='15' align='center' class='tblcell'><div
> >> > align='center'><strong>Results: </strong><?php echo "$number_rows";
> >> > ?></div></td>
> >> > </tr>
> >> > </table>
> >> > <?php
> >> > // Figure out the total number of results in DB:
> >> > $sql_total= "SELECT * FROM my_table WHERE my_table.column = 'P'";
> >> > $tot_result = mssql_query($sql_total) or die(mssql_error());
> >> > $total_results = mssql_num_rows($tot_result) or die(mssql_error());
> >> > // Figure out the total number of pages. Always round up using ceil()
> >> > $total_pages = ceil($total_results / $max_results);
> >> > echo $max_results."Results";
> >> > echo $total_results."Total";
> >> > echo $total_pages."pages";
> >> > // Build Page Number Hyperlinks
> >> > echo "<center>Select a Page<br />";
> >> > // Build Previous Link
> >> > if($page > 1){
> >> > $prev = ($page - 1);
> >> > echo "<a
> > href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a>
> >> > ";
> >> > }
> >> >
> >> > for($i = 1; $i <= $total_pages; $i++){
> >> > if(($page) == $i){
> >> > echo "$i ";
> >> > } else {
> >> > echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a>
> > ";
> >> > }
> >> > }
> >> > // Build Next Link
> >> > if($page < $total_pages){
> >> > $next = ($page + 1);
> >> > echo "<a
> href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
> >> > }
> >> > echo "</center>";
> >> > ?>
> >>
> >> I think it returns the same 10 records because of TOP $max_results.
> >> This will always get the first 10 records. Probably better to use
> LIMIT.
> >>
> >> Why are there so much subqueries needed to get the result set?
> >> Why not something like this:
> >>
> >> SELECT DISTINCT * FROM my_table WHERE my_table.column = 'p' ORDER BY
> >> credit_card_id DESC LIMIT $page_results, $max_results
> >>
>
> Dan,
>
> Thanx for the explenation. I should have asked what DB you are using.
>
> So if you wanna select rows from 10 to 20 with a limit of 10 the query
> will
> be
> something like this?
>
> SELECT DISTINCT * FROM (
> SELECT TOP 10 Value1, Value2 FROM (
> SELECT TOP 20 Value1,
> FROM my_table
> WHERE my_table.column = 'P'
> ) as newtbl order by credit_card_id desc
> ) as newtbl2 order by credit_card_id asc
>
> If you watch at the output of print_r($result) you get different results
> for every page?
>
>
attached mail follows:
On Wed, 19 Sep 2007 10:48:20 -0400, "Dan Shirah" <mrsquash2
gmail.com>
wrote:
> Actually, the query you mentioned will select records 11-20 because it
> counts 10 records backwards starting with record 20.
>
> print_r($result) onyl returns "Resource id #3" and not the actual data.
>
>
> On 9/19/07, T. Lensselink <dev
lenss.nl> wrote:
>>
>> On Wed, 19 Sep 2007 10:23:58 -0400, "Dan Shirah" <mrsquash2
gmail.com>
>> wrote:
>> > Becase I am using MSSQL not MYSQL. MSSQL does not have anything easy
> to
>> > use
>> > like LIMIT in MYSQL. So, to achieve the same functionality you have to
>> use
>> > the subqueries.
>> >
>> > Having the largest number as the inner most subquery value tells the
>> query
>> > to retrieve the records that are equal to that number minus 10(my
>> results
>> > per page)
>> >
>> > So, if the inner most query has has a value of 30, the outer query
> will
>> > select records 21-30.
>> >
>> > And, it does this just fine because if I echo out my variables I see
> the
>> > numbers changing. But for whatever reason, the data being displayed is
>> not
>> > changing.
>> >
>> >
>> > On 9/19/07, T. Lensselink <dev
lenss.nl> wrote:
>> >>
>> >> On Wed, 19 Sep 2007 10:05:40 -0400, "Dan Shirah"
> <mrsquash2
gmail.com>
>> >> 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?
>> >> >
>> >> >
>> >> > <?php
>> >> > if(!isset($_GET['page'])){
>> >> > $page = 1;
>> >> > } else {
>> >> > $page = $_GET['page'];
>> >> > }
>> >> > // Define the number of results per page
>> >> > $max_results = 10;
>> >> > // Figure out the limit for the query based
>> >> > // on the current page number.
>> >> > $from = (($page * $max_results) - $max_results);
>> >> > echo $from."FROM";
>> >> > $page_results = $max_results + $from;
>> >> > echo $page_results."PAGE RESULTS";
>> >> > // Query the table and load all of the records into an array.
>> >> > $sql = "SELECT DISTINCT * FROM (
>> >> > SELECT TOP $max_results Value1, Value2 FROM (
>> >> > SELECT TOP $page_results Value1,
>> >> > FROM my_table
>> >> > WHERE my_table.column = 'P'
>> >> > ) as newtbl order by credit_card_id desc
>> >> > ) as newtbl2 order by credit_card_id asc";
>> >> >
>> >> > print_r ($sql);
>> >> > $result = mssql_query($sql) or die(mssql_error());
>> >> > //print_r ($result);
>> >> > $number_rows = mssql_num_rows($result);
>> >> > ?>
>> >> > <table width='780' border='1' align='center' cellpadding='2'
>> >> > cellspacing='2'
>> >> > bordercolor='#000000'>
>> >> > <?php
>> >> > if(!empty($result)) {
>> >> > while ($row = mssql_fetch_array($result)) {
>> >> > $id = $row['credit_card_id'];
>> >> > $dateTime = $row['date_request_received'];
>> >> > //print_r ($id_child);
>> >> > ?>
>> >> > <tr>
>> >> > <td width='88' height='13' align='center' class='tblcell'><div
>> >> > align='center'><?php echo "<a
>> > href='javascript:editRecord($id)'>$id</a>"
>> >> > ?></div></td>
>> >> > <td width='224' height='13' align='center' class='tblcell'><div
>> >> > align='center'><?php echo "$dateTime" ?></div></td>
>> >> > <td width='156' height='13' align='center' class='tblcell'><div
>> >> > align='center'><?php echo "To Be Processed" ?></div></td>
>> >> > <td width='156' height='13' align='center' class='tblcell'><div
>> >> > align='center'><?php echo "Last Processed By" ?></div></td>
>> >> > </tr>
>> >> > <?php
>> >> > }
>> >> > }
>> >> > ?>
>> >> > </table>
>> >> > <table align="center" width="780" cellpadding="2" cellspacing="2"
>> >> > border="0">
>> >> > <tr>
>> >> > <td width='780' height='15' align='center' class='tblcell'><div
>> >> > align='center'><strong>Results: </strong><?php echo "$number_rows";
>> >> > ?></div></td>
>> >> > </tr>
>> >> > </table>
>> >> > <?php
>> >> > // Figure out the total number of results in DB:
>> >> > $sql_total= "SELECT * FROM my_table WHERE my_table.column = 'P'";
>> >> > $tot_result = mssql_query($sql_total) or die(mssql_error());
>> >> > $total_results = mssql_num_rows($tot_result) or die(mssql_error());
>> >> > // Figure out the total number of pages. Always round up using
> ceil()
>> >> > $total_pages = ceil($total_results / $max_results);
>> >> > echo $max_results."Results";
>> >> > echo $total_results."Total";
>> >> > echo $total_pages."pages";
>> >> > // Build Page Number Hyperlinks
>> >> > echo "<center>Select a Page<br />";
>> >> > // Build Previous Link
>> >> > if($page > 1){
>> >> > $prev = ($page - 1);
>> >> > echo "<a
>> > href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a>
>> >> > ";
>> >> > }
>> >> >
>> >> > for($i = 1; $i <= $total_pages; $i++){
>> >> > if(($page) == $i){
>> >> > echo "$i ";
>> >> > } else {
>> >> > echo "<a
> href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a>
>> > ";
>> >> > }
>> >> > }
>> >> > // Build Next Link
>> >> > if($page < $total_pages){
>> >> > $next = ($page + 1);
>> >> > echo "<a
>> href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>";
>> >> > }
>> >> > echo "</center>";
>> >> > ?>