popcornplya Posted October 26, 2008 Share Posted October 26, 2008 How do I select stuff from database that start with numbers? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/ Share on other sites More sharing options...
Lodius2000 Posted October 26, 2008 Share Posted October 26, 2008 if you mean database (mysql) column names that start with numbers... you dont, db columns, like php variables cant start with numbers Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-675239 Share on other sites More sharing options...
popcornplya Posted October 26, 2008 Author Share Posted October 26, 2008 No, If I have movies in my database (mysql) called 007 whatever 123 ways to be cool like popcorn plya a cool way to be me how can I get the ones that start with numbers only Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-675249 Share on other sites More sharing options...
Twister1004 Posted October 27, 2008 Share Posted October 27, 2008 I could be wrong, but to call out stuff in the database you need to use the select statement in php and all that stuff. *~I did not try it!~* <?php $selectmovie = mysql_query("SELECT * FROM `table here` WHERE `column name here` = 'movie here'"); echo $selectmovie; ?> Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-675269 Share on other sites More sharing options...
popcornplya Posted October 27, 2008 Author Share Posted October 27, 2008 I could be wrong, but to call out stuff in the database you need to use the select statement in php and all that stuff. *~I did not try it!~* <?php $selectmovie = mysql_query("SELECT * FROM `table here` WHERE `column name here` = 'movie here'"); echo $selectmovie; ?> Lol, thanks for the reply but I don't think you understand my question clearly. Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-675278 Share on other sites More sharing options...
Twister1004 Posted October 27, 2008 Share Posted October 27, 2008 Well as long as the movie liek 007 is in quotes ('') or ("") then it shouldent effect you. Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-675281 Share on other sites More sharing options...
popcornplya Posted October 27, 2008 Author Share Posted October 27, 2008 Well as long as the movie liek 007 is in quotes ('') or ("") then it shouldent effect you. Effect me in what? Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-675287 Share on other sites More sharing options...
Lodius2000 Posted October 27, 2008 Share Posted October 27, 2008 my brains not working tonight but heres a couple of ideas -regex in the query identifying the first character as numeric or not (not for sure if mysql supports php regex) - return all the movie titles and shorten them all to 1 character and run is_numeric() on them, but, im really tired and cant remember how to shorten a string, nor can i figure out how to get those results back to the query to get you the right movie titles in their entirety //should get you thinking EDIT: regex is your best bet, query the db for all results, run a preg_match and foreach the results but im terrible at regex so dont ask me //dunno why this got moved Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-675290 Share on other sites More sharing options...
Lodius2000 Posted October 27, 2008 Share Posted October 27, 2008 EDIT: regex is your best bet, query the db for all results, run a preg_match and foreach the results but im terrible at regex so dont ask me //dunno why this got moved Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-675296 Share on other sites More sharing options...
popcornplya Posted October 27, 2008 Author Share Posted October 27, 2008 Anything else? Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-676035 Share on other sites More sharing options...
fenway Posted October 28, 2008 Share Posted October 28, 2008 Anything else? What was wrong with: WHERE yourColumn REGEXP '[0-9]%' Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-676590 Share on other sites More sharing options...
mrmitch Posted October 28, 2008 Share Posted October 28, 2008 Adding the carat before the group will search at the beginning of the movie name only, so the movie has to start with a number. REGEXP '^[0-9]%' Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-676760 Share on other sites More sharing options...
fenway Posted October 30, 2008 Share Posted October 30, 2008 Yeah, that. Quote Link to comment https://forums.phpfreaks.com/topic/130202-help/#findComment-678526 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.