php-general Digest 27 May 2007 17:18:22 -0000 Issue 4814

Topics (messages 255696 through 255701):

Re: installing error
        255696 by: Jim Lucas
        255699 by: Tijnema
        255700 by: Jim Lucas

Re: Too many records to display in one web page
        255697 by: Jim Lucas
        255701 by: Brian Seymour

Re: $_GET strings seperation
        255698 by: Jared Farrish

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Rafael Mora wrote:
Thank you very much for you answers!!! =), but Im trying to work with
PostgreSQL.

So Im gonna review your suggestions in order to see which would be the best
for me

Thank you very much!

Rafa


On 5/26/07, Sathyashrayan <[EMAIL PROTECTED]> wrote:



On 5/26/07, Tijnema <[EMAIL PROTECTED]> wrote:
>
> On 5/26/07, Richard Davey <[EMAIL PROTECTED]> wrote:
> > Hi Rafael,
> >
> > Saturday, May 26, 2007, 12:38:15 AM, you wrote:
> >
> > > Hello does anyone know the correct way to install PHP and APACHE
> (last
> > > versions both of them) on WinXP???, Im doing it with the installers
> and I
> > > cannot even run phpinfo(); script, I see apache's error log and it
> says that
> > > i cant find SAM directory
> >
> > http://wamp.corephp.co.uk
> >
> > Cheers,
> >
> > Rich



May be this helps.

http://www.tanguay.info/wamp/installPhp5.php5



--
"War doesn't determine who is right, war determines who is left."
                                                                 Chinese
proverb

You can use any of the suggested WAMP installers, then just install the Postgres installation, either before or after you install the others. They won't conflict with each other, you will just have to figure out how to enable Postgres support in PHP. That should not be that hard though. I'm sure that Postgres has some nice docs on how to do that.
--- End Message ---
--- Begin Message ---
On 5/27/07, Jim Lucas <[EMAIL PROTECTED]> wrote:
Rafael Mora wrote:
> Thank you very much for you answers!!! =), but Im trying to work with
> PostgreSQL.
>
> So Im gonna review your suggestions in order to see which would be the best
> for me
>
> Thank you very much!
>
> Rafa
>
>
> On 5/26/07, Sathyashrayan <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> On 5/26/07, Tijnema <[EMAIL PROTECTED]> wrote:
>> >
>> > On 5/26/07, Richard Davey <[EMAIL PROTECTED]> wrote:
>> > > Hi Rafael,
>> > >
>> > > Saturday, May 26, 2007, 12:38:15 AM, you wrote:
>> > >
>> > > > Hello does anyone know the correct way to install PHP and APACHE
>> > (last
>> > > > versions both of them) on WinXP???, Im doing it with the installers
>> > and I
>> > > > cannot even run phpinfo(); script, I see apache's error log and it
>> > says that
>> > > > i cant find SAM directory
>> > >
>> > > http://wamp.corephp.co.uk
>> > >
>> > > Cheers,
>> > >
>> > > Rich
>>
>>
>>
>> May be this helps.
>>
>> http://www.tanguay.info/wamp/installPhp5.php5
>>
>>
>>
>> --
>> "War doesn't determine who is right, war determines who is left."
>>                                                                  Chinese
>> proverb
>
You can use any of the suggested WAMP installers, then just install the
Postgres installation, either before or after you install the others.
They won't conflict with each other, you will just have to figure out
how to enable Postgres support in PHP.  That should not be that hard
though.  I'm sure that Postgres has some nice docs on how to do that.

Uhm, you just need a WAMP installer where the PostgreSQL PHP
dll(php_pgsql.dll) is included (like EasyPHP), then you need to
install PostgreSQL, and run it separately. Maybe you also need to load
the dll in php.ini and make some changes to the [PostgreSQL] section
in php.ini.

Tijnema


--- End Message ---
--- Begin Message ---
Tijnema wrote:
On 5/27/07, Jim Lucas <[EMAIL PROTECTED]> wrote:
Rafael Mora wrote:
> Thank you very much for you answers!!! =), but Im trying to work with
> PostgreSQL.
>
> So Im gonna review your suggestions in order to see which would be the best
> for me
>
> Thank you very much!
>
> Rafa
>
>
> On 5/26/07, Sathyashrayan <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> On 5/26/07, Tijnema <[EMAIL PROTECTED]> wrote:
>> >
>> > On 5/26/07, Richard Davey <[EMAIL PROTECTED]> wrote:
>> > > Hi Rafael,
>> > >
>> > > Saturday, May 26, 2007, 12:38:15 AM, you wrote:
>> > >
>> > > > Hello does anyone know the correct way to install PHP and APACHE
>> > (last
>> > > > versions both of them) on WinXP???, Im doing it with the installers
>> > and I
>> > > > cannot even run phpinfo(); script, I see apache's error log and it
>> > says that
>> > > > i cant find SAM directory
>> > >
>> > > http://wamp.corephp.co.uk
>> > >
>> > > Cheers,
>> > >
>> > > Rich
>>
>>
>>
>> May be this helps.
>>
>> http://www.tanguay.info/wamp/installPhp5.php5
>>
>>
>>
>> --
>> "War doesn't determine who is right, war determines who is left."
>> Chinese
>> proverb
>
You can use any of the suggested WAMP installers, then just install the
Postgres installation, either before or after you install the others.
They won't conflict with each other, you will just have to figure out
how to enable Postgres support in PHP.  That should not be that hard
though.  I'm sure that Postgres has some nice docs on how to do that.

Uhm, you just need a WAMP installer where the PostgreSQL PHP
dll(php_pgsql.dll) is included (like EasyPHP), then you need to
install PostgreSQL, and run it separately. Maybe you also need to load
the dll in php.ini and make some changes to the [PostgreSQL] section
in php.ini.

Tijnema


Isn't that exactly what I said?

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Unknown

--- End Message ---
--- Begin Message ---
Brian Seymour wrote:
Eduardo,
The best way to do it is on both a php and sql level. Use sql's limit
keyword in your query to return only the amount of records you want. For
instance, page 1 will have LIMIT 0, 9 in the query. Page 2 will have LIMIT
10, 19. Then you can simply use *_fetch_array and a foreach(maybe) to
iterate through all the values. If you want to have the the amount of
records dynamically generate then either have a asdf.php?min=0&max=9 or just
do min = (page * 10) - 10 and max = (page * 10) - 1. Many different ways to
do this. However I find this one to be the most efficient.

problem with your example.

Limit is not used that way

Check out this page for further explanation

http://dev.mysql.com/doc/refman/5.0/en/select.html#id3064319


Here is something I whipped together for this as an example


<?php

$page = 1;
$rowsPerPage = 10;
$start = 0;

if (
        isset($_GET['page']) &&
        is_numeric($_GET['page']) &&
        $_GET['page'] >= $page
        ) {
        $start = ($rowsPerPage * floor($_GET['page']) );
}

$SQL = "select * from table LIMIT {$start}, {$rowsPerPage}"

display results...

?>

Let me know if I completely confused you.  I am often confusing...

Jim Lucas


Hope this helped.
Brian Seymour
AeroCoreProductions
http://www.aerocore.net/

-----Original Message-----
From: Eduardo Vizcarra [mailto:[EMAIL PROTECTED] Sent: Saturday, May 26, 2007 7:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Too many records to display in one web page

Hi All

I am developing a web site that interacts with a MySQL database. When I run a query and display the records in a web page, this can become a problem because there might be too many records to be displayed in one single web page so I am trying to divide the total number of records and display them in multiple pages. Let's say, if the query returns 100 records then I would like to display the first 10 records and then put a navigation bar where I can go to the next 10 or return to the previous 10 records

Is this done at a SQL or PHP level ? any experience on doing this ?

Thanks a bunch
Eduardo

--- End Message ---
--- Begin Message ---
Jim,
Your totally right, must have slipped my mind.

Brian Seymour
AeroCoreProductions
http://www.aerocore.net/

-----Original Message-----
From: Jim Lucas [mailto:[EMAIL PROTECTED] 
Sent: Sunday, May 27, 2007 1:07 AM
To: Brian Seymour
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Too many records to display in one web page

Brian Seymour wrote:
> Eduardo,
> The best way to do it is on both a php and sql level. Use sql's limit
> keyword in your query to return only the amount of records you want. For
> instance, page 1 will have LIMIT 0, 9 in the query. Page 2 will have LIMIT
> 10, 19. Then you can simply use *_fetch_array and a foreach(maybe) to
> iterate through all the values. If you want to have the the amount of
> records dynamically generate then either have a asdf.php?min=0&max=9 or
just
> do min = (page * 10) - 10 and max = (page * 10) - 1. Many different ways
to
> do this. However I find this one to be the most efficient.

problem with your example.

Limit is not used that way

Check out this page for further explanation

http://dev.mysql.com/doc/refman/5.0/en/select.html#id3064319


Here is something I whipped together for this as an example


<?php

$page = 1;
$rowsPerPage = 10;
$start = 0;

if (
        isset($_GET['page']) &&
        is_numeric($_GET['page']) &&
        $_GET['page'] >= $page
        ) {
        $start = ($rowsPerPage * floor($_GET['page']) );
}

$SQL = "select * from table LIMIT {$start}, {$rowsPerPage}"

display results...

?>

Let me know if I completely confused you.  I am often confusing...

Jim Lucas

> 
> Hope this helped. 
> 
> Brian Seymour
> AeroCoreProductions
> http://www.aerocore.net/
> 
> -----Original Message-----
> From: Eduardo Vizcarra [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, May 26, 2007 7:18 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Too many records to display in one web page
> 
> Hi All
> 
> I am developing a web site that interacts with a MySQL database. When I
run 
> a query and display the records in a web page, this can become a problem 
> because there might be too many records to be displayed in one single web 
> page so I am trying to divide the total number of records and display them

> in multiple pages. Let's say, if the query returns 100 records then I
would 
> like to display the first 10 records and then put a navigation bar where I

> can go to the next 10 or return to the previous 10 records
> 
> Is this done at a SQL or PHP level ? any experience on doing this ?
> 
> Thanks a bunch
> Eduardo 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
On May 26, 5:39 pm, [EMAIL PROTECTED] ("Navid Yar") wrote:
Thanks so much Jarred. It helps me learn more when there's an
explaination on how the code works. I'll play around with it, change
it a bit and give that a try. Take care...
P.S. -- I'm in Arlington, TX

I work with a guy from Arlington. Live near the new stadium?
Incidentally, ponder this:

<code>
function shortGetNewQueryString($arr,$merge) {
   return array_merge($arr,$merge);
}
echo('<pre>');

// Let's do one new cID, new GET key/value
$query = Array('cID'=>42,'freudian'=>'slip');
$go = shortGetNewQueryString($_GET,$query);
print_r($go);

// Let's do one new cID, new GET key/value
$query = Array('cID'=>9-002,'footloose'=>'fancy free');
$go = shortGetNewQueryString($go,$query);
print_r($go);

// Let's do one new cID, new GET key/value
$query = Array('cID'=>493,'fugged'=>'dhaboutit');
$go = shortGetNewQueryString($go,$query);
print_r($go);

// Let's do one new cID, new GET key/value
$query = Array('cID'=>A4,'longlongtimeago'=>'in a galaxy far, far
away');
$go = shortGetNewQueryString($go,$query);
print_r($go);

echo('</pre>');
</code>

By the way, when you run that code, pay special attention to the
second test. Very very tricky entry anomaly... Wuffuh!

Pay attention to how short that new code is
( shortGetNewQueryString() ). It's certainly arguable you don't even
need to wrap it in a function. Consider:

<code>
// This is the best version, I believe: brief and simple.
function mediumGetNewQueryString ($arr,$add) {
   foreach ($add as $key=>$val) {
       $arr[$key] = $val;
   }
   return $arr;
}

echo('<pre>');
print_r( mediumGetNewQueryString($_GET,$query) );
echo('<pre>');
</code>

And then, of course, a number of shortcuts may be used to obscurify and
mystify your code for later puzzling, head-scratchedness.

This is, of course, exactly comparable to all the other example
methods:

<code>
// Hard to read, ie, needless brevity
function annoyingGetNewQueryString ($arr,$add) {
   foreach ($add as $key=>$val) $arr[$key] = $val;
   return $arr;
}

echo('<pre>');
print_r( annoyingGetNewQueryString($_GET, $query) );
echo('</pre>');
</code>

Caution: Using array_merge, though, will overwrite keynames, but NOT
numerical items. You can't auto-map over numerical keys with array_merge(),
apparently.

Consider:

<code>
$array = Array(
   [0] => 'moe'
   [1] => 'curly',
   [2] => 'larry'
);

// Is equivalent to ~
$array = Array();
$array[] 'moe';
$array[] 'curly';
$array[] 'larry';

// Is equivalent to ~
$array = Array();
array_push($array, 'moe');
array_push($array, 'curly');
array_push($array, 'larry');
</code>

When you add a numerical array in php, it is added to the stack as a new
item, or push. Essentially,

$array = Array('item1')
$array[] = 'item2' eq ~ "Array('item1','item2')"

And then when you call on the array, it

{ get Array as Numerically-Indexed Set } eq ~ split($array,$token=',') eq ~
({ [0] => 'item' , [1] = 'item2' })

So an array on a stack can be represeted in memory as a comma-delimited
numerically-indexed list, eg, 'item','item2'

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$

--- End Message ---

Reply via email to