Page 1 of 1

Loop is not working when displaying

Posted: Mon Oct 01, 2007 3:26 am
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

Posted: Mon Oct 01, 2007 3:29 am
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

Posted: Mon Oct 01, 2007 8:09 am
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

Posted: Mon Oct 01, 2007 9:06 am
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())?>
";