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
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.