Hi I want to fetch data from a table whose first charater must be numebr not the character. The table structure is here CREATE TABLE `jos_seyret_authors` ( `id` int(11) NOT NULL auto_increment, `authorname` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; -- -- Dumping data for table `jos_seyret_authors` -- INSERT INTO `jos_seyret_authors` VALUES (14, 'Bow Bow'); INSERT INTO `jos_seyret_authors` VALUES (5, 'Kenshin'); INSERT INTO `jos_seyret_authors` VALUES (6, '50 Cent'); INSERT INTO `jos_seyret_authors` VALUES (7, 'Usher'); INSERT INTO `jos_seyret_authors` VALUES (8, 'T-Vice'); INSERT INTO `jos_seyret_authors` VALUES (9, '2Pac'); INSERT INTO `jos_seyret_authors` VALUES (10, 'Sweet Micky'); INSERT INTO `jos_seyret_authors` VALUES (11, 'Ne-Yo'); INSERT INTO `jos_seyret_authors` VALUES (12, 'The Dream'); I want to fetch this values from my sql 50 Cent 2Pac Like this many valuse will be there. Thanks in advance for your help, Pradip
MySQL doesn't have a numeric validator. But, I think something like this would work. SELECT * FROM jos_seyret_authors WHERE CONVERT(LEFT(TRIM(authorname),1), SIGNED INTEGER) IS NOT NULL
$artist_array = array(); $quer = "Select * from tablenameHere"; $result = mysql_query($quer); While($rows = mysql_fetch_assoc($result)){ if(is_int(substr($rows['authorname'], 0, 1))){ $artist_array[] = array( 'artist' => $rows['authorname'], 'id' => $rows['id'] ); } } print_r($artist_array); PHP: Try that