MySQL Wildcard
| From: | Karl DeSaulniers | Date: | Fri, 07 May 2010 08:46:31 +0000 |
| Subject: | MySQL Wildcard | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-47144@lists.php.net to get a copy of this message | ||
Hello All,
What I want to do is get all the fields from a table without specifying which ID to grab from.
I am trying to implement a wildcard in my query. What am I doing wrong? I keep getting...
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource"
CODE:::::
function getOptGrps($ID){
if ($ID == "All") {
$ID = "%"; // % = MySQL multi character wildcard
}
$q = "SELECT * FROM ".OPT_GRPS_TABLE." WHERE OptGrpID LIKE '$ID' ";
$result = $this->query($q);
/* Error occurred, return given name by default */
if(!$result || (mysql_numrows($result) < 1)){
return NULL;
}
/* Return result array */
$array_results = mysql_fetch_array($result);
return $array_results;
}
AND this does not work either
function getOptGrps(){
$q = "SELECT * FROM ".OPT_GRPS_TABLE;
$result = $this->query($q);
/* Error occurred, return given name by default */
if(!$result || (mysql_numrows($result) < 1)){
return NULL;
}
/* Return result array */
$array_results = mysql_fetch_array($result);
return $array_results;
}
TIA,
Karl DeSaulniers
Design Drumm
http://designdrumm.com