Page 1 of 1

php not putting tables where I want them..

Posted: Mon Jan 19, 2004 3:51 am
by seeker2921
Okay, I have a blog on my site and I am using a a type of templete and I have to blog file included on my main page.. Well, When I have more then one post it doesn't put the blog tables in the correct place.. I have included the blog's code in this post and here is the site that I am having the problem with..

http://www.o-blivion.com/

Code: Select all

<? 

//main page goes below
            @include("/home/oblivion/public_html/site/blog/admin/config.php");


            //search results
			if(!empty($string)){

			$string=explode(" ",$string);
			$j=0;
			$search_worde=Array();

			for($i=0;$i<count($string);$i++) {
			if($string[$i] != "") {
			if(!ereg("^[+|-]",$string[$i])) {
			$string[$i]="+".$string[$i];
			}
			$search_worde[$j]=$string[$i];
			$j++;
			}
			}


			$mysqlquery="select * from $tb_entries";

			for($i=0;$i<count($search_worde);$i++) {
			$search_word=substr($search_worde[$i],1);
			if(ereg("^\+",$search_worde[$i])) {
			if($i==0) $mysqlquery.="where entry LIKE '%$search_word%'";
			else
			$mysqlquery.=" AND entry LIKE '%$search_word%'";
			}
			else {
			if($i==0) $mysqlquery.="where entry NOT LIKE '%$search_word%'";
			else
			$mysqlquery.=" AND entry NOT LIKE '%$search_word%'";
			}
			}

			$user_query=mysql_query("SELECT * FROM $tb_user") or die(mysql_error());
			while($array = mysql_fetch_array($user_query,MYSQL_ASSOC)) {
			    $user=$array["user"];
			    $$user=$array["email"];
			}

			$query=mysql_query($mysqlquery);

			while($row = mysql_fetch_array($query)) {
			     $j = mysql_num_fields($query);
			        for($i=0;$i<$j;$i++) {
			            $k = mysql_field_name($query,$i);
			            $$k = $row[$k];
			        }

			$entry=nl2br(stripslashes($entry));

			if($foo!=$date){
//My title for blog entry for search Function
				print("<table cellspacing="0" cellpadding="0" border=0><tr><td width="100" align="left" valign="top" style="padding: 5px"><span class="subjectheader"><img src="/site/images/bullet.gif" align="left"><i><b>$title</b></i></span><br><font size="1"><span class="timeheader"><i>$day, $date</i></span></font></td>");
				$foo=$date;
			}
//The Blog Entry For Search function
			print("<td width="375" bgcolor=000000 align="left" valign="top" style="border-top: solid 1px #516382; border-bottom: solid 1px #516382; border-left: solid 1px #516382; border-right: solid 1px #516382; padding: 5px"><img src="/site/images/bullet.gif" align="left"><i>$entry</i><br><br><i>--$author</i></td></tr></table>");

			$count=mysql_query("SELECT id FROM $tb_comments WHERE id = '$id'") or die(mysql_error());
			$count=mysql_num_rows($count);

			if($count=="0"){
				$comment="Post Comment";
			}
			if($count=="1"){
				$comment="1 Comment";
			}
			if($count>"1"){
				$comment=$count." Comments";
			}

			$email=$$author;

			print("<p align="right"><a href="/htm/blog/comments.php?id=$id">$comment</a></p>\n");
			print("<br>");
			print("<a href=/index.php><center>back</center></a>");
			}
			}
			//end search results


			//default view
			else{
			$user_query=mysql_query("SELECT * FROM $tb_user") or die(mysql_error());
			while($array = mysql_fetch_array($user_query,MYSQL_ASSOC)) {
			    $user=$array["user"];
			    $$user=$array["email"];
			}

			$query=mysql_query("SELECT * FROM $tb_entries ORDER BY id DESC LIMIT $limit") or die(mysql_error());

			while($row = mysql_fetch_array($query)) {
			     $j = mysql_num_fields($query);
			        for($i=0;$i<$j;$i++) {
			            $k = mysql_field_name($query,$i);
			            $$k = $row[$k];
			        }

			$entry=nl2br(stripslashes($entry));

			if($foo!=$date){
//Title For Blog Entry Main Page
				print("<table cellspacing="0" cellpadding="0" border=0><tr><td width="100" align="left" valign="top" style="padding: 5px"><span class="subjectheader"><img src="/site/images/bullet.gif" align="left"><i><b>$title</b></i></span><br><font size="1"><span class="timeheader"><i>$day, $date</i></span></font></td>");
				$foo=$date;
			}

			$email=$$author;
//Blog entry For Main Page
			print("<td width="375" bgcolor=000000 align="left" valign="top" style="border-top: solid 1px #516382; border-bottom: solid 1px #516382; border-left: solid 1px #516382; border-right: solid 1px #516382; padding: 5px"><img src="/site/images/bullet.gif" align="left"><i>$entry</i><br><br><i>--$author</i></td></tr></table>");

			$count=mysql_query("SELECT id FROM $tb_comments WHERE id = '$id'") or die(mysql_error());
			$count=mysql_num_rows($count);

			if($count=="0"){
				$comment="Post Comment";
			}
			if($count=="1"){
				$comment="1 Comment";
			}
			if($count>"1"){
				$comment=$count." Comments";
			}

			print("<div align="right"><a href="/site/blog/comments.php?id=$id"><font size="1"><i>$comment</i></font></a></div><br>\n");
			}
			}
			//end default view


?>
On my site I have commented on where the include function is so it will be easy to find.. Thanks for your help!!!

Posted: Mon Jan 19, 2004 7:32 am
by DuFF
Hmmm, pretty hard to debug code you didn't write, especially for an entire website. I don't have much time, but I took a picture with all the tables outlined. (Firebird Rules!)

http://www.duffdesigns.net/blogtables.jpg

Seems like the blogs keep getting put inside <td>'s or something. Check for unclosed tags.

Posted: Mon Jan 19, 2004 8:25 am
by twigletmac
Code like this:

Code: Select all

print("<table cellspacing="0" cellpadding="0" border=0><tr><td width="100" align="left" valign="top" style="padding: 5px"><span class="subjectheader"><img src="/site/images/bullet.gif" align="left"><i><b>$title</b></i></span><br><font size="1"><span class="timeheader"><i>$day, $date</i></span></font></td>");
makes debugging HTML near on impossible - there are no line breaks or other formatting to make it possible to read and so when you view source you get things like this:

Code: Select all

&lt;!-- BLOG GOES HERE --&gt;
&lt;table cellspacing="0" cellpadding="0" border=0&gt;&lt;tr&gt;&lt;td width="100" align="left" valign="top" style="padding: 5px"&gt;&lt;span class="subjectheader"&gt;&lt;img src="/site/images/bullet.gif" align="left"&gt;&lt;i&gt;&lt;b&gt;testing yet again&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;br&gt;&lt;font size="1"&gt;&lt;span class="timeheader"&gt;&lt;i&gt;Monday, January 19th, 2004&lt;/i&gt;&lt;/span&gt;&lt;/font&gt;&lt;/td&gt;&lt;td width="375" bgcolor=000000 align="left" valign="top" style="border-top: solid 1px #516382; border-bottom: solid 1px #516382; border-left: solid 1px #516382; border-right: solid 1px #516382; padding: 5px"&gt;&lt;img src="/site/images/bullet.gif" align="left"&gt;&lt;i&gt;Well, My last post didn't go where it needed to so I will see where this one goes&lt;/i&gt;&lt;br&gt;&lt;br&gt;&lt;i&gt;--Stephen&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div align="right"&gt;&lt;a href="/site/blog/comments.php?id=00005"&gt;&lt;font size="1"&gt;&lt;i&gt;Post Comment&lt;/i&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;

&lt;td width="375" bgcolor=000000 align="left" valign="top" style="border-top: solid 1px #516382; border-bottom: solid 1px #516382; border-left: solid 1px #516382; border-right: solid 1px #516382; padding: 5px"&gt;&lt;img src="/site/images/bullet.gif" align="left"&gt;&lt;i&gt;This is another test to see if this will work with the table I have set up.. Thanks&lt;/i&gt;&lt;br&gt;&lt;br&gt;&lt;i&gt;--Stephen&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div align="right"&gt;&lt;a href="/site/blog/comments.php?id=00004"&gt;&lt;font size="1"&gt;&lt;i&gt;Post Comment&lt;/i&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;
&lt;td width="375" bgcolor=000000 align="left" valign="top" style="border-top: solid 1px #516382; border-bottom: solid 1px #516382; border-left: solid 1px #516382; border-right: solid 1px #516382; padding: 5px"&gt;&lt;img src="/site/images/bullet.gif" align="left"&gt;&lt;i&gt;testing&lt;/i&gt;&lt;br&gt;&lt;br&gt;&lt;i&gt;--Stephen&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div align="right"&gt;&lt;a href="/site/blog/comments.php?id=00003"&gt;&lt;font size="1"&gt;&lt;i&gt;Post Comment&lt;/i&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;
&lt;table cellspacing="0" cellpadding="0" border=0&gt;&lt;tr&gt;&lt;td width="100" align="left" valign="top" style="padding: 5px"&gt;&lt;span class="subjectheader"&gt;&lt;img src="/site/images/bullet.gif" align="left"&gt;&lt;i&gt;&lt;b&gt;Incomplete Site&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;br&gt;&lt;font size="1"&gt;&lt;span class="timeheader"&gt;&lt;i&gt;Friday, January 16th, 2004&lt;/i&gt;&lt;/span&gt;&lt;/font&gt;&lt;/td&gt;&lt;td width="375" bgcolor=000000 align="left" valign="top" style="border-top: solid 1px #516382; border-bottom: solid 1px #516382; border-left: solid 1px #516382; border-right: solid 1px #516382; padding: 5px"&gt;&lt;img src="/site/images/bullet.gif" align="left"&gt;&lt;i&gt;Well, Apparently my blog is in working order lol.. &lt;br /&gt;
My site is still being worked on, Altho it is coming along nicely I still have alot of work to complete on it.. I'm sorry for taking so long But I have been trying a few different appproces to the design of the site including Flash among others.. Thank you and check back soon for the completed site, Also post me a comment if you think I should Include a Flash Intro to my site?&lt;/i&gt;&lt;br&gt;&lt;br&gt;&lt;i&gt;--Stephen&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div align="right"&gt;&lt;a href="/site/blog/comments.php?id=00002"&gt;&lt;font size="1"&gt;&lt;i&gt;Post Comment&lt;/i&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;
&lt;!--BLOG ENDS HERE!!--&gt;
Best thing you can do is either break out of the PHP to go into the HTML or use heredoc (here document) format - then you can format the HTML to see what's going on.

Mac