Page 1 of 1

php output to ajax script problem

Posted: Wed Jun 30, 2010 7:05 am
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

Re: php output to ajax script problem

Posted: Wed Jun 30, 2010 7:45 am
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.

[solved]php output to ajax script problem

Posted: Wed Jun 30, 2010 8:49 am
by manRay
Thanks again!