Web Hosting Talk







View Full Version : VERY small PHP/MYSQL task - a quick $5


mrsam
09-25-2005, 06:53 PM
I wanna run a query looking something like this:

SELECT * FROM tabel where platform='PC' AND platform='PS2' AND platform='Xbox' ORDER BY id DESC limit 0,5

basically a query where I pick out certain platforms and then only list the latest 5 additions to those platforms. Thats pretty easy, however I want the data listed in a speciel way, 2 platforms with listing (meaning 2 columns per row), then a <br> (or empty <tr>) and repeat again with 2 platform listings per row:

PC games and hints | PS2 games and hints
- newest addition 1 | - newest addition 1
- newest addition 2 | - newest addition 2
- newest addition 3 | - newest addition 3
- newest addition 4 | - newest addition 4
- newest addition 5 | - newest addition 5

<br>

Xbox games and hints | Gamecube games and hints and hints
- newest addition 1 | - newest addition 1
- newest addition 2 | - newest addition 2
- newest addition 3 | - newest addition 3
- newest addition 4 | - newest addition 4
- newest addition 5 | - newest addition 5

Payment with Paypal. PM me if you can do it. Need it quick, so whoever can do it the fastest for me got the task.

Im going to bed and will return to check my PMs in 8 hours time or so.

MrOrange
09-25-2005, 07:27 PM
You could save yourself $5 and just query for each platform and then output each as table - only if the platforms selected are static that is. Though, the query you supplied wouldn't work as it would just return a total of 5 rows - e.g. 3 for PS2, 2 for Xbox, 0 for PC.

jimlundeen
09-25-2005, 08:19 PM
um, actually the query wouldn't result in anything... platform can't equal three different things all at once.

SELECT * FROM table WHERE platform IN ( 'PC', 'something', 'somethingelse' ) ORDER BY id LIMIT 5

it's an OR operation, not an AND.

another variation of the above query:

SELECT * FROM table WHERE platform = 'something' or platform = 'somethingelse' or platform = 'yetsomethingelse' ORDER BY id LIMIT 5

I prefer using IN; it's cleaner, in my opinion...

I won't bother providing a code example... it likely wouldn't be exactly what you want anyhow, and would just waste both of our time.

good luck...

mrsam
09-26-2005, 12:58 PM
MrOrange > I want to make less queries as possible, to reduce db load, so making a query for each platform isn't an option .. Im pretty sure it's possible to do this only making one query.. It should be very simple (just not for me)

Im sorry about the query info I posted at start, you're all right, it wouldn't work with anything :) was tired when I posted this.

Im still looking for someone to do this, it could really be done within a half an hour

jimlundeen
09-26-2005, 01:06 PM
how many records are going to be in your table? i can't imagine the performance hit of a few queries would make that much of a difference, if any. Don't let perfection be the enemy of the good.

mrsam
09-26-2005, 04:40 PM
Got it done. Thanks for your interest