htmlstig Posted October 5, 2010 Share Posted October 5, 2010 sorry if i have posted this in the wrong place, wasnt sure wether to post here or mysql. I have made a php calendar, and i am now wanting it to show if there is an event on that day and if so show it in a tool tip. the tool tip is populated by what is in the title="" of the link so i need my events to be shown in there. I have figured out how to show the event but now i am stuck on how to show all events if there is more than one one that day, how i have set it seems to only the second event, probably as the second variable overwrote the first variable. this is the code i have at the minute .............. $result = mysql_query("SELECT * FROM events WHERE day='$day_num' AND month='$fullmonth' AND year='$year'") or die(mysql_error()); $rows= mysql_num_rows($result); if ($rows !="false"){ while($rowout = mysql_fetch_array($result)) { $todayis = $rowout['day'] ."-". $rowout['month'] ."-". $rowout['year'] ."<br>"; $title= $rowout['event'] ."<br><br>";} $firstl = "<a href='' title='". $todayis . $title ."'>"; $lastl = "</a>";} else {$firstl = ""; $lastl = "";} then to display the day and links ................. <td><? echo $firstl; ?><? print $day_num; ?><? echo $lastl; ?></td> could some one be so kind and help me write it so that it displays all events? here is a link to the calendar, incase its needed. http://www.scripttesting.htmlstig.com/calendar/index.php Many thanks Carl Link to comment https://forums.phpfreaks.com/topic/215249-repeating-mysql-stored-data/ Share on other sites More sharing options...
joel24 Posted October 6, 2010 Share Posted October 6, 2010 yes, you are overwriting the variables... you can concatenate strings into a variable with the concatenate operator ".", i.e. $test = "first part of string"; $test .= "second part of string"; echo $test; Link to comment https://forums.phpfreaks.com/topic/215249-repeating-mysql-stored-data/#findComment-1119476 Share on other sites More sharing options...
htmlstig Posted October 6, 2010 Author Share Posted October 6, 2010 cheers joel that kind of works but......... is there a way of stopping adding to the variable as if i have 2 events on one day and 1 on the next day the second day is showing all 3 events as its still adding to the variable Link to comment https://forums.phpfreaks.com/topic/215249-repeating-mysql-stored-data/#findComment-1119569 Share on other sites More sharing options...
htmlstig Posted October 6, 2010 Author Share Posted October 6, 2010 never mind iv added $title=""; before the while loop so that it resetes the variable to NULL. Many Thanks Link to comment https://forums.phpfreaks.com/topic/215249-repeating-mysql-stored-data/#findComment-1119572 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.