RSS Forums RSS
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Can anyone help me?

Join Date: Jul 2008
Posts: 3
Reputation: Keased is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Keased Keased is offline Offline
Newbie Poster

Can anyone help me?

  #1  
Jul 18th, 2008
HI i would be more than thankful if anybody can tell me why this don't work,
the problem is that the JS counter won't work when there are more then 1 entrys in mysql.
With one entry the script runs fine.
Heres the code:
<table>
<?
//Connect to mysql server
	$link = mysql_connect("database connect works","...","...");
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	//Select database
	$db = mysql_select_db("niisama");
	if(!$db) {
		die("Unable to select database");
	}
$asjad = mysql_query("SELECT aegs,aegm,aegh,aegp,aegk,aega FROM tehingud;");
	if (mysql_num_rows($asjad) == 0) break;
		while ($asi = mysql_fetch_array($asjad))
		{?>
		<table width="200" border="0">
  <tr>
   <tr>
    <th scope="row">Aega Jäänud</th>
    <td>
    
    
	<form name="counter"><input type="text" size="8" 
name="d2"></form> <script> 
<!-- 
// 
		
<?
	$aegs=60-date("s" ,time());
	$aegm=$asi[aegm]-date("i" ,time())-1;
	$pkuus=$asi[aegp]-date("d" ,time());
	if($pkuus<0)
	{
	$pkuus=date("t" ,time())-date("d" ,time())+$asi[aegp];
	}
	
	$aegh=$pkuus*24+$asi[aegh]-date("H" ,time());
	if($aegm<0)
	{
	$aegh-=1;
	$aegm=60+$aegm;
	}
	$aegp=$asi[aegm];
	$aegk=$asi[aegm];
	$aega=$asi[aegm];
	?>
 var milisec=0;
 var seconds= <?=$aegs?>; 
 var minutes= <?=$aegm?>;
 var hours= <?=$aegh?>;
 document.counter.d2.value='30' 

function display(){ 
 if (milisec<=0){ 
    milisec=9 
    seconds-=1 
 } 
 if (seconds<=-1){ 
    seconds=59 
    minutes-=1 
 } 
  if (minutes<=-1){ 
    minutes=59 
    hours-=1 
 } 
 if (seconds<=-1){ 
    milisec=0 
    seconds+=1 
 } 
 else 
    milisec-=1;
    document.counter.d2.value=hours+":"+minutes+":"+seconds;
    setTimeout("display()",100) 
} 
display() 
--> 
</script> </td>
</td>
  </tr>
</table>
<br />
<?
}
?>
</table>
AddThis Social Bookmark Button
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:52 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC