Loop is not working when displaying

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Loop is not working when displaying

Post by shivam0101 »

I hope i am posting in the right place, (involves both javascript and php).


i downloaded to display counter from,

http://www.dynamicdrive.com/dynamicinde ... lcount.htm

treid to implement it using a loop (i have to display counter for each event).

Code: Select all

echo "<body>";

date('M d, Y H:i:s');

$i=0;
$query_pools=mysql_query("SELECT * FROM pools");
while($fetch_pool_det=mysql_fetch_array($query_pools))
{
    $pool_draw_date=$fetch_pool_det['pool_draw_date'];
	$exp_date_time=explode(' ',$pool_draw_date);
	
	$date=$exp_date_time[0];   $time=$exp_date_time[1];
	$exp_date=explode('-', $date);
	
	$month_array=array(1=>January, February, March, April, May, June, July, August, September, October, November, December);
	$formated_date=$month_array[$exp_date[1]].' '.$exp_date[2].','.$exp_date[0];
	
    $i++;
	
    echo "<div id=\"cdcontainer_$i\"></div>
	<script language='javascript'>
	
	var launchdate=new cdLocalTime(\"cdcontainer_$i\", \"server-php\", 0, \"$formated_date $time\", \"debugmode\")
	launchdate.displaycountdown(\"days\", formatresults2)
	
	</script>"; 
}

echo "</body>";
This is displaying correctly only for one pools, for the rest of them i am getting,

Debug Mode on!
Current Local time: Monday, October 01, 2007 8:25:34 AM
Verify this is the correct current local time, in other words, time zone of count down date.

Target Time: NaN
Verify this is the date/time you wish to count down to (should be a future date).

NaN days NaN hours NaN minutes NaN seconds left until launch time
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

I think the script is wanting numbers for dates. NaN is javascript.. meaning Not a Number.
http://www.w3schools.com/jsref/jsref_NaN.asp
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

I solved it. Its displaying very well. but,

when i place it in another file (actual file) its not working.

The structure in that file is in this manner

In the php file, i am calling html file and passing the values using tags.

like this,

Code: Select all

$main_file=ReadTemplate('templates/member_main.html');
$main_file=DisplayValues(array('content' => $content, 'left_menu' => $left_menu, 'message' => $message, 'error' => $error, 'heading' => 'Pools <br/>', 'main_title'=>'Pools'), $main_file);
at the end of the file.

In the html file i am placing tags for these values.

When i run, its saying container not found
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

Its working now, but current time is not fetching,
is this correct?

Code: Select all

var servertimestring=
"

Code: Select all

<?php print date('F d, Y H:i:s', time())?>
";
Post Reply