Jump to content

Archived

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

rh91uk

Query

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

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.