...

View Full Version : Doing a while statement inside a javascript problem



olidenia
11-12-2011, 02:27 PM
Hi to all!

I'm having some problems with the following script:

I need to do a while statement inside a javascript tooltip, but it's giving problems and it's not working, what am I doing wrong???


$result_events = mysql_query("SELECT * FROM `dnl_events` WHERE date='$year-$fmonth-$startdate'");
$output .= "<td id=\"$year"."-"."$fmonth"."-"."$fstartdate\" width=$width valign=top align=center onclick=\"calendar_date('$year"."-"."$fmonth"."-"."$fstartdate','$js_status','$username','e7e7e7');\" bgcolor=\"#$status_color\">

<table width=\"100%\" cellpadding=2 cellspacing=0 border=0><tr><td align=center>

<span class=\"calendar_date_number$small\"><a id=\"cal_links\" href=\"events.php?d=$startdate&m=$fmonth&y=$year\" onMouseover=\"ddrivetip('".while($row_event = mysql_fetch_array($result_events)){echo"$row_event[title]<br>";}."')\";
onMouseout=\"hideddrivetip()\">$startdate</a></span>

</td></tr></table></td>";

needsomehelp
11-12-2011, 04:44 PM
ok first thing to do here is check that there are results to use in the while statement.

change your code to this, (i have added one line just after your query line)


$result_events = mysql_query("SELECT * FROM `dnl_events` WHERE date='$year-$fmonth-$startdate'");
echo(":".mysql_num_rows($result_events).":"); exit; // this line echo's the number of results found in the previous line and then stops the page from continuing with exit;
$output .= "<td id=\"$year"."-"."$fmonth"."-"."$fstartdate\" width=$width valign=top align=center onclick=\"calendar_date('$year"."-"."$fmonth"."-"."$fstartdate','$js_status','$username','e7e7e7');\" bgcolor=\"#$status_color\">

<table width=\"100%\" cellpadding=2 cellspacing=0 border=0><tr><td align=center>

<span class=\"calendar_date_number$small\"><a id=\"cal_links\" href=\"events.php?d=$startdate&m=$fmonth&y=$year\" onMouseover=\"ddrivetip('".while($row_event = mysql_fetch_array($result_events)){echo"$row_event[title]<br>";}."')\";
onMouseout=\"hideddrivetip()\">$startdate</a></span>

</td></tr></table></td>";


let us know what number is between the :: displayed.

Inigoesdr
11-13-2011, 04:34 AM
Additionally, post the current output and any errors you get.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum