![]() |
MySQL - Is there a better way to SELECT
I am fairly new to the whole PHP MySQL stuff, I can make it work but don't know all the optimizations and such. I know very little MySQL and figured there has got to be a better way of doing this...
Currently I am doing this, each query is specific to a 'type' and each result is put into a different table. PHP Code:
Thanks! |
To combine those first 5 queries you could do:
PHP Code:
PHP Code:
On another point, here's a small article that you may find useful in regards to using sprintf for formatting query strings, http://www.talkphp.com/showthread.php?t=1062 |
Thanks Karl, but how would I separate each type (which only goto 4 btw) into their own table with only one select statement? Like I would have 5 tables each with a while loop for the $result*.
PHP Code:
Thanks though I will look into doing sprintf |
Use the
mysql_fetch_array function to fetch all of the relevant rows into a structured array, which you can then output to your pleasure.For Example PHP Code:
|
| All times are GMT. The time now is 02:01 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0