php output to ajax script problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

php output to ajax script problem

Post by manRay »

I am returning output from a php file to an ajax script. I have the php file echo a table, which is formatted properly. The problem is, when the text returns from the php file, the content inside the table footer is on top of the table. Really weird.

My Code:

Code: Select all

$table;
		
		$table .= "<table id='pageme'><thead><tr><th align='center'>Request #</th><th align='center'>Date</th><th align='center'>Subject</th><th align='center'>Status</th></tr></thead><tbody>";
		
		$get = mysql_query("SELECT * FROM support WHERE customer='$num' LIMIT $start,$perpage");
		
		while($row = mysql_fetch_row($get)) { 
 			$table .=  "<tr><td align='center'>$row[0]</td><td>$row[1]</td><td>$row[3]</td><td>$row[5]</td></tr>";
		} 
		
		$previous = $start - $perpage;
		$next = $start + $perpage;
		$table .= "</tbody><tfoot><tr>";
		
		if (!($start<=0)) {
			$table .= "<a onclick=\"LoadPage('widgets.php?start=$previous');\">prev</a>";
		}
			
		$i = 1;
		for ($x=0;$x<$num_rows;$x+=$perpage) {
			if ($start != $x)
				$table .= "<a onclick=\"LoadPage('widgets.php?start=$x');\">$i</a>";
			else
				$table .= "<b>$i</b>";
			$i++;
		}
			
		if (!($start>=($num_rows-$perpage))) {
			$table .= "<a onclick=\"LoadPage('widgets.php?start=$next');\">next</a>";
		}
			
		$table .= "</tr></tfoot></table>";
		
		echo $table;

Output Code:
Image
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: php output to ajax script problem

Post by Jade »

Your links need to be inside of a TD cell if you want them to display inside of the table otherwise it's up to the browser to figure out where to render them and as you can see, it usually ends up at the top and outside of the table completely.
Last edited by Jade on Wed Jun 30, 2010 11:50 am, edited 2 times in total.
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

[solved]php output to ajax script problem

Post by manRay »

Thanks again!
Post Reply