Disappearing sidebar

I’m trying to change the way my blog displays posts on the main page. Currently it just shows all the entries from the most recent day I posted, but I want to change it to show any entries from the last 7 days. The challenge has been to get it to echo a box with the date once for each day, rather than once for each entry. I have it ALMOST working, but when I implement the changes, my sidebar disappears!

This is my test page and the pages which are required on the test page (except config.php, which is just db login info). Everything seems to work except the sidebar.

test.php:

[code]<?

$level = ‘5’;

require(“config.php”);

#######################################################
// functions
#######################################################

// opens a box
function open_box()
{
echo "










";
}

// closes a box
function close_box()
{
echo "




";
}

// opens a bordered box
function open_b_box()
{
echo "










";
}

// closes a bordered box
function close_b_box()
{
echo "




";
}

// creates a box that displays the title of the domain, plus a variable page title or date
function title_box($domain_title, $page_title)
{
// makes the domain title global
global $domain_title;

	// opens bordered box
	open_b_box();

	// echos domain title and variable page title
	echo "<h1>$domain_title</h1><h2>- $page_title</h2>";

	// closes bordered box
	close_b_box();
}

function title_box2($page_title)
{
// opens bordered box
open_b_box();

	// echos domain title and variable page title
	echo "<h2>$page_title</h2>";

	// closes bordered box
	close_b_box();
}

// replaces names with links to photos
function photo($timestamp,$entry,$name1,$name2)
{
$sql = “SELECT * FROM gallery WHERE timestamp<’$timestamp’ AND $name1=‘1’ ORDER BY src DESC LIMIT 4”;
$result_photo = mysql_query($sql);
while($row_photo = mysql_fetch_array($result_photo))
{
$photo = $row_photo[‘id’];
}

	$entry = str_replace(' '.$name2,' <a href="http://gallery.usr-bin-mom.com/gallery.php?id='. $photo . '&amp;filter=' . $name1 . '" target="_blank">' . $name2 . '</a>',$entry);
	return $entry;
}

open_db();

// start code for copying

require(“header.php”);

$num_entries = ‘0’;
$title_box = ‘0’;

// THIS IS THE WHILE LOOP THAT IS A PROBLEM!
while($num_entries<‘7’)
{
$last_date = date(“l F d Y”,strtotime("$num_entries days ago"));

	// select entries from this day
	$result = mysql_query("SELECT * FROM journal WHERE security<$level AND FROM_UNIXTIME( timestamp, '%W %M %d %Y' ) = '$last_date' ORDER BY timestamp DESC") or die (mysql_error());

	if ($row = mysql_fetch_array($result))
		{
			if($title_box=='0')
				{
					// title box
					title_box($domain_title, $last_date);
				}
			else
				{
					// title box
					title_box2($last_date);
				}
			$title_box++;
		}
	
	// select entries from this day
	$result2 = mysql_query("SELECT * FROM journal WHERE security<$level AND FROM_UNIXTIME( timestamp, '%W %M %d %Y' ) = '$last_date' ORDER BY timestamp DESC") or die (mysql_error());

	// for these entries...
	while ($row = mysql_fetch_array($result2))
		{
			extract($row);

			// gets time
			$time = date("h:i a",$timestamp);

			// opens bordered box
			open_b_box();
			
			$entry = photo($timestamp,$entry,'Mark','mark');
			$entry = photo($timestamp,$entry,'Aryanna','aryanna');
			$entry = photo($timestamp,$entry,'Aryanna','anna');
			$entry = photo($timestamp,$entry,'Aoghdan','aoghdan');
			$entry = photo($timestamp,$entry,'Seamus','seamus');
			$entry = photo($timestamp,$entry,'Hamish','hamish');
			$entry = photo($timestamp,$entry,'Sinead','sinead');

			// title and entry
			echo "<h3>$title</h3><br>$entry";

			// if there is a prayer...
			if ($blessing)
				{
					// prayer icon and prayer
					echo "<br><br><img src="images/prayer.gif"> $blessing";
				}

			// time posted
			echo "<br><br>posted @ $time -- ";
			
			// creates comment link
			$result_nineteen = mysql_query ("SELECT id FROM comments WHERE entry=$id");
			$num_rows = mysql_num_rows($result_nineteen);
	
			if($num_rows)
				{
					echo "<a href="index.php?page=entry&amp;id=$id">comments ($num_rows)</a>";
				}
			else
				{
					echo "<a href="index.php?page=entry&amp;id=$id">comments</a>";
				}

			// closes bordered box
			close_b_box();
		}

	$num_entries++;
}

require(“footer.php”);
?>[/code]

header.php:

[code]

<? global $usrbinmom_layout_cookie; if(!$usrbinmom_layout_cookie) { open_db(); $result=mysql_query("SELECT skin AS usrbinmom_layout_cookie FROM users WHERE id='1'"); while($row=mysql_fetch_array($result)) { extract($row); } } function header_middle() { print" "; } if($usrbinmom_layout_cookie == "cebu") { // stylesheet print" #!/usr/bin/mom: song of the cebu td { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} h1 { margin : 0px; font-size : 16px;} h2 { margin : 0px; font-size : 10px;} h3 { margin : 0px; font-size : 10px;} A.footer { color:#cccccc; } .footer { color: #cccccc; } .box1 { background-color : #e6d8d4; border : 1px solid #000000; text-align : justify; TEXT-TRANSFORM: lowercase;} .box2 { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} .box3 { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} "; header_middle(); // begin layout print"
"; } elseif($usrbinmom_layout_cookie == "nobody") { $year_for_link = date('Y'); // stylesheet print" #!/usr/bin/mom: my friend's name is nobody td,form { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} h1 { margin : 0px; font-size : 16px;} h2 { margin : 0px; font-size : 10px;} h3 { margin : 0px; font-size : 10px;} A.footer { color:#cccccc; } .footer { color: #cccccc; } .box1 { background-color : #ffffff; border : 1px solid #000000; text-align : justify; TEXT-TRANSFORM: lowercase;} .box2 { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} .box3 { background-color : #ffffff; border : 1px solid #000000; text-align : justify; TEXT-TRANSFORM: lowercase;} "; header_middle(); // begin layout print"
I've got a friend that you can't see.  My friend's name is Nobody.




home







archives







journal



"; } elseif($usrbinmom_layout_cookie == "prolife") { // stylesheet print" #!/usr/bin/mom: my mommy is pro-life td { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} A { color: #000000; } A.footer { color: #E8D4F2; } .footer { color: #E8D4F2; } h1 { margin : 0px; font-size : 16px; color: #E8D4F2;} h2 { margin : 0px; font-size : 10px;} h3 { margin : 0px; font-size : 10px;} .caption { font-weight: bold; margin-top: 10px; font-size: 13px; color: #E8D4F2; border-bottom: 1px solid #E8D4F2;} .box1 { background-color : #9F92A6; border : 2px solid #000000; text-align : justify; TEXT-TRANSFORM: lowercase;} .box2 { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} .box3 { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} .photo {border: 2px solid #000000; border-bottom: 7px solid #000000;} "; header_middle(); // begin layout print"
"; } elseif($usrbinmom_layout_cookie == "taste") { // stylesheet print" #!/usr/bin/mom: a little taste td { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} h1 { margin : 0px; font-size : 16px;} h2 { margin : 0px; font-size : 10px;} h3 { margin : 0px; font-size : 10px;} A.footer { color:#000000; } .footer { color: #000000; } .box1 { background-color : #ffffff; border : 1px solid #756d47; text-align : justify; TEXT-TRANSFORM: lowercase;} .box2 { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} .box3 { background-color : #ffffff; border : 1px solid #756d47; text-align : justify; TEXT-TRANSFORM: lowercase;} div.header {position: absolute; left: 100px; top: 30px; width: 400px; } div.content {position: absolute; left: 100px; top: 100px; width: 400px; } div.girl {position: absolute; left: 525px; top: 30px; width: 220px; } div.sidebar {position: absolute; left: 634px; top: 318px; width: 275px; } "; header_middle(); // begin layout print"

"; } elseif($usrbinmom_layout_cookie == "photo") { // stylesheet print" #!/usr/bin/mom: photo finish td { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} h1 { margin : 0px; font-size : 16px;} h2 { margin : 0px; font-size : 10px;} h3 { margin : 0px; font-size : 10px;} A.footer { color:#000000; } .footer { color: #000000; } .box1 { text-align : justify; TEXT-TRANSFORM: lowercase;} .box2 { font-family : Verdana,Geneva,Arial,sans-serif; font-size : 10px; text-align : justify; TEXT-TRANSFORM: lowercase;} .box3 { text-align : justify; TEXT-TRANSFORM: lowercase;} .border {position: absolute; left: 0px; top: 30px; right: 0px; } .title {position: absolute; left: 315px; top: 30px; } .photo1 {position: absolute; left: 25px; top: 150px; border: 0px } .photo2 {position: absolute; left: 25px; top: 365px; border: 0px } .photo3 {position: absolute; left: 25px; top: 580px; border: 0px } .photo4 {position: absolute; left: 25px; top: 795px; border: 0px } .photo5 {position: absolute; left: 25px; top: 1010px; border: 0px } .top { background-color : #aa997c; position: absolute; top: 0px; left: 250px; width: 400px; height: 150px; } .content { background-color : #aa997c; position: absolute; top: 150px; left: 250px; width: 400px; } div.sidebar { background-color : #aa997c; position: absolute; left: 675px; top: 150px; width: 275px; } "; header_middle(); // begin layout print"
"; } ?>[/code]

footer.php:

[code]<?

global $usrbinmom_layout_cookie;

if($usrbinmom_layout_cookie == “cebu”)
{
$year_for_link = date(‘Y’);
echo"












this is a song about a boy.  a song about a little boy and his cebu.  a song about a little boy and his three cebu.  the little boy who had a sick cebu, a sad cebu and a mute cebu.  and also a hippo.














journal














archives














journal



";
					sidebar();
	echo"
				</td>
			</tr>
		</table>
		<br>";
}

elseif($usrbinmom_layout_cookie == “prolife”)
{
$year_for_link = date(‘Y’);
echo"

";
open_box();
	rand_photo();

	echo"<div align="center"><a href="index.php">home</a> &middot; <a href="index.php?page=archives&amp;year=$year_for_link">archives</a> &middot; <a href="index.php?page=about">about</a> &middot; <a href="http://darkflame.org/prolife" target="_blank">pro-life</a></div>";
	close_box();
	open_box();
	sidebar();
	close_box();
	echo"</td></tr></table><br>";
}

elseif($usrbinmom_layout_cookie == “nobody”)
{
$year_for_link = date(‘Y’);
echo"

";
					sidebar();
	echo"
				</td>
			</tr>
		</table>
		<br>";
}

elseif($usrbinmom_layout_cookie == “taste”)
{
$year_for_link = date(‘Y’);
echo "

	<div class = "girl"><a href="http://www.artrenewal.org/asp/database/image.asp?id=24" target="_blank"><img src="images/Le_gouter_scaled.gif" border="0"></a></div>
				
	<div class="sidebar">";
	open_b_box();
	echo "<b>site menu</b><br><br> &middot; <a href="index.php">recent works of art</a><br> &middot; <a href="index.php?page=archives&amp;year=2005">the museum archives</a><br> &middot; <a href="index.php?page=about">about the artist</a>";
	close_b_box();
	sidebar();
	echo "</div>
	</td></tr></table><center>";
}

elseif($usrbinmom_layout_cookie == “photo”)
{
$year_for_link = date(‘Y’);
echo "






	<div class="sidebar">";
	open_b_box();
	echo "<b>site menu</b><br><br> &middot; <a href="index.php">recent entries</a><br> &middot; <a href="index.php?page=archives&amp;year=2005">archives</a><br> &middot; <a href="index.php?page=about">about me</a>";
	close_b_box();
	sidebar();
	echo "</div>		
	</td></tr></table><center>";
}
		?>
		<table width="700" class="box2">
			<tr>
				<td>
					<center><font class="footer"><br><br>veggietales images and lyrics &copy; big idea &middot; nobody lyrics &copy; trout fishing in america &middot; photos of prolife babies belong to their parents &middot; <i>le gouter</i> was painted by William Bouguereau<br>this journal is powered by me &middot; all code and content &copy;2000 - <? echo date("Y"); ?> michelle potter except where noted otherwise<br><A class="footer" HREF="http://www.hostedscripts.com/scripts/antispam.html" target="_blank">Fight Spam! Click Here!</A> &middot; <a class="footer" href="http://validator.w3.org/check?uri=http://usr-bin-mom.com" target="_blank">Valid HTML 4.01</a> &middot; <a class="footer" href="http://jigsaw.w3.org/css-validator/validator?uri=http://usr-bin-mom.com" target="_blank">Valid CSS</a></font></center>
				</td>
			</tr>
		</table>
	</center>
</body>
[/code]

sorry, but could you try and narrow it down a bit. Atleast let us know what you have tried.

I, nor others, have the desire to chug through your whole page of code, without some idea of where to narrow it down to.

Also what have you tried to debug it? What were the results? GIve us more to go on.

Sponsor our Newsletter | Privacy Policy | Terms of Service