Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

This a question for al the geniuses in math, Looking for a..

 
   Database Help (Home) -> PHP RSS
Next:  SQL 2005 Managment Studio  
Author Message
SM

External


Since: May 07, 2008
Posts: 41



(Msg. 1) Posted: Wed Oct 08, 2008 9:56 pm
Post subject: This a question for al the geniuses in math, Looking for a math
Archived from groups: comp>lang>php (more info?)

This a question for the math genius...

i have an 3 dimensional array representing CD's...
I want to do pagination without getting the value of the current page
in the url (linking issues). So i want to use a mathematical formula
to get the current page...

Here's where i am right now:
--------------------------------
$cat = $_GET['cat'];

$cds = array(
1=> array(
ClOHCQiD=> array('xxx', 'yyy'),
pZrhrRRX=> array('xxx', 'yyy'),
Lk3AGW6P=> array('xxx', 'yyy'),
XXXXXXXX=> array('xxx', 'yyy'),
t1knTITi=> array('xxx', 'yyy'),
yJd6OBlM=> array('xxx', 'yyy'),
J1tiIzSE=> array('xxx', 'yyy'),
22222222=> array('xxx', 'yyy')
),

2=> array(
ClOHCQiD=> array('xxx', 'yyy'),
pZrhrRRX=> array('xxx', 'yyy'),
Lk3AGW6P=> array('xxx', 'yyy'),
GIeWMFBa=> array('xxx', 'yyy')
)
);

//pagination
$p_perpage = 3;
$p_totalcds = count($cds[$cat]); //total = 8
$p_totalpages = ceil($p_totalcds / $p_perpage);

????
$p_thispage = ????; //get this value depending on the position of the
$cd in array

-----------------------

Let's just pretend that $cat = 1. If the key string of the array $cds
is 'XXXXXXXX' that would mean that the value $p_thispage = 2. I've
arrived at that conclusion by considering the key position of the
value 'xxxxxxxx' in the array $cds[1] and also that the per page value
= 3...

If the key string in $cds is '22222222' then $p_thispage = 3 and so
on...

Usin the above example and If I had this:
$p_perpage = 5;
$p_totalcds = count($cds[$cat]);
$p_totalpages = ceil($p_totalcds / $p_perpage);

then
$p_thispage = 1


Knowning that these variables (per page.. total of cds...) could
change in the future, what could be a good mathematical formula to get
the value for the variable $p_thispage. My brain is almost bleeding
with all the searching and trying with no success... you could call it
an effor to nowhere...

Thanks again
Marco

 >> Stay informed about: This a question for al the geniuses in math, Looking for a.. 
Back to top
Login to vote
SM

External


Since: May 07, 2008
Posts: 41



(Msg. 2) Posted: Thu Oct 09, 2008 1:50 pm
Post subject: Re: This a question for al the geniuses in math, Looking for a math [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Oct 9, 2:13 pm, Jerry Stuckle <jstuck... DeleteThis @attglobal.net> wrote:
> SM wrote:
> > This a question for the math genius...
>
> > i have an 3 dimensional array representing CD's...
> > I want to do pagination without getting the value of the current page
> > in the url (linking issues). So i want to use a mathematical formula
> > to get the current page...
>
> > Here's where i am right now:
> > --------------------------------
> > $cat = $_GET['cat'];
>
> > $cds = array(
> >    1=> array(
> >       ClOHCQiD=> array('xxx', 'yyy'),
> >       pZrhrRRX=> array('xxx', 'yyy'),
> >       Lk3AGW6P=> array('xxx', 'yyy'),
> >       XXXXXXXX=> array('xxx', 'yyy'),
> >       t1knTITi=> array('xxx', 'yyy'),
> >       yJd6OBlM=> array('xxx', 'yyy'),
> >       J1tiIzSE=> array('xxx', 'yyy'),
> >       22222222=> array('xxx', 'yyy')
> >    ),
>
> >    2=> array(
> >       ClOHCQiD=> array('xxx', 'yyy'),
> >       pZrhrRRX=> array('xxx', 'yyy'),
> >       Lk3AGW6P=> array('xxx', 'yyy'),
> >       GIeWMFBa=> array('xxx', 'yyy')
> >    )
> > );
>
> > //pagination
> > $p_perpage = 3;
> > $p_totalcds = count($cds[$cat]); //total = 8
> > $p_totalpages = ceil($p_totalcds / $p_perpage);
>
> > ????
> > $p_thispage = ????; //get this value depending on the position of the
> > $cd in array
>
> > -----------------------
>
> > Let's just pretend that $cat = 1. If the key string of the array $cds
> > is 'XXXXXXXX' that would mean that the value $p_thispage = 2. I've
> > arrived at that conclusion by considering the key position of the
> > value 'xxxxxxxx' in the array $cds[1] and also that the per page value
> > = 3...
>
> > If the key string in $cds is '22222222' then $p_thispage = 3 and so
> > on...
>
> > Usin the above example and If I had this:
> > $p_perpage = 5;
> > $p_totalcds = count($cds[$cat]);
> > $p_totalpages = ceil($p_totalcds / $p_perpage);
>
> > then
> > $p_thispage = 1
>
> > Knowning that these variables (per page.. total of cds...) could
> > change in the future, what could be a good mathematical formula to get
> > the value for the variable $p_thispage. My brain is almost bleeding
> > with all the searching and trying with no success... you could call it
> > an effor to nowhere...
>
> > Thanks again
> > Marco
>
> Why not just store the current page in a hidden field and POST the form
> back for your next/prev buttons?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck... DeleteThis @attglobal.net
> ==================

that could also be a solution... thanks for the idea...
i'm gonna ask the same question in a math forum group... if they came
up with something i'll posted here for everybody to see...

 >> Stay informed about: This a question for al the geniuses in math, Looking for a.. 
Back to top
Login to vote
Jerry Stuckle

External


Since: Aug 11, 2004
Posts: 3696



(Msg. 3) Posted: Thu Oct 09, 2008 2:13 pm
Post subject: Re: This a question for al the geniuses in math, Looking for a math [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

SM wrote:
> This a question for the math genius...
>
> i have an 3 dimensional array representing CD's...
> I want to do pagination without getting the value of the current page
> in the url (linking issues). So i want to use a mathematical formula
> to get the current page...
>
> Here's where i am right now:
> --------------------------------
> $cat = $_GET['cat'];
>
> $cds = array(
> 1=> array(
> ClOHCQiD=> array('xxx', 'yyy'),
> pZrhrRRX=> array('xxx', 'yyy'),
> Lk3AGW6P=> array('xxx', 'yyy'),
> XXXXXXXX=> array('xxx', 'yyy'),
> t1knTITi=> array('xxx', 'yyy'),
> yJd6OBlM=> array('xxx', 'yyy'),
> J1tiIzSE=> array('xxx', 'yyy'),
> 22222222=> array('xxx', 'yyy')
> ),
>
> 2=> array(
> ClOHCQiD=> array('xxx', 'yyy'),
> pZrhrRRX=> array('xxx', 'yyy'),
> Lk3AGW6P=> array('xxx', 'yyy'),
> GIeWMFBa=> array('xxx', 'yyy')
> )
> );
>
> //pagination
> $p_perpage = 3;
> $p_totalcds = count($cds[$cat]); //total = 8
> $p_totalpages = ceil($p_totalcds / $p_perpage);
>
> ????
> $p_thispage = ????; //get this value depending on the position of the
> $cd in array
>
> -----------------------
>
> Let's just pretend that $cat = 1. If the key string of the array $cds
> is 'XXXXXXXX' that would mean that the value $p_thispage = 2. I've
> arrived at that conclusion by considering the key position of the
> value 'xxxxxxxx' in the array $cds[1] and also that the per page value
> = 3...
>
> If the key string in $cds is '22222222' then $p_thispage = 3 and so
> on...
>
> Usin the above example and If I had this:
> $p_perpage = 5;
> $p_totalcds = count($cds[$cat]);
> $p_totalpages = ceil($p_totalcds / $p_perpage);
>
> then
> $p_thispage = 1
>
>
> Knowning that these variables (per page.. total of cds...) could
> change in the future, what could be a good mathematical formula to get
> the value for the variable $p_thispage. My brain is almost bleeding
> with all the searching and trying with no success... you could call it
> an effor to nowhere...
>
> Thanks again
> Marco
>

Why not just store the current page in a hidden field and POST the form
back for your next/prev buttons?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex DeleteThis @attglobal.net
==================
 >> Stay informed about: This a question for al the geniuses in math, Looking for a.. 
Back to top
Login to vote
SM

External


Since: May 07, 2008
Posts: 41



(Msg. 4) Posted: Thu Oct 09, 2008 3:10 pm
Post subject: Re: This a question for al the geniuses in math, Looking for a math [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Oct 9, 4:50 pm, SM <servandomont... DeleteThis @gmail.com> wrote:
> On Oct 9, 2:13 pm, Jerry Stuckle <jstuck... DeleteThis @attglobal.net> wrote:
>
>
>
> > SM wrote:
> > > This a question for the math genius...
>
> > > i have an 3 dimensional array representing CD's...
> > > I want to do pagination without getting the value of the current page
> > > in the url (linking issues). So i want to use a mathematical formula
> > > to get the current page...
>
> > > Here's where i am right now:
> > > --------------------------------
> > > $cat = $_GET['cat'];
>
> > > $cds = array(
> > >    1=> array(
> > >       ClOHCQiD=> array('xxx', 'yyy'),
> > >       pZrhrRRX=> array('xxx', 'yyy'),
> > >       Lk3AGW6P=> array('xxx', 'yyy'),
> > >       XXXXXXXX=> array('xxx', 'yyy'),
> > >       t1knTITi=> array('xxx', 'yyy'),
> > >       yJd6OBlM=> array('xxx', 'yyy'),
> > >       J1tiIzSE=> array('xxx', 'yyy'),
> > >       22222222=> array('xxx', 'yyy')
> > >    ),
>
> > >    2=> array(
> > >       ClOHCQiD=> array('xxx', 'yyy'),
> > >       pZrhrRRX=> array('xxx', 'yyy'),
> > >       Lk3AGW6P=> array('xxx', 'yyy'),
> > >       GIeWMFBa=> array('xxx', 'yyy')
> > >    )
> > > );
>
> > > //pagination
> > > $p_perpage = 3;
> > > $p_totalcds = count($cds[$cat]); //total = 8
> > > $p_totalpages = ceil($p_totalcds / $p_perpage);
>
> > > ????
> > > $p_thispage = ????; //get this value depending on the position of the
> > > $cd in array
>
> > > -----------------------
>
> > > Let's just pretend that $cat = 1. If the key string of the array $cds
> > > is 'XXXXXXXX' that would mean that the value $p_thispage = 2. I've
> > > arrived at that conclusion by considering the key position of the
> > > value 'xxxxxxxx' in the array $cds[1] and also that the per page value
> > > = 3...
>
> > > If the key string in $cds is '22222222' then $p_thispage = 3 and so
> > > on...
>
> > > Usin the above example and If I had this:
> > > $p_perpage = 5;
> > > $p_totalcds = count($cds[$cat]);
> > > $p_totalpages = ceil($p_totalcds / $p_perpage);
>
> > > then
> > > $p_thispage = 1
>
> > > Knowning that these variables (per page.. total of cds...) could
> > > change in the future, what could be a good mathematical formula to get
> > > the value for the variable $p_thispage. My brain is almost bleeding
> > > with all the searching and trying with no success... you could call it
> > > an effor to nowhere...
>
> > > Thanks again
> > > Marco
>
> > Why not just store the current page in a hidden field and POST the form
> > back for your next/prev buttons?
>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck... DeleteThis @attglobal.net
> > ==================
>
> that could also be a solution... thanks for the idea...
> i'm gonna ask the same question in a math forum group... if they came
> up with something i'll posted  here for everybody to see...


I've posted the following question in a math group. I'll keep you
posted:

I need to find a mathematical formula for this next problem...

I have a list containing 13 items. The list is dynamic, wich means
that sometimes it could contains 20 items or 35 items o only 4 items.

I want to show the items in groups of 4. Again, this is dynamic.
Sometimes i want to show the items in groups of 11, 2, etc...

So, if i have 34 items and i want to show it in groups of 10, I would
end up having 4 groups (3 groups of 10, and 1 group of 4)... So far so
good. Let's continue. If item 'joe' is the 12th item, then item 'joe'
is in group 2. right? If the item 'banana' is the 8th item, then item
'banana' is in group 1...and so on...

This is were it gets complicated for me. I need to find the group were
the item resides

So, let's recap. Knowing the total of items and the number of items
per group (also, with those two variables you can guess the total of
groups), and knowing the position of the item in the list, how do i
found out in wich group the item resides?

I'm looking for some sort of a miracle mathematical formula so i can
incorporate it in a program i'm building. Does a formula exist???

Thanks in advance
Marco
---
 >> Stay informed about: This a question for al the geniuses in math, Looking for a.. 
Back to top
Login to vote
Michael Fesser

External


Since: Dec 17, 2007
Posts: 867



(Msg. 5) Posted: Thu Oct 09, 2008 7:25 pm
Post subject: Re: This a question for al the geniuses in math, Looking for a math formula to get a value [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

..oO(SM)

>I've posted the following question in a math group. I'll keep you
>posted:
>
>I need to find a mathematical formula for this next problem...
>
>I have a list containing 13 items. The list is dynamic, wich means
>that sometimes it could contains 20 items or 35 items o only 4 items.
>
>I want to show the items in groups of 4. Again, this is dynamic.
>Sometimes i want to show the items in groups of 11, 2, etc...
>
>So, if i have 34 items and i want to show it in groups of 10, I would
>end up having 4 groups (3 groups of 10, and 1 group of 4)... So far so
>good. Let's continue. If item 'joe' is the 12th item, then item 'joe'
>is in group 2. right? If the item 'banana' is the 8th item, then item
>'banana' is in group 1...and so on...

<?php
$itemsPerGroup = 10;
$itemPosition = 12;
$group = ceil($itemPosition/$itemsPerGroup);
var_dump($group);
?>

Micha
 >> Stay informed about: This a question for al the geniuses in math, Looking for a.. 
Back to top
Login to vote
SM

External


Since: May 07, 2008
Posts: 41



(Msg. 6) Posted: Thu Oct 09, 2008 8:47 pm
Post subject: Re: This a question for al the geniuses in math, Looking for a math [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Oct 9, 6:37 pm, Michael Fesser <neti... DeleteThis @gmx.de> wrote:
> .oO(SM)
>
>
>
> >I've posted the following question in a math group. I'll keep you
> >posted:
>
> >I need to find a mathematical formula for this next problem...
>
> >I have a list containing 13 items. The list is dynamic, wich means
> >that sometimes it could contains 20 items or 35 items o only 4 items.
>
> >I want to show the items in groups of 4. Again, this is dynamic.
> >Sometimes i want to show the items in groups of 11, 2, etc...
>
> >So, if i have 34 items and i want to show it in groups of 10, I would
> >end up having 4 groups (3 groups of 10, and 1 group of 4)... So far so
> >good. Let's continue. If item 'joe' is the 12th item, then item 'joe'
> >is in group 2. right? If the item 'banana' is the 8th item, then item
> >'banana' is in group 1...and so on...
>
> <?php
> $itemsPerGroup = 10;
> $itemPosition = 12;
> $group = ceil($itemPosition/$itemsPerGroup);
> var_dump($group);
> ?>
>
> Micha

Thanks, just what i need it.
 >> Stay informed about: This a question for al the geniuses in math, Looking for a.. 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> PHP All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]