Jump to content

Query


rh91uk

Recommended Posts

Hiya

I haveb a php script set up, but I want the folllowing query to display only records whos type fields are set up as, "Web Design"

[code]SELECT title, id, type, description, updated FROM portfolio ORDER BY id DES[/code]

Probably simple for some people, hehe

thanx,


Richard
Link to comment
Share on other sites

[!--quoteo(post=386810:date=Jun 22 2006, 08:38 AM:name=rh91uk)--][div class=\'quotetop\']QUOTE(rh91uk @ Jun 22 2006, 08:38 AM) [snapback]386810[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hiya

I haveb a php script set up, but I want the folllowing query to display only records whos type fields are set up as, "Web Design"

[code]SELECT title, id, type, description, updated FROM portfolio ORDER BY id DES[/code]

Probably simple for some people, hehe

thanx,
Richard
[/quote]

this is where your WHERE clause comes in:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] title, id, type, description, [span style=\'color:blue;font-weight:bold\']update[/span]d [color=green]FROM[/color] [color=orange]portfolio[/color] [color=green]WHERE[/color] type [color=orange]=[/color] [color=red]'Web Design'[/color] [color=green]ORDER BY[/color] id [color=green]DESC[/color] [!--sql2--][/div][!--sql3--]

good luck
Link to comment
Share on other sites

[!--quoteo(post=386811:date=Jun 22 2006, 07:41 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Jun 22 2006, 07:41 AM) [snapback]386811[/snapback][/div][div class=\'quotemain\'][!--quotec--]
this is where your WHERE clause comes in:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] title, id, type, description, [span style=\'color:blue;font-weight:bold\']update[/span]d [color=green]FROM[/color] [color=orange]portfolio[/color] [color=green]WHERE[/color] type [color=orange]=[/color] [color=red]'Web Design'[/color] [color=green]ORDER BY[/color] id [color=green]DESC[/color] [!--sql2--][/div][!--sql3--]

good luck
[/quote]

Parse error: parse error, unexpected T_STRING in e:\domains\n\notonlybutalso.net\user\htdocs\richardcmstest\websites.php on line 162

Line 162 is :

[code]$result = @mysql_query('SELECT title, id, type, description, updated FROM portfolio WHERE type = 'Web Design' ORDER BY id DESC');
[/code]
Link to comment
Share on other sites

[!--quoteo(post=386814:date=Jun 22 2006, 08:55 AM:name=rh91uk)--][div class=\'quotetop\']QUOTE(rh91uk @ Jun 22 2006, 08:55 AM) [snapback]386814[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Parse error: parse error, unexpected T_STRING in e:\domains\n\notonlybutalso.net\user\htdocs\richardcmstest\websites.php on line 162

Line 162 is :

[code]$result = @mysql_query('SELECT title, id, type, description, updated FROM portfolio WHERE type = 'Web Design' ORDER BY id DESC');
[/code]
[/quote]

Either escape the single quotes (\') or use double quotes.
Link to comment
Share on other sites

[!--quoteo(post=386853:date=Jun 22 2006, 11:40 AM:name=rh91uk)--][div class=\'quotetop\']QUOTE(rh91uk @ Jun 22 2006, 11:40 AM) [snapback]386853[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hmmm that doesnt seem to want to work either

Any other ideas anyone?
[/quote]

If the code you've posted is what you're using, then you're getting a "unexpected T_STRING" parse error because you're using single quotes within single quotes. PHP thinks you're ending your string when you just want to quote 'Web Design.'

Use any of the following:
[code]
$result = @mysql_query('SELECT title, id, type, description, updated FROM portfolio WHERE type = "Web Design" ORDER BY id DESC');
$result = @mysql_query("SELECT title, id, type, description, updated FROM portfolio WHERE type = 'Web Design' ORDER BY id DESC");
$result = @mysql_query('SELECT title, id, type, description, updated FROM portfolio WHERE type = \'Web Design\' ORDER BY id DESC');
$result = @mysql_query("SELECT title, id, type, description, updated FROM portfolio WHERE type = \"Web Design\" ORDER BY id DESC");[/code]
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.