Hulu Posted November 14, 2013 Share Posted November 14, 2013 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 only uses one "View" and a "Class". I have tried to make all the $_POST variables into $_SESSIONS and that still did not work. Im sure if I could make the pagination stay at "Search" and not go to "Search?page=2" it might work, but I don't know how to do that exactly. Here is the Pagination and Search Function class/code: <?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'); } } ?> here is the "Search/Index" View: <?php include_once("views/Header.php"); ?> <div class="container"> <?php if($this->err == true): ?> <div class="alert alert-success alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <?php echo $this->msg; ?> </div> <?php else: ?> <div class="alert alert-danger alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <?php echo $this->msg; ?> </div> <?php endif ?> <div class="well well-sm"> <div class="row col-xs-12"> <div class="btn-group"> <a class="btn btn-danger dropdown-toggle" data-toggle="dropdown" href="#" style="font-weight: normal;"><?php if ($url == '/us/sc') { ?>US Softcore<?php }elseif ($url == '/us/hc') { ?> US Hardcore <?php } ?> <span class="caret"></span> </a> <ul class="dropdown-menu open" style="padding: 5px;"> <li><a href="<?php echo $ahurl; ?>/sc">US Softcore</a></li> <li class="divider"></li> <li><a href="<?php echo $ahurl;?>/hc">US Hardcore</a></li> </ul> </div> </div> </div> <?php include("models/ItemSearch.php"); ?> <div class="row"> <div class="col-md-8"> <!-- Item --> <?php $count = 0; if (count($this->items)%3!=0) { //Append 1 or 2 items from start of array if needed } ?><div class="row"> <?php foreach ($this->items as $item): if (($count>0) and ($count%3==0)): ?></div><div class="row"><?php endif; ?><div class='col-md-4'> <div class="thumbnail"> <h4 <?php if ($item['quality'] == 'Legendary'): ?> class="item-title quality-orange" <?php elseif ($item['quality'] == 'Set'): ?> class="item-title quality-green" <?php elseif ($item['quality'] == 'Rare'): ?> class="item-title quality-yellow" <?php endif ?>><a class="item-title" style="text-decoration:none;" href="<?php echo $this->url; ?>Item-<?php echo $item['item_num']; ?>"><?php echo $item['item_name']; ?></a></h4> <a href="<?php echo $this->url; ?>Item-<?php echo $item['item_num']; ?>"> <img <?php if ($item['quality'] == 'Legendary'): ?> class="item-icon quality-orange" <?php elseif ($item['quality'] == 'Set'): ?> class="item-icon quality-green" <?php elseif ($item['quality'] == 'Rare'): ?> class="item-icon quality-yellow" <?php endif ?> src="<?php echo $this->url.$item['item_img']; ?>" align="left" /></a> <div class="caption"> <?php if ($item['armor'] == NULL){ echo ''; }else{ ?> <ul class="stat-basic"><li class="armor"><?php echo $item['armor']; ?></li>Armor</ul> <?php }if ($item['dps'] == NULL && $item['min_max'] == NULL && $item['aps'] == NULL){ echo ''; }else{ ?> <ul class="stat-basic"> <li class="dmg"><?php echo $item['dps']; ?></li><li class="dps"> Damage Per Second</li> <li><?php echo $item['min_max']; ?> Damage</li> <li><?php echo $item['aps']; ?> Attacks Per Second</li> </ul> <?php }?> <div class="prop"> <ul class="item-attrib"> <?php if($item['attrib_1'] == 'None' || $item['attrib_1'] == '' || $item['attrib_1'] == 'none' || $item['attrib_1'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_1']; ?> <?php echo $item['attrib_1']; ?></li> <?php }if ($item['attrib_2'] == 'None' || $item['attrib_2'] == '' || $item['attrib_2'] == 'none' || $item['attrib_2'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_2']; ?> <?php echo $item['attrib_2']; ?></li> <?php }if ($item['attrib_3'] == 'None' || $item['attrib_3'] == '' || $item['attrib_3'] == 'none' || $item['attrib_3'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_3']; ?> <?php echo $item['attrib_3']; ?></li> <?php }if ($item['attrib_4'] == 'None' || $item['attrib_4'] == '' || $item['attrib_4'] == 'none' || $item['attrib_4'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_4']; ?> <?php echo $item['attrib_4']; ?></li> <?php }if ($item['attrib_5'] == 'None' || $item['attrib_5'] == '' || $item['attrib_5'] == 'none' || $item['attrib_5'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_5']; ?> <?php echo $item['attrib_5']; ?></li> <?php }if ($item['attrib_6'] == 'None' || $item['attrib_6'] == '' || $item['attrib_6'] == 'none' || $item['attrib_6'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_6']; ?> <?php echo $item['attrib_6']; ?></li> <?php }if ($item['attrib_7'] == 'None' || $item['attrib_7'] == '' || $item['attrib_7'] == 'none' || $item['attrib_7'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_7']; ?> <?php echo $item['attrib_7']; ?></li> <?php }if ($item['attrib_8'] == 'None' || $item['attrib_8'] == '' || $item['attrib_8'] == 'none' || $item['attrib_8'] == 'Has Sockets'){ echo ''; }else{ ?> <li><img src="<?php echo $this->url."img/bullet.gif"; ?>"> +<?php echo $item['value_8']; ?> <?php echo $item['attrib_8']; ?></li> <?php }if ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_1'] == 'Has Sockets' && $item['value_1'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_2'] == 'Has Sockets' && $item['value_2'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_3'] == 'Has Sockets' && $item['value_3'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_4'] == 'Has Sockets' && $item['value_4'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_5'] == 'Has Sockets' && $item['value_5'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_6'] == 'Has Sockets' && $item['value_6'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_7'] == 'Has Sockets' && $item['value_7'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 3){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 2){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php }elseif ($item['attrib_8'] == 'Has Sockets' && $item['value_8'] == 1){?> <li><img src="<?php echo $this->url."img/empty-socket.png"; ?>"> Empty Socket</li> <?php } ?> </ul> </div> </div> </div> </div><?php $count++; endforeach; ?> <!-- end item --> </div> </div> <ul class="pager"> <?php echo $this->first; echo $this->prev; echo $this->next; echo $this->count; echo $this->last; ?> </ul> </div> </div> </div> <?php include_once("views/Footer.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/ Share on other sites More sharing options...
dalecosp Posted November 14, 2013 Share Posted November 14, 2013 (edited) Is this right? $last_page = ceil($ctr/$per_page); Because to write a query like that and then only use it for a calculation (and incidentally, are you quite certain it's a numeric value and not a DB resource handle you're using as the dividend there?) seems a tad strange... Edited November 14, 2013 by dalecosp Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/#findComment-1458193 Share on other sites More sharing options...
Hulu Posted November 14, 2013 Author Share Posted November 14, 2013 Is this right? Because to write a query like that and then only use it for a calculation (and incidentally, are you quite certain it's a numeric value and not a DB resource handle you're using as the dividend there?) seems a tad strange... That is correct, it gets the number of search results from the DB then divides it. Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/#findComment-1458195 Share on other sites More sharing options...
trq Posted November 14, 2013 Share Posted November 14, 2013 Sorry, but that is some seriously messed up code on oh so many levels. One of the problems is quite obvious, and your already aware of it. $_POST does not persist across requests. Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/#findComment-1458202 Share on other sites More sharing options...
dalecosp Posted November 14, 2013 Share Posted November 14, 2013 That is correct, it gets the number of search results from the DB then divides it. You want "SELECT COUNT(something)", then, not that humongous query with a "SELECT *" ... too expensive otherwise. Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/#findComment-1458203 Share on other sites More sharing options...
Hulu Posted November 14, 2013 Author Share Posted November 14, 2013 Sorry, but that is some seriously messed up code on oh so many levels. One of the problems is quite obvious, and your already aware of it. $_POST does not persist across requests. I have the same exact paginaton on my homepage and it works 100%, but there isnt any form that needs filled out. What are my options to fix this? i already tried to do sessions and it didnt work either. Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/#findComment-1458204 Share on other sites More sharing options...
Hulu Posted November 14, 2013 Author Share Posted November 14, 2013 You want "SELECT COUNT(something)", then, not that humongous query with a "SELECT *" ... too expensive otherwise. That humongous code counts it... $this->database->Ctr($sql,$arr) is in lib. Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/#findComment-1458205 Share on other sites More sharing options...
ignace Posted November 14, 2013 Share Posted November 14, 2013 You come here for help and when people give it, you tell them they are wrong while in fact they are correct. Fuck off! Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/#findComment-1458213 Share on other sites More sharing options...
Hulu Posted November 14, 2013 Author Share Posted November 14, 2013 You come here for help and when people give it, you tell them they are wrong while in fact they are correct. Fuck off! I didn't say anyone was wrong, learn to read. Quote Link to comment https://forums.phpfreaks.com/topic/283884-pagination-on-mvc-search-class/#findComment-1458214 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.