Pass Variables to Next Page

I have a search class with pagination and I can get the first page to display correctly but the next page gives a bunch of undefined index(s). I know i need to pass the variables to the next page but it uses one “View” and a “Class”.

Here is the search function:

<?php

class Search extends MainController{
	function __construct(){
			parent::__construct();
			$this->view->url	=	$this->config->url;
			$this->view->ID 	  = get_class($this);
			$this->view->Title = "Diablo 3 Online Auction House";
			$this->view->msg = "";
			$this->view->err = false;


            $itemName = isset($_POST['item_name']) ? $_POST['item_name'] : '';
            $val_1 = $_POST['attrib1'];
            $val_2 = $_POST['attrib2'];
            $val_3 = $_POST['attrib3'];
            $val_4 = $_POST['attrib4'];
            $val_5 = $_POST['attrib5'];
            $val_6 = $_POST['attrib6'];
            $val_7 = $_POST['attrib7'];
            $val_8 = $_POST['attrib8'];
            $itemAttrib1 = $_POST['list_1'];
            $itemAttrib2 = $_POST['list_2'];
            $itemAttrib3 = $_POST['list_3'];
            $itemAttrib4 = $_POST['list_4'];
            $itemAttrib5 = $_POST['list_5'];
            $itemAttrib6 = $_POST['list_6'];
            $itemAttrib7 = $_POST['list_7'];
            $itemAttrib8 = $_POST['list_8'];
            $Quality = $_POST['quality'];
            $Type = $_POST['type'];
            $sub_Type = $_POST['sub'];

            $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
            // If the page wasn't set, lets set $page to number 1 for the first page
            $sql = "SELECT * FROM items_us_sc WHERE item_name = :item_name AND quality = :quality AND type = :type AND sub_type = :sub
                AND ((attrib_1 = :prop1 AND value_1 >= :val1 OR attrib_2 = :prop1 AND value_2 >= :val1 OR attrib_3 = :prop1 AND value_3 >= :val1 OR attrib_4 = :prop1 AND value_4 >= :val1 OR attrib_5 = :prop1 AND value_5 >= :val1 OR attrib_6 = :prop1 AND value_6 >= :val1 OR attrib_7 = :prop1 AND value_7 >= :val1 OR attrib_8 = :prop1 AND value_8 >= :val1)
                AND (attrib_1 = :prop2 AND value_1 >= :val2 OR attrib_2 = :prop2 AND value_2 >= :val2 OR attrib_3 = :prop2 AND value_3 >= :val2 OR attrib_4 = :prop2 AND value_4 >= :val2 OR attrib_5 = :prop2 AND value_5 >= :val2 OR attrib_6 = :prop2 AND value_6 >= :val2 OR attrib_7 = :prop2 AND value_7 >= :val2 OR attrib_8 = :prop2 AND value_8 >= :val2)
                AND (attrib_1 = :prop3 AND value_1 >= :val3 OR attrib_2 = :prop3 AND value_2 >= :val3 OR attrib_3 = :prop3 AND value_3 >= :val3 OR attrib_4 = :prop3 AND value_4 >= :val3 OR attrib_5 = :prop3 AND value_5 >= :val3 OR attrib_6 = :prop3 AND value_6 >= :val3 OR attrib_7 = :prop3 AND value_7 >= :val3 OR attrib_8 = :prop3 AND value_8 >= :val3)
                AND (attrib_1 = :prop4 AND value_1 >= :val4 OR attrib_2 = :prop4 AND value_2 >= :val4 OR attrib_3 = :prop4 AND value_3 >= :val4 OR attrib_4 = :prop4 AND value_4 >= :val4 OR attrib_5 = :prop4 AND value_5 >= :val4 OR attrib_6 = :prop4 AND value_6 >= :val4 OR attrib_7 = :prop4 AND value_7 >= :val4 OR attrib_8 = :prop4 AND value_8 >= :val4)
                AND (attrib_1 = :prop5 AND value_1 >= :val5 OR attrib_2 = :prop5 AND value_2 >= :val5 OR attrib_3 = :prop5 AND value_3 >= :val5 OR attrib_4 = :prop5 AND value_4 >= :val5 OR attrib_5 = :prop5 AND value_5 >= :val5 OR attrib_6 = :prop5 AND value_6 >= :val5 OR attrib_7 = :prop5 AND value_7 >= :val5 OR attrib_8 = :prop5 AND value_8 >= :val5)
                AND (attrib_1 = :prop6 AND value_1 >= :val6 OR attrib_2 = :prop6 AND value_2 >= :val6 OR attrib_3 = :prop6 AND value_3 >= :val6 OR attrib_4 = :prop6 AND value_4 >= :val6 OR attrib_5 = :prop6 AND value_5 >= :val6 OR attrib_6 = :prop6 AND value_6 >= :val6 OR attrib_7 = :prop6 AND value_7 >= :val6 OR attrib_8 = :prop6 AND value_8 >= :val6)
                AND (attrib_1 = :prop7 AND value_1 >= :val7 OR attrib_2 = :prop7 AND value_2 >= :val7 OR attrib_3 = :prop7 AND value_3 >= :val7 OR attrib_4 = :prop7 AND value_4 >= :val7 OR attrib_5 = :prop7 AND value_5 >= :val7 OR attrib_6 = :prop7 AND value_6 >= :val7 OR attrib_7 = :prop7 AND value_7 >= :val7 OR attrib_8 = :prop7 AND value_8 >= :val7)
                AND (attrib_1 = :prop8 AND value_1 >= :val8 OR attrib_2 = :prop8 AND value_2 >= :val8 OR attrib_3 = :prop8 AND value_3 >= :val8 OR attrib_4 = :prop8 AND value_4 >= :val8 OR attrib_5 = :prop8 AND value_5 >= :val8 OR attrib_6 = :prop8 AND value_6 >= :val8 OR attrib_7 = :prop8 AND value_7 >= :val8 OR attrib_8 = :prop8 AND value_8 >= :val8))";
                $arr = array(":item_name" => $itemName, ":quality" => $Quality, ":type" => $Type, ":sub" => $sub_Type, ":prop1" => $itemAttrib1, ":val1" => $val_1, ":val2" => $val_2, ":val3" => $val_3, ":val4" => $val_4, ":val5" => $val_5, ":val6" => $val_6, ":val7" => $val_7, ":val8" => $val_8, ":prop2" => $itemAttrib2, ":prop3" => $itemAttrib3, ":prop4" => $itemAttrib4, ":prop5" => $itemAttrib5, ":prop6" => $itemAttrib6, ":prop7" => $itemAttrib7, ":prop8" => $itemAttrib8);
            $ctr = $this->database->DBCtr($sql,$arr);
            $this->view->count = $ctr;

            // Lets set how many messages we want to display
            $per_page = "5";

            // Now we must calculate the last page
            $last_page = ceil($ctr/$per_page);

            // And set the first page
            $first_page = "1";

            // Here we are making the "First page" link
            if ($page == $first_page){
                $this->view->first = "<li class='disabled'><a href='?page=".$first_page."'>First page</a></li>";
            }else{
                $this->view->first = "<li><a href='?page=".$first_page."'>First page</a></li>";
            }

            // If page is 1 then remove link from "Previous" word
            if($page == $first_page){
                $this->view->prev = "<li class='disabled'><a>Previous</a></li>";
            }else{
                if(!isset($page)){
                    $this->view->prev = "<li><a>Previous</a></li>";
                }else{
                    // But if page is set and it's not 1.. Lets add link to previous word to take us back by one page
                    $previous = $page-1;
                    $this->view->prev = "<li><a href='?page=".$previous."'>Previous</a></li>";
                }
            }

            // If the page is last page.. lets remove "Next" link
            if($page == $last_page){
                $this->view->next = "<li class='disabled'><a>Next</a></li>";
            }else{
                // If page is not set or it is set and it's not the last page.. lets add link to this word so we can go to the next page
                if(!isset($page)){
                    $next = $first_page+1;
                    $this->view->next = "<li><a href='?page=".$next."'>Next</a></li> ";
                }else{
                    $next = $page+1;
                    $this->view->next = "<li><a href='?page=".$next."'>Next</a></li>";
                }
            }

            // And now lets add the "Last page" link
            if ($page == $last_page){
                $this->view->last = "<li class='disabled'><a href='?page=".$last_page."'>Last page</a></li>";
            }else{
                $this->view->last = "<li><a href='?page=".$last_page."'>Last page</a></li>";
            }

            // Math.. It gets us the start number of message that will be displayed
            $start = (($page * $per_page) - $per_page);

            // Now lets set the limit for our query
            $limit = "LIMIT $start, $per_page";


    			$sql = "SELECT * FROM items_us_sc WHERE item_name = :item_name AND quality = :quality AND type = :type AND sub_type = :sub
    			AND ((attrib_1 = :prop1 AND value_1 >= :val1 OR attrib_2 = :prop1 AND value_2 >= :val1 OR attrib_3 = :prop1 AND value_3 >= :val1 OR attrib_4 = :prop1 AND value_4 >= :val1 OR attrib_5 = :prop1 AND value_5 >= :val1 OR attrib_6 = :prop1 AND value_6 >= :val1 OR attrib_7 = :prop1 AND value_7 >= :val1 OR attrib_8 = :prop1 AND value_8 >= :val1)
    			AND (attrib_1 = :prop2 AND value_1 >= :val2 OR attrib_2 = :prop2 AND value_2 >= :val2 OR attrib_3 = :prop2 AND value_3 >= :val2 OR attrib_4 = :prop2 AND value_4 >= :val2 OR attrib_5 = :prop2 AND value_5 >= :val2 OR attrib_6 = :prop2 AND value_6 >= :val2 OR attrib_7 = :prop2 AND value_7 >= :val2 OR attrib_8 = :prop2 AND value_8 >= :val2)
    			AND (attrib_1 = :prop3 AND value_1 >= :val3 OR attrib_2 = :prop3 AND value_2 >= :val3 OR attrib_3 = :prop3 AND value_3 >= :val3 OR attrib_4 = :prop3 AND value_4 >= :val3 OR attrib_5 = :prop3 AND value_5 >= :val3 OR attrib_6 = :prop3 AND value_6 >= :val3 OR attrib_7 = :prop3 AND value_7 >= :val3 OR attrib_8 = :prop3 AND value_8 >= :val3)
    			AND (attrib_1 = :prop4 AND value_1 >= :val4 OR attrib_2 = :prop4 AND value_2 >= :val4 OR attrib_3 = :prop4 AND value_3 >= :val4 OR attrib_4 = :prop4 AND value_4 >= :val4 OR attrib_5 = :prop4 AND value_5 >= :val4 OR attrib_6 = :prop4 AND value_6 >= :val4 OR attrib_7 = :prop4 AND value_7 >= :val4 OR attrib_8 = :prop4 AND value_8 >= :val4)
    			AND (attrib_1 = :prop5 AND value_1 >= :val5 OR attrib_2 = :prop5 AND value_2 >= :val5 OR attrib_3 = :prop5 AND value_3 >= :val5 OR attrib_4 = :prop5 AND value_4 >= :val5 OR attrib_5 = :prop5 AND value_5 >= :val5 OR attrib_6 = :prop5 AND value_6 >= :val5 OR attrib_7 = :prop5 AND value_7 >= :val5 OR attrib_8 = :prop5 AND value_8 >= :val5)
    			AND (attrib_1 = :prop6 AND value_1 >= :val6 OR attrib_2 = :prop6 AND value_2 >= :val6 OR attrib_3 = :prop6 AND value_3 >= :val6 OR attrib_4 = :prop6 AND value_4 >= :val6 OR attrib_5 = :prop6 AND value_5 >= :val6 OR attrib_6 = :prop6 AND value_6 >= :val6 OR attrib_7 = :prop6 AND value_7 >= :val6 OR attrib_8 = :prop6 AND value_8 >= :val6)
    			AND (attrib_1 = :prop7 AND value_1 >= :val7 OR attrib_2 = :prop7 AND value_2 >= :val7 OR attrib_3 = :prop7 AND value_3 >= :val7 OR attrib_4 = :prop7 AND value_4 >= :val7 OR attrib_5 = :prop7 AND value_5 >= :val7 OR attrib_6 = :prop7 AND value_6 >= :val7 OR attrib_7 = :prop7 AND value_7 >= :val7 OR attrib_8 = :prop7 AND value_8 >= :val7)
    			AND (attrib_1 = :prop8 AND value_1 >= :val8 OR attrib_2 = :prop8 AND value_2 >= :val8 OR attrib_3 = :prop8 AND value_3 >= :val8 OR attrib_4 = :prop8 AND value_4 >= :val8 OR attrib_5 = :prop8 AND value_5 >= :val8 OR attrib_6 = :prop8 AND value_6 >= :val8 OR attrib_7 = :prop8 AND value_7 >= :val8 OR attrib_8 = :prop8 AND value_8 >= :val8)) $limit";
            	$arr = array(":item_name" => $itemName, ":quality" => $Quality, ":type" => $Type, ":sub" => $sub_Type, ":prop1" => $itemAttrib1, ":val1" => $val_1, ":val2" => $val_2, ":val3" => $val_3, ":val4" => $val_4, ":val5" => $val_5, ":val6" => $val_6, ":val7" => $val_7, ":val8" => $val_8, ":prop2" => $itemAttrib2, ":prop3" => $itemAttrib3, ":prop4" => $itemAttrib4, ":prop5" => $itemAttrib5, ":prop6" => $itemAttrib6, ":prop7" => $itemAttrib7, ":prop8" => $itemAttrib8);
            	$this->view->items = $this->database->DBQry($sql,$arr);
    			$this->view->msg = "Successful Search";
    			$this->view->err = true;
    		

    		$this->view->render('Search/Index');
    }
}
?>

And here are the errors I am getting on the next “page”:

<b>Notice</b>:  Undefined index: attrib1 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>14</b><br />
<br />
<b>Notice</b>:  Undefined index: attrib2 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>16</b><br />
<br />
<b>Notice</b>:  Undefined index: attrib3 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>17</b><br />
<br />
<b>Notice</b>:  Undefined index: attrib4 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>18</b><br />
<br />
<b>Notice</b>:  Undefined index: attrib5 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>19</b><br />
<br />
<b>Notice</b>:  Undefined index: attrib6 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>20</b><br />
<br />
<b>Notice</b>:  Undefined index: attrib7 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>21</b><br />
<br />
<b>Notice</b>:  Undefined index: attrib8 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>22</b><br />
<br />
<b>Notice</b>:  Undefined index: list_1 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>23</b><br />
<br />
<b>Notice</b>:  Undefined index: list_2 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>24</b><br />
<br />
<b>Notice</b>:  Undefined index: list_3 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>25</b><br />
<br />
<b>Notice</b>:  Undefined index: list_4 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>26</b><br />
<br />
<b>Notice</b>:  Undefined index: list_5 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>27</b><br />
<br />
<b>Notice</b>:  Undefined index: list_6 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>28</b><br />
<br />
<b>Notice</b>:  Undefined index: list_7 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>29</b><br />
<br />
<b>Notice</b>:  Undefined index: list_8 in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>30</b><br />
<br />
<b>Notice</b>:  Undefined index: quality in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>31</b><br />
<br />
<b>Notice</b>:  Undefined index: type in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>32</b><br />
<br />
<b>Notice</b>:  Undefined index: sub in <b>C:\\xampp\\htdocs\\us\\sc\\controllers\\Search.php</b> on line <b>33</b><br />

The variable (Classes do not store data - they represent the prototype model of the data. a variable can be an instance of a class.) must be passed between pageloads - most commonly by use of sessions, but it’s possible to do so with POST and GET, or even in some strange cases, flat files also. Also that is an ungodly long SQL statement which points to a flaw in the database structure behind it.

I know its a long SQL statement, I am not sure how to minimize that. I tried to do sessions it returned with no errors, but i got absolutely no output.

That the table contains fields with names such as attrib_2 and value_8 indicates that the database has not been designed properly.

With a properly normalized database you will have only one column of each field type in a table. The repeating columns would have been split out into a separate table where they have multiple rows for each row of the original table.

If you restructure your database properly then you will be able to get rid of all those tests in your query and retrieve the desired data much more quickly and easily.

I personally need to learn how to structure a database better.

http://www.studytonight.com/dbms/database-normalization.php - covers the first four normalizations you should be applying to your database design - 1NF, 2NF, 3NF and BCNF

http://www.bkent.net/Doc/simple5.htm - covers the first three of these plus two additional normalizations that apply in some special cases - 1NF, 2NF, 3NF, 4NF, 5NF

http://en.wikipedia.org/wiki/Database_normalization#Normal_forms - lists all of the normalizations that you may need to consider in designing your database properly.

We’re wandering away from the OP point a bit, but i’ll divide my post a bit here.

Re: The Database. Generally speaking if you have a variable-length list of things to associate to an object (the item is the object), a secondary table (or even a secondary table with a join table, to reduce space) is used; For example, instead of:

Table Item: Fields:{ name,type,attr1,attr2,attr3,attr4 }

If there may be a variable number of attributes, instead:
Table Item: Fields: {id,name,type} [ID may be required if there isn’t a single-field natural key to the table. If Name is unique, use that instead in the next table.]
Table Attributes; Fields {id,attribute}

This way your attributes table can contain multiple attributes for a single item, without requiring the storage of potentially empty data.
I strongly suggest we take a look at your form also, because you’re looking for a fixed set of fields, and my guess is you’re not actually caring about ALL 8 of them. I think we can optimize things a bit.

But to the ORIGINAL question.
Show us your invoking page - the one that actually creates an instance of this class. You’ve shown us the class definition (which was needed), and the output, but not the pages that create an instance of the class and the receiving page where you expect your data to exist.