![]() |
|
#1
|
|||
|
|||
Trying to retrieve selective results from a table.Hi.
I want to be able to retrieve selected results from a MySQL table. I'm no PHP programmer but i have been playing around with the following code : PHP Code:
WHERE ( content=8 ) AND ( status='yes' )"; I get ALL the results but when I add that bit back in I get nothing displayed. Anyone know where I am going wrong? Thanks in advance for any help. |
|
#2
|
||||
|
||||
|
Hello icsys,
Maybe there's no record for content=8 or status='yes' or both; in the database table? ![]() If it were just a syntax error, your code error checking should be reporting it... __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
|||
|
|||
|
If only it were that simple
There are loads of matching records. It just wont extract them? Last edited by icsys : 14-Nov-2003 at 12:37.
|
|
#4
|
||||
|
||||
|
OK, try this then:
PHP Code:
If it returns any record with Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#5
|
|||
|
|||
|
I tried the query as suggested and there were no errors reported but still no results?
|
|
#6
|
||||
|
||||
|
If you have access to mysql command line, try a few of these queries:
Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#7
|
|||
|
|||
|
mysql> SELECT * from `gsm_compat` WHERE content=8;
returns no results mysql> SELECT * from `gsm_compat` WHERE status='yes'; returns no results mysql> SELECT `content`, `status` from `gsm_compat`; returns content and status for all records I'm begining to think there is a problem with this table. |
|
#8
|
||||
|
||||
|
Quote:
Before you think that, are you CERTAIN at least one of these rows (see above) were either content=8 or status='yes'? It might help if you post some rows that were returned by that last query... just some...not all! Also you could copy and paste the results off the following query via the MySQL monitor: Code:
__________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#9
|
|||
|
|||
|
Well after hours of frustration I think I have sussed it! And i cant believe it!
I am using a program called csv_importer to upload the csv extracts into the database. This is because our host server cannot accept load_data_local due to security issues (another story). Anyway, this importer also appears to be importing the '' characters therefore it seems that this is why the sql query wont work. I.e the records were 'yes' instead of yes (and like a dumbass I diddnt notice) After much frustration and headache i noticed this and decided to delete a few rows and replace them without the '' and the bloody thing extracted!!!! Thanks to all who tried to help with this. The problem now is how do I stop the importer from importing these '' characters? I have no control over the csv format. With over 900 records its going to be a ballache changing each record manually. |
|
#10
|
||||
|
||||
|
I am glad to hear that you got this thing figured out...
My suggestion is to send the CSV to your host and get them to upload it to the table/db. If not, find a decent web host very quickly __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
Recent GIDBlog
Flickr uploads of IA pictures by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search Engine Positioning 101 and 201 "How To" Tips... | 000 | Search Engine Optimization Forum | 0 | 29-May-2003 10:34 |
| [Tutorial] MySQL Basics | nniehoff | MySQL / PHP Forum | 15 | 23-Mar-2003 19:42 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The