CecilDL Posted November 9, 2007 Share Posted November 9, 2007 My php code: <?php $sql = "SELECT movieid FROM showtimes WHERE curdate() BETWEEN st AND en"; $query = mysql_query($sql,$db); $output = mysql_fetch_array($query, MYSQL_NUM); $takenmovies = implode(",",$output); ?> When I run that sql statement on phpmyadmin, I get 4 rows. When it's run in my page, I get 1 result; always just the first row. st is startdate, and en is enddate for my date range. WHY??????? sql table, with data in it: CREATE TABLE `showtimes` ( `id` tinyint(10) NOT NULL auto_increment, `st` date NOT NULL, `en` date NOT NULL, `movieid` tinyint(10) NOT NULL, `times` text collate latin1_general_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=5 ; INSERT INTO `showtimes` VALUES (1, '2007-11-02', '2007-11-08', 2, '1:05,3:50,7:00,9:50'); INSERT INTO `showtimes` VALUES (2, '2007-11-02', '2007-11-08', 3, '1:15,4:10'); INSERT INTO `showtimes` VALUES (3, '2007-11-02', '2007-11-08', 9, '1:25,6:45'); INSERT INTO `showtimes` VALUES (4, '2007-11-02', '2007-11-08', 12, '9:45'); (hope I've given enough information) Thankyou for reading. Quote Link to comment https://forums.phpfreaks.com/topic/76596-sql-query-isnt-pulling-what-it-should/ Share on other sites More sharing options...
teng84 Posted November 9, 2007 Share Posted November 9, 2007 $sql = "SELECT movieid FROM showtimes WHERE curdate() BETWEEN st AND en"; $query = mysql_query($sql,$db); while($output = mysql_fetch_array($query, MYSQL_NUM)){ $takenmovies[]= $output; } print_r($takenmovies); //$takenmovies = implode(",",$output); Quote Link to comment https://forums.phpfreaks.com/topic/76596-sql-query-isnt-pulling-what-it-should/#findComment-387937 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.