- The field name page comes from the section where you say:
if($i == $page){ echo " [$i] "; }
else{ echo " <strong><a href='?page=$i'>$i</a></strong> "; }
}
if(($numrows % $limit) != 0){
if($i == $page){ echo " [$i] "; }
else{ echo " <strong><a href='?page=$i'>$i</strong></b> "; }
}
Do you see how you have <a href='?page= $i ?
That is where $_GET['page'] comes from, you are passing the GET variable (when passing it in the URL it is a GET request.
- Its a notice that $_GET['page'] doesnt exist, at the top of your code, RIGHT BELOW <?php add the following
error_reporting(E_ALL ^ E_NOTICE);
This will suppress notice's
With question #3,
lscruiser wrote:
3. On line 25 I need to rename the value of "yes" to where it displays all the results of the column ename.
I am not sure, what is the value ename? That is a column name, you may not need that at all.
You can try removing that, you are essentially telling the SQL to give you data where the value of the 'ename' column is yes, when I provided the example on how to do this, I had taken this from a portion of my code that needed it, if you don't need it, remove it.
It seems as if you are trying to pull a POST of the variable PAGE but i don't see you using POST anywhere.
I had made some recommendations in the code below and made a couple changes, I hope this helps..
<?php
error_reporting(E_ALL ^ E_NOTICE); // supress notice's
$db = odbc_connect('','',''); //put your connection here
function inv_rows($r1) {
ob_start();
(int)$number=odbc_result_all($r1);
ob_clean();
return $number;
}
// Setting the $max as 5, as in 5 results PER PAGE.
$max = 5; // using this instead of limit
// if you havn't specified page (as in they clicked on next page) set $start as 0 (i think, may need to be 1)
// If they have specified it, get the 'page' from the URL (?page=#) and be sure its a number. (thats what (int) does)
// Then set the $page (page number) and the start, is the number of pages * limit, i.e. page 1 is 5, 2 is 10, etc.
if (!isset($_GET['page']) || empty($_GET['page'])) {
$page = (int)$_GET['page']; //question about this line 20 - Notice: Undefined index: page
$start = ($page * $max);
} else {
$start = 0;
}
$query = "SELECT * FROM plastic"; //name of table is plastic with columns plastic_ID, ename, and iname.
$num_result = odbc_exec($db, $query);
$numrows = inv_rows($num_result);
echo '<p>There are '.$numrows.' ideas.</p>'; // I am assuming this works
// Example: Page 2, start will be 10
// Example SQL Query: Select top 5 * FROM plastic WHERE plastic_id is not in the top 10 items, thus you get 11-15...
$sql = "SELECT TOP $max * FROM plastic WHERE (plastic_ID NOT IN (SELECT TOP $start plastic_ID FROM plastic ORDER BY plastic_ID)) ";//question about this line 25
$result = odbc_exec($db, $sql);
while(odbc_fetch_row($result)){
?>
<table style="width: 600;">
<tr>
<td style="width: 300; height: 25px;">Name:</td>
<td style="width: 300; height: 25px;">Idea Name:</td>
</tr>
<tr>
<td style="width: 300; height: 25px;"><?php echo odbc_result($result, "ename"); ?></td>
<td style="width: 300; height: 25px;"><?php echo odbc_result($result, "iname"); ?></td>
</tr>
<tr>
<td colspan="5" style="height: 25px"><hr/></td>
</tr>
</table>
<?php //PREVIOUS AND NEXT BUTTONS
}
if($page !=1){
$pageprev = $page - 1;
echo ' <strong><a href="?page='.$pageprev.'">PREV</a></strong> '; }
else{ echo " PREV "; }
$numofpages = $numrows / $max;
for($i = 1; $i <= $numofpages; ++$i){
if($i == $page){ echo " [$i] "; }
else{ echo " <strong><a href='?page=$i'>$i</a></strong> "; }
}
if(($numrows % $max) != 0){
if($i == $page){ echo " [$i] "; }
else{ echo " <strong><a href='?page=$i'>$i</strong></b> "; }
}
if(($numrows - ($max * $page)) > 0){
$pagenext = $page + 1;
echo " <strong><a href='?page=$pagenext'>NEXT</a></strong> "; }
else{ echo " NEXT "; }
odbc_free_result($result);
exit;
?>