Re: [PHP-DB] MySQL Wildcard
function getOptGrps($ID=null){ if ($ID == All) { $ID = %; // % = MySQL multi character wildcard } $extraClause = ; if(!is_null($ID)) { $extraClause = WHERE OptGrpID LIKE '$ID' ; } $q = SELECT * FROM .OPT_GRPS_TABLE.$extraClause; $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; } On May 7, 2010, at 11:46 AM, Karl DeSaulniers wrote: ... -- Onur Yerlikaya -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Wildcard
On May 7, 2010, at 4:16 AM, Onur Yerlikaya wrote: function getOptGrps($ID=null){ if ($ID == All) { $ID = %; // % = MySQL multi character wildcard } $extraClause = ; if(!is_null($ID)) { $extraClause = WHERE OptGrpID LIKE '$ID' ; } $q = SELECT * FROM .OPT_GRPS_TABLE.$extraClause; $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; } On May 7, 2010, at 11:46 AM, Karl DeSaulniers wrote: ... -- Onur Yerlikaya Thanks Onur, but same error message. It is not setting the % as a wild card. Not sure the way around this. Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Wildcard
so sorry function getOptGrps($ID=null){ $extraClause = ; if($ID != All) { $extraClause = WHERE OptGrpID LIKE '$ID' ; } $q = SELECT * FROM .OPT_GRPS_TABLE.$extraClause; $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; } On May 7, 2010, at 12:36 PM, Karl DeSaulniers wrote: On May 7, 2010, at 4:16 AM, Onur Yerlikaya wrote: function getOptGrps($ID=null){ if ($ID == All) { $ID = %; // % = MySQL multi character wildcard } $extraClause = ; if(!is_null($ID)) { $extraClause = WHERE OptGrpID LIKE '$ID' ; } $q = SELECT * FROM .OPT_GRPS_TABLE.$extraClause; $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; } On May 7, 2010, at 11:46 AM, Karl DeSaulniers wrote: ... -- Onur Yerlikaya Thanks Onur, but same error message. It is not setting the % as a wild card. Not sure the way around this. Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Onur Yerlikaya -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql wildcard
I have an query: select * from offtime where type='$type' then I just pass the type variable to the page. Is there a wildcard in mysql like there is in sqlserver that I can use to grab all the records? such as select * from offtime where type='%' would grab all. Thanks, Eddie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql wildcard
If you want all records, remove the where clause. select * from mytable Jim ---Original Message--- From: Edward Peloke Date: Wednesday, January 08, 2003 02:03:04 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql wildcard I have an query: select * from offtime where type='$type' then I just pass the type variable to the page. Is there a wildcard in mysql like there is in sqlserver that I can use to grab all the records? such as select * from offtime where type='%' would grab all. Thanks, Eddie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php .
Re: [PHP-DB] mysql wildcard
Well, if that is your only condition, why not use: 'select * from offtime' as your query? I believe the % as a wildcard is standard SQL, so I would *think* it should work in mysql, have you tried it? -Brad Edward Peloke wrote: I have an query: select * from offtime where type='$type' then I just pass the type variable to the page. Is there a wildcard in mysql like there is in sqlserver that I can use to grab all the records? such as select * from offtime where type='%' would grab all. Thanks, Eddie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql wildcard
You probably want something like: select * from offtime where type like '{$type}%' As a side note, are you making sure that $type does not contain any malicious code? Cheers, Marco -- php|architect - The Monthly Magazine for PHP Professionals Come check us out on the web at http://www.phparch.com! ---BeginMessage--- I have an query: select * from offtime where type='$type' then I just pass the type variable to the page. Is there a wildcard in mysql like there is in sqlserver that I can use to grab all the records? such as select * from offtime where type='%' would grab all. Thanks, Eddie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql wildcard
In a message dated 1/8/03 2:48:15 PM Pacific Standard Time, [EMAIL PROTECTED] writes: I have an query: select * from offtime where type='$type' then I just pass the type variable to the page. Is there a wildcard in mysql like there is in sqlserver that I can use to grab all the records? such as select * from offtime where type='%' would grab all. Yes, MySQL has a wild card. It is % for a string of characters or _ for a single character. You can say things like where type like 'tp%'. However, if all you want to do is get all the records from a table, you can do that with: SELECT * FROM offtime Wild cards are used more for things like: SELECT * FROM offtime WHERE type LIKE 'tp%' You can also do pattern matching with regular expressions using REGEXP Janet -- Janet Valade author, PHP and MySQL for Dummies -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php