Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating the responsetext to return

Status
Not open for further replies.

bbsemail

MIS
Oct 29, 2003
6
US
Hi, I'm a newbie to AJAX and I'm having a bit of trouble. I have a page for a charity that has 3 horizontal divs:
1. A navigation div
2. A cage div to hold the results of queries
3. A cart div to put the surplus publications desired into

I want the contents of the cage div to change/get updated with new contents from a php call to mysql db. I want to page the results from mysql. I set up a form in the navigation div to hold the current position in the list of literature from the db. This is all working. When I click the "next" link to get more results, the javascript function updates the form field and then tries to implement an update of the cage div with AJAX and the process.php file.

I want to send the record number currently stored in the form mentioned above(navform in navigation div) to the php script, have php query the db, create a table of data and send that back to replace the current table and display the new data. The results are always blank. If I do a print_r($_GET); I see the value I expect to be passing in (the next record to retrieve)

Any help would be greatly appreciated. The test page is at:
Here are the contents of the php page:
//-- db connect
Code:
<?php require_once('../connections/hcfi.php'); ?>

<?php
if($_GET['action'] == 'getit')
{
$page = $_GET['page'];
/* this works
echo "<p>page= $page";
print_r($_GET);
$page=$_GET["page"]; 
*/
/* this works
echo "here is the page # ";
echo "page=$page<p>";
*/
$pageNum = ($page*25)-24;
//echo "pagenum=$pageNum";

$maxRows = 25;
$startRow = $pageNum;

mysql_select_db($database_hcfi, $hcfi);
$query_LitSet = "SELECT * FROM literature";
$query_limit_LitSet = sprintf("%s LIMIT %d, %d", $query_LitSet, $startRow, $maxRows);
$LitSet = mysql_query($query_limit_LitSet, $hcfi) or die(mysql_error());
$row_LitSet = mysql_fetch_assoc($LitSet);
$totalRows_LitSet = mysql_num_rows($LitSet);
$totalPages_LitSet = ceil($totalRows_LitSet/$maxRows_LitSet)-1;

$col[1]="CCCCCC";
$col[-1]="DDDDDD";
$c=1;
$result="";
do
{
	$c *= -1;
	$result.="<tr bgcolor=$col[$c] onMouseOver='this.bgColor=\"#CCFFCC\"' onMouseOut='this.bgColor=\"$col[$c]\"'>"; 
	$result.="<td align=\"right\">$row_LitSet['Price'].00 <br /><img src=\"images/basket.jpg\"></td>";
	$result.="<td>$row_LitSet['Year']; </td>";
	$result.="<td>$row_LitSet['Make']; </td>";
	$result.="<td>$row_LitSet['Title']; </td>";
	$result.="<td>$row_LitSet['Type']; </td>";
	$result.="<td>$row_LitSet['Pages']; </td>";
	$result.="<td>$row_LitSet['Size']; </td>";
	$result.="<td>$row_LitSet['Condition']; </td>";
	$result.="</tr>";
} while ($row_LitSet = mysql_fetch_assoc($LitSet));

echo $result;
}
else
{
	echo "error";
}
?>
If I alert() responseText it's always blank. 25 is the number of rows I want to display
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top