Hi there,
Im trying to add some pagnation to some records that are displayed on my page...I keep getting an error saying:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in line 207
that line points to:
echo("<a href=\".$_SERVER['PHP_SELF'].?page=$pageprev\">PREV</a> ");
If anybody can help me that would be super 🙂
Heres the full code:
<?php require_once('Connections/woodside.php'); ?>
<?php
// Report all PHP errors (bitwise 63 may be used in PHP 3)
error_reporting(E_ALL);
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO animalexperience (AnimalExpID, AnimalID, ExpID, Experience) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['animalexperienceid'], "int"),
GetSQLValueString($_POST['animalid'], "int"),
GetSQLValueString($_POST['select'], "int"),
GetSQLValueString($_POST['experience'], "text"));
mysql_select_db($database_woodside, $woodside);
$Result1 = mysql_query($insertSQL, $woodside) or die(mysql_error());
$insertGoTo = "add_animal_exp.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_animal = "-1";
if (isset($_GET['recordID'])) {
$colname_animal = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
}
mysql_select_db($database_woodside, $woodside);
$query_animal = sprintf("SELECT * FROM animal WHERE AnimalID = %s", $colname_animal);
$animal = mysql_query($query_animal, $woodside) or die(mysql_error());
$row_animal = mysql_fetch_assoc($animal);
$totalRows_animal = mysql_num_rows($animal);
mysql_select_db($database_woodside, $woodside);
$query_experience = "SELECT * FROM experience ORDER BY ExpID ASC";
$experience = mysql_query($query_experience, $woodside) or die(mysql_error());
$row_experience = mysql_fetch_assoc($experience);
$totalRows_experience = mysql_num_rows($experience);
$maxRows_animalexperience = 10;
$pageNum_animalexperience = 0;
if (isset($_GET['pageNum_animalexperience'])) {
$pageNum_animalexperience = $_GET['pageNum_animalexperience'];
}
$startRow_animalexperience = $pageNum_animalexperience * $maxRows_animalexperience;
mysql_select_db($database_woodside, $woodside);
$query_animalexperience = "SELECT * FROM animalexperience";
$query_limit_animalexperience = sprintf("%s LIMIT %d, %d", $query_animalexperience, $startRow_animalexperience, $maxRows_animalexperience);
$animalexperience = mysql_query($query_limit_animalexperience, $woodside) or die(mysql_error());
$row_animalexperience = mysql_fetch_assoc($animalexperience);
if (isset($_GET['totalRows_animalexperience'])) {
$totalRows_animalexperience = $_GET['totalRows_animalexperience'];
} else {
$all_animalexperience = mysql_query($query_animalexperience);
$totalRows_animalexperience = mysql_num_rows($all_animalexperience);
}
$totalPages_animalexperience = ceil($totalRows_animalexperience/$maxRows_animalexperience)-1;
[b]if(empty($page)){
$page = 1;
}
$limit = 5;
$query_count = "SELECT count(*) FROM experience";
$result_count = mysql_query($query_count);
$totalrows = mysql_result($result_count, 0, 0); [/b]
mysql_select_db($database_woodside, $woodside);
[b]$limitvalue = $page * $limit - ($limit);[/b]
$query_test = "SELECT * FROM animalexperience WHERE AnimalID='" . $row_animal['AnimalID'] . "'[b]'$limitvalue, $limit'";[/b]
$test = mysql_query($query_test, $woodside) or die(mysql_error());
$row_test = mysql_fetch_assoc($test);
$totalRows_test = mysql_num_rows($test);
mysql_select_db($database_woodside, $woodside);
$query_experiencelist = "SELECT * FROM experience WHERE ExpID NOT IN (SELECT ExpID FROM animalexperience WHERE AnimalID='" . $row_test['AnimalID'] . "')";
$experiencelist = mysql_query($query_experiencelist, $woodside) or die(mysql_error());
$row_experiencelist = mysql_fetch_assoc($experiencelist);
$totalRows_experiencelist = mysql_num_rows($experiencelist);
?>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<label>
<select name="select">
<?php
do {
?>
<option value="<?php echo $row_experiencelist['ExpID']?>"><?php echo $row_experiencelist['Experience']?></option>
<?php
} while ($row_experiencelist = mysql_fetch_assoc($experiencelist));
$rows = mysql_num_rows($experiencelist);
if($rows > 0) {
mysql_data_seek($experiencelist, 0);
$row_experiencelist = mysql_fetch_assoc($experiencelist);
}
?>
</select>
</label>
<p> </p>
<?php echo $row_test['Experience']?>
<table width="250" border="0">
<tr> <td>
<span class="style12">This Animal has Experience:</span> </td>
</tr>
<?php do { ?>
<tr> <td> </td> </tr>
<?php } while ($row_test = mysql_fetch_assoc($test)); ?>
</table>
<input name="animalexperienceid" type="hidden" id="animalexperienceid" value="<?php echo $totalRows_animalexperience +1 ?>" />
<input name="animalid" type="hidden" id="animalid" value="<?php echo $row_animal['AnimalID']; ?>" />
<input type="submit" name="Submit" value="Submit" />
<input type="hidden" name="MM_insert" value="form1">
<input name="experience" type="hidden" id="experience" value="<?php echo $row_experiencelist['Experience']?>" />
</form>
<?php
[b]$pageprev = $page-1;
if($page != 1){
echo("<a href=\".$_SERVER['PHP_SELF'].?page=$pageprev\">PREV</a> ");
}else{
echo("PREV"." ");
}
$numofpages = ceil($totalrows /$limit);
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\".$_SERVER['PHP_SELF'].?page=$i\">$i</a> ");
} }
$pagenext = $page+1;
//$new = ($limit * $page) - $totalrows; <-- and remove this part
//echo"$new";
if($page < $numofpages) {
echo("<a href=\".$_SERVER['PHP_SELF'].?page=$pagenext\">NEXT</a>");
}else{
echo("NEXT");
}[/b]
mysql_free_result($test);
mysql_free_result($animal);
mysql_free_result($experience);
mysql_free_result($user_conditional);
mysql_free_result($animalexperience);
?>
Thank You