runnerjp Posted October 19, 2009 Share Posted October 19, 2009 Hey guys.. for come reason my data is outputted twise shown in the image below and i cant figure out why. <html> <head> <title>Month Summary</title> <!-- change styles if you want --> <style type="text/css"> p {font-family: georgia, verdana, sans-serif; font-size: 13px; color: #333333; } h1 {font-family: georgia, verdana, sans-serif; font-size: 16px; color: #26618e; } body {background-color: #fcfcfc;} </style> </head> <body> <br/> <?php // THERE IS NO NEED TO EDIT BELOW HERE $mon = $_GET['mon']; // month from clicked month name $month = intval($mon); // var to use with month name array if (strlen($mon)==1) { $mon = "0". $mon; } $yr = $_GET['yr']; // year from clicked month name include("cal_parms.php"); include("./lang/dat_nam_en.php"); // load default language file so as not to mess anything upp with new text. include($dat_names); // retrieved from cal_parms.php as a 'language' file include("cal_db_conn.php"); mysql_connect($db_host, $db_login, $db_pass) or die ("Can't connect!"); mysql_select_db($db_name) or die ("Can't open database!"); $min_dat = $yr. "-". $mon. "-01"; $max_dat = $yr. "-". $mon. "-31"; //sloppy but effective // retrieve all events for the month $query = "SELECT * from $db_table WHERE (ev_dat>='$min_dat') AND (ev_dat<='$max_dat') ORDER by ev_dat"; $result = @mysql_db_query($db_name, $query); echo "<table width='480' cellpadding='3' cellspacing='3' align='center' style='border: thin dotted #999999;' bgcolor='#f7f7f7'><tr><td>"; while ($myrow = mysql_fetch_array($result)) // loop through all results { $found = $myrow['ev_dat']; $pieces = explode("-", $found); $monum = intval($pieces[1]); $danum = intval($pieces[2]); echo "<h1>". $danum. " ". $mo[$month]. ", ". $yr. "</h1>"; echo "<p><strong>". $EventText. ": ". $myrow['ev_title']. "</strong><br/>"; echo $LocationText. ": ". $myrow['ev_locn']. "<br/>"; echo $DetailsText. "<br/>". nl2br($myrow['ev_desc']). "</p>"; $i++; } if ($i==0) { echo "<h1>".$noEventsText." ". $mo[$month]. "</h1>"; } if ($sho == "1") { echo "<p align='right'><a href='javascript:self.close()'>".$closewindowText ."</a>"; } else { echo "<p align='right'>« <a href='javascript:history.go(-1)'>".$backToCalendar."</a></p>"; } ?> </td></tr></table> </html> </body> hopefully someone can see the reason why Thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 19, 2009 Share Posted October 19, 2009 You are either including the posted file twice or it is inside of a loop that executes twice. The fact that you have variables $i and $sho that are not initialized in the posted code but are used and cause the back/close links to be produced indicate the problem is in the code that is causing the posted code to be executed. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted October 19, 2009 Author Share Posted October 19, 2009 I just cant find where its going wrong... its also doing it for this code which poicks dates rather then month <html> <head> <title>Event Information</title> <!-- change styles if you want --> <style type="text/css"> p {font-family: georgia, verdana, sans-serif; font-size: 13px; color: #333333; } h1 {font-family: georgia, verdana, sans-serif; font-size: 16px; color: #26618e; } body {background-color: #fcfcfc;} </style> </head> <body> <br /> <?php // no need to edit below here $id = $_GET['event']; // from clicked day $sho = $_GET['sho']; // display method // mo/yr needed as well for whole month view include("cal_parms.php"); include($dat_names); // retrieved from cal_parms.php as a 'language' file include("cal_db_conn.php"); mysql_connect($db_host, $db_login, $db_pass) or die ("Can't connect!"); mysql_select_db($db_name) or die ("Can't open database!"); // retrieve record for 'clicked' days $query = "SELECT * FROM $db_table WHERE id = '$id' "; // retrieves ONE record $result = mysql_db_query($db_name, $query); $myrow = mysql_fetch_array($result); $ev_1 = $myrow['ev_dat']; // is date for that record (allows multiple events selection) $found = $myrow['ev_dat']; $pieces = explode("-", $ev_1); $monum = intval($pieces[1]); $query = "SELECT * from $db_table WHERE ev_dat = '$ev_1' "; // retrieves ALL date matches $result = mysql_db_query($db_name, $query); echo"<table width='480' cellpadding='3' cellspacing='3' align='center' style='border: thin dotted #cccccc;' bgcolor='#f7f7f7'><tr><td>"; echo "<h1>". $mo[$monum]. " ". intval($pieces[2]). ", ". intval($pieces[0]). "</h1>"; while ($myrow = mysql_fetch_array($result)) // loop through all results { echo "<p><strong> Title: ". $myrow['ev_title']. "</strong></p>"; // echo "<p>". $LocationText. ": ". $myrow['ev_locn']. "</p>"; echo "<p>". nl2br($myrow['ev_desc']). "</p><br/>"; } ?> </td></tr></table> </html> </body> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 19, 2009 Share Posted October 19, 2009 Posting a second set of code without posting the corresponding output is not really going to help, either with the problem the second code is having or with the first code and its' problem. Stick to one problem at a time. Look at the "view source" in your browser for the first problem you posted. You will probably find what I already suggested, that you are somehow including/looping through that code twice on one page. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted October 19, 2009 Author Share Posted October 19, 2009 Humm it seems the code event runs before the loop and doubles itself <?php $query = "SELECT * from $db_table WHERE (ev_dat>='$min_dat') AND (ev_dat<='$max_dat') ORDER by ev_dat"; $result = @mysql_db_query($db_name, $query); echo "<table width='480' cellpadding='3' cellspacing='3' align='center' style='border: thin dotted #999999;' bgcolor='#f7f7f7'><tr><td>"; ?> even the above taken form the top code so it dont see where im psting it twice nor looping it twice Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.