SkyRanger Posted April 24, 2007 Share Posted April 24, 2007 I am having a problem pulling info from mysql. Not sure if I need multiple select statements or if I can use 1 Here is what I I am trying to do. select * from table where fname='fname' order by 'time_sent' desc <-- This works what I am trying to do is: select * from table where fname='fname' and opened='y' and opened='n' and opened='r' order by 'time_sent' desc <-- This doesn't work the entries in opened are y, n, r, a I only want it to pull y,n,r and list them where fname='$fname' only I tried googling for a solution with very little luck. Anybody have any ideas how I can accomplish this? Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/ Share on other sites More sharing options...
Mr. R Posted April 24, 2007 Share Posted April 24, 2007 Emmm.. try select * from table where fname='fname' and opened= "'y', 'n', 'r'" order by 'time_sent' desc Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237156 Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 No, can't the "" is giving me an error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237171 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 add a backslash in front of the double quotes so it would be \" - this tells php to ignore the symbol Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237176 Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 No, it pull nothing out now. Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237185 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 try select * from table where fname='fname'and opened= 'y, n, r, a' order by 'time_sent' desc if this fails can you print the returnd values from select * from table where fname='fname' order by 'time_sent' desc EDIT: missed the a Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237187 Share on other sites More sharing options...
Mr. R Posted April 24, 2007 Share Posted April 24, 2007 could you do something like.. $sql = "select * from table where fname='fname' and opened= 'y' order by 'time_sent' desc"; $sql .= "select * from table where fname='fname' and opened= 'n' order by 'time_sent' desc"; $sql .= "select * from table where fname='fname' and opened= 'r' order by 'time_sent' desc"; $result = mysql_query($sql); not sure if it would work Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237191 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 @Mr R, it wouldn't work Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237193 Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 That code you asked me to try didn't work, came up unable to select database. And the return values for the second string pulls everything from the table where fname=$fname That works no problem just need to not show the entries where opened='a' Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237223 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 ok, do select * from table where fname='$fname' order by 'time_sent' desc and do print_r($row); i assume the data your pulling is $row['fname']; is its not $row then use what you use, the part i need is the array thats printed ~or~ can you post the code that does the displaying.. Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237229 Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 Here you go: Array ( [0] => 17 [pmid] => 17 [1] => Dave Ellis [to_name] => Dave Ellis [2] => frname [from_name] => frname [3] => 24 Apr 07 12:20 [time_sent] => 24 Apr 07 12:20 [4] => I still ... [subject] => I still ... [5] => ... msg. [message] => ... msg. [6] => y [opened] => y [7] => [time_opened] => ) Array ( [0] => 16 [pmid] => 16 [1] => Dave Ellis [to_name] => Dave Ellis [2] => frname [from_name] => frname [3] => 24 Apr 07 11:10 [time_sent] => 24 Apr 07 11:10 [4] => subj [subject] => subj [5] => msg. [message] => msg. [6] => r [opened] => r [7] => [time_opened] => ) Array ( [0] => 1 [pmid] => 1 [1] => Dave Ellis [to_name] => Dave Ellis [2] => SkyRanger [from_name] => SkyRanger [3] => 23 Apr 07 18:03 [time_sent] => 23 Apr 07 18:03 [4] => This is a test PM [subject] => This is a test PM [5] => msg [message] => msg [6] => a [opened] => a [7] => [time_opened] => ) Array ( [0] => 7 [pmid] => 7 [1] => toname [to_name] => toname [2] => frname [from_name] => frname [3] => 23 Apr 07 17:26 [time_sent] => 23 Apr 07 17:26 [4] => subj [subject] => subj [5] => msg. [message] => msg. [6] => y [opened] => y [7] => [time_opened] => ) Array ( [0] => 5 [pmid] => 5 [1] => toname [to_name] => toname [2] => frname [from_name] => frname [3] => 23 Apr 07 17:24 [time_sent] => 23 Apr 07 17:24 [4] => subj [subject] => subj [5] => msg. [message] => msg. [6] => r [opened] => r [7] => [time_opened] => ) Array ( [0] => 3 [pmid] => 3 [1] => toname [to_name] => toname [2] => frname [from_name] => frname [3] => 23 Apr 07 17:18 [time_sent] => 23 Apr 07 17:18 [4] => Testing [subject] => Testing [5] => msg [message] => msg [6] => r [opened] => r [7] => [time_opened] => ) Output modified due to user/clients privacy issues...lol Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237245 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 Ahhh i get you now Try select * from table where fname='$fname' AND opened IN ('y', 'n', 'r', 'a') order by 'time_sent' desc Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237247 Share on other sites More sharing options...
SkyRanger Posted April 24, 2007 Author Share Posted April 24, 2007 Awesome MadTechie, you have done it again. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/48494-solved-pulling-info/#findComment-237253 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.