rh91uk Posted June 22, 2006 Share Posted June 22, 2006 HiyaI 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, hehethanx,Richard Quote Link to comment https://forums.phpfreaks.com/topic/12631-query/ Share on other sites More sharing options...
obsidian Posted June 22, 2006 Share Posted June 22, 2006 [!--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--]HiyaI 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, hehethanx,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 Quote Link to comment https://forums.phpfreaks.com/topic/12631-query/#findComment-48441 Share on other sites More sharing options...
rh91uk Posted June 22, 2006 Author Share Posted June 22, 2006 Thank you kind sir ;)Am going to go try it out now! Quote Link to comment https://forums.phpfreaks.com/topic/12631-query/#findComment-48442 Share on other sites More sharing options...
rh91uk Posted June 22, 2006 Author Share Posted June 22, 2006 [!--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 162Line 162 is :[code]$result = @mysql_query('SELECT title, id, type, description, updated FROM portfolio WHERE type = 'Web Design' ORDER BY id DESC'); [/code] Quote Link to comment https://forums.phpfreaks.com/topic/12631-query/#findComment-48444 Share on other sites More sharing options...
Wildbug Posted June 22, 2006 Share Posted June 22, 2006 [!--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 162Line 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. Quote Link to comment https://forums.phpfreaks.com/topic/12631-query/#findComment-48458 Share on other sites More sharing options...
rh91uk Posted June 22, 2006 Author Share Posted June 22, 2006 Hmmm that doesnt seem to want to work eitherAny other ideas anyone? Quote Link to comment https://forums.phpfreaks.com/topic/12631-query/#findComment-48483 Share on other sites More sharing options...
Wildbug Posted June 22, 2006 Share Posted June 22, 2006 [!--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 eitherAny 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] Quote Link to comment https://forums.phpfreaks.com/topic/12631-query/#findComment-48530 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.