Announcement

Collapse
No announcement yet.

Using IN within an sql query. How to pull multiple rows

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using IN within an sql query. How to pull multiple rows

    Code:
    $query = $db->query_read("SELECT value, varname FROM ".TABLE_PREFIX."setting WHERE varname IN ('minuserlength','maxuserlength','illegalusernames')");
    I am trying to pull the values for all three of the above fields using one sql query. I have tried numerous variations of queries/fetches; sadly the results always result in a resource id or:
    Code:
    Array ( [value] => admin moderator op9 option9 option.9 forum vbulletin [varname] => illegalusernames )
    Please help me understand why only this row is being placed in the array.


    Straight from phpMyAdmin:
    Click image for larger version

Name:	phpMyAdmin SQL Result.jpg
Views:	1
Size:	71.4 KB
ID:	3724621

    - - - Updated - - -

    [RESOLVED]
    Code:
    $query = $db->query_read("SELECT value, varname FROM ".TABLE_PREFIX."setting WHERE varname IN ('minuserlength','maxuserlength','illegalusernames')");
    while ($results = $db->fetch_array($query)) {//do stuff}
    Last edited by nullified; Sat 8th Sep '12, 7:31pm. Reason: Resolved
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X