
-----------------------------------
Numbah51
Mon Nov 06, 2006 12:04 am

Need help with PHP/MySQL
-----------------------------------
I have a list of things in my database, numbered under the column 'Number'.  What i'm trying to do is to display 5.  I want it to work so that the page will be like whatever.php?start=0 and it will display videos 56-60 (if there is 60 videos in the database) and if start=1 then it will display videos 51-55.  The query i attemped and failed at using was:




Any help would be VERY GREATLY appreciated

-----------------------------------
wtd
Mon Nov 06, 2006 8:40 am


-----------------------------------
Perhaps:

$5

Is a typo?

-----------------------------------
rdrake
Mon Nov 06, 2006 8:43 am


-----------------------------------
Just a few nitpicks...

$x is not a very meaningful variable name.  Also, the value of $x should be sanitized.  Remember not to trust anything that comes from outside sources.

How exactly is this failing?  Can you give is an example?  Let's say you set start=10.

-----------------------------------
Numbah51
Mon Nov 06, 2006 9:46 am


-----------------------------------
Perhaps:

$5

Is a typo?

i just typed it wrong when i typed it here.  It should be

 5*$x

And it doesn't work like it gives a SQL error.  Even when i just put $x=0 it doesn't work.

-----------------------------------
rdrake
Mon Nov 06, 2006 9:55 am


-----------------------------------
Perhaps:

$5

Is a typo?

i just typed it wrong when i typed it here.  It should be

 5*$x

And it doesn't work like it gives a SQL error.  Even when i just put $x=0 it doesn't work.What is the exact error?

-----------------------------------
Numbah51
Mon Nov 06, 2006 10:01 am


-----------------------------------
Unfortunately I'm at school right now, i'll post it when i get home.  Thanks for your time so far btw.

-----------------------------------
octopi
Mon Nov 06, 2006 1:09 pm


-----------------------------------
$query="SELECT * FROM 'Videos' WHERE 'Number' BETWEEN ((MAX(Number)-5)-(5*$x)) AND (MAX(Number)-($5*x))"; 


I haven't looked at your code to determine if thers typos or not, but a more common way to do this is as follows:

$query="SELECT * FROM `Videos` order by `Number` ASC limit $x,5

you can change ASC to DESC to switch between ascending, and descending results.

-----------------------------------
Numbah51
Mon Nov 06, 2006 11:44 pm


-----------------------------------
omg thank you that works perfectly! :)
