Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/76596-sql-query-isnt-pulling-what-it-should/
Share on other sites

$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);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.