|
#1
|
||
|
PHP Help!
Hi,
I am currently making a system but I am slightly stuck - im a bit of a rookie at php developmet. Any help would be great! Basically I am using PHP to pull information from a database based on url info - i.e GET function. So i want to pull information from the DB where group = 1 - easy enuff so far, with the URL saying group.php?group=1 but now i want it to pull from the DB where group = 1 AND 3, but i cant seem to get this to work, iv tried group.php?group=1,2 group.php?group=1&2 but none of this is working.. any help is greatly appreciated! thanks Ryan |
|
|
#2
|
||
|
Hi Ryan.
My advice to you would be to read up on some beginner PHP tutorials or purchase a book on it. If you're running into problems at this stage, then things are only going to get worse (for you and your clients). That said:- script.php?groups[]=1&groups[]=2 Code:
<?php $groups = $_GET['groups']; var_dump($groups); ?> |
|
|
#3
|
|||
|
Quote:
__________________
Nathan Roberts Web Design Birmingham Latest Projects - Loudmouth | Make Up Artist Of The Year Contact - 0121 314 0390 | info (at) bluecubemedia.co.uk | Website Design Birmingham |
||
|
#4
|
||
|
Is this being used on a production site?
I wouldn't advise it... if you're running into problems with GET variables, there's likely to be exploits in the script. |
|
|
#6
|
|||
|
Thanks a lot, thats perfect..
and yeh im using mysql_escape_string i probably should have taken off the zinkdesign sig, im only really designing for clients not coding at the minute.. im only 17 and still learnin btw: Quote:
thanks for the advice ryan |
||
|
#8
|
||
|
@RichardJohn
listen, enough with the givin off about my capabilities, its a personal project and i am aware of exploits etc. so thanks for the advice but theres really no need for the patronising appreciate the help richardh
|
|
|
#9
|
|||
|
Quote:
Then there are several online resources you can use for further reference i.e. - http://www.php.net Hope this helps
__________________
Nathan Roberts Web Design Birmingham Latest Projects - Loudmouth | Make Up Artist Of The Year Contact - 0121 314 0390 | info (at) bluecubemedia.co.uk | Website Design Birmingham |
||
|
#10
|
|||
|
Quote:
![]() HTH Nathan
__________________
Nathan Roberts Web Design Birmingham Latest Projects - Loudmouth | Make Up Artist Of The Year Contact - 0121 314 0390 | info (at) bluecubemedia.co.uk | Website Design Birmingham |
||
|
#11
|
||
|
thanks, iv been thinkin about investing in a book so i think ill have to have a look on amazon soon!
thats fair enuff, i kinda jst got annoyed over nuthin there lol apologies, its just been a busy week cheers again for all ur advice ryan |
|
|
#12
|
||
|
I wasn't being patronising, I was just advising against using code on production sites whilst you're still learning!
|
|
|
#13
|
||
|
thats cool, apologies im jst a bit touchy lol. my age seems to make my credibility go wayy down a lot when im designing etc. so just a little edgy with it.. i didnt mean to snap lol
you're right tho, iv kinda jumped in the deep end, i need to start at the beginning ![]() cheers ryan |
|
|
#14
|
|||
|
Re: PHP Help!
Quote:
select * from tablename where groupid = 1 is OK select * from tablename where groupid = 1 AND 3 is really saying select * from tablename where groupid = 1 and 3 where 3 is a boolean expression which is always true (because it is non zero), so it is redundant. What you are really after is something ilke: select * from tablename where groupid = 1 or groupid = 3 or maybe select * from tablename where groupid in ( 1, 3 )
__________________
Paul, software developer. Freebies: year planner (pdf), singer songwriter (album)
|
||
|
#15
|
|||
|
Re: PHP Help!
Quote:
group.php?group=1&group2=2&group3=3 If it is the database query you are struggling with then have a read of: http://www.w3schools.com/sql/default.asp Also, get a copy of phpMyAdmin installed on your host / or pc, with that you can execute queries directly in the database and get them working in SQL... then build the same statement in your code... |
||
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
|||||