Jump to content

Selecting from MySQL field


Woodburn2006

Recommended Posts

hello,

i know how to select data from a SQL database fine by using: SELECT * from table where blah blah blah

but what i am having problems with is that i need to be able to select data that contains a certain bit of text.

for example, if i have a column in a db table called 'Media'. the data within the column would be entered as 'cd, tape, floppy' so what i want is for the user to be able to click a button that says 'CD' and the query will notice that the MEDIA field will contain this bit of text, therefore will display it.

if the MEDIA field only containd 'cd' in it then i know that this would be shown using the standard SELECT query but i want the query to pick out just a bit of the text in the field.

any ideas?

any help would be appreciated

thanks
Link to comment
https://forums.phpfreaks.com/topic/11869-selecting-from-mysql-field/
Share on other sites

Instead of echoing out the field data, echo out what you want if the select is true...

i.e.

[code]

select * from table where field like '%CD%'

IF ($row=mysql_fetch_array($result))
    {
     echo $CD='CD';
     //  don't do echo $CD=$row[field];
    }

[/code]

If you know the field it "true", then make it just say what you want, instead of trying to "pick" it out












[!--quoteo(post=383280:date=Jun 13 2006, 10:23 AM:name=Eggmoth)--][div class=\'quotetop\']QUOTE(Eggmoth @ Jun 13 2006, 10:23 AM) [snapback]383280[/snapback][/div][div class=\'quotemain\'][!--quotec--]
hello,

i know how to select data from a SQL database fine by using: SELECT * from table where blah blah blah

but what i am having problems with is that i need to be able to select data that contains a certain bit of text.

for example, if i have a column in a db table called 'Media'. the data within the column would be entered as 'cd, tape, floppy' so what i want is for the user to be able to click a button that says 'CD' and the query will notice that the MEDIA field will contain this bit of text, therefore will display it.

if the MEDIA field only containd 'cd' in it then i know that this would be shown using the standard SELECT query but i want the query to pick out just a bit of the text in the field.

any ideas?

any help would be appreciated

thanks
[/quote]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.