Jump to content

lovephp

Members
  • Content Count

    530
  • Joined

  • Last visited

Community Reputation

1 Neutral

About lovephp

  • Rank
    Prolific Member
  1. typos in title i mean phpfreaks
  2. was wondering how many years its been online?
  3. oh god my mistake i should have made this $results= $sth->fetchall(PDO::FETCH_ASSOC); not $rows = $sth->fetchall(PDO::FETCH_ASSOC); now fixed
  4. i also tried BindParam but same no records gets fetched
  5. ok this time serious not guessing i have got rest of it working but running into something which i guess you guys will know better than me for sure i am getting results if i query it like $results = $db->query('SELECT * FROM blog_posts WHERE catID = '.$cat.' ORDER BY postID DESC LIMIT '.$row.','.$records_per_page.'')->fetchAll(); but when i use $cat = $_POST['catid']; $row = $_POST['row']; global $records_per_page; $sth = $db->prepare("SELECT * from blog_posts WHERE catID = ? ORDER BY postID ASC LIMIT ?,?"); $sth->execute(array($cat,$row,$rowperpage)); $sth->execute(); $rows = $sth->fetchall(PDO::FETCH_ASSOC); even with Bind like $sth = $db->prepare("SELECT * from blog_posts WHERE catID = :catID ORDER BY postID ASC LIMIT :row, :records_per_page"); $sth->bindParam(':catID', $cat, PDO::PARAM_INT); $sth->bindParam(':row', $row, PDO::PARAM_INT); $sth->bindParam(':records_per_page', $records_per_page, PDO::PARAM_INT); $sth->execute(); all i get is blank or 0 value but why $results = $db->query('SELECT * FROM blog_posts WHERE catID = '.$cat.' ORDER BY postID DESC LIMIT '.$row.','.$records_per_page.'')->fetchAll(); fetches records without issue?
  6. i did this $query = "SELECT count(id) AS allcount FROM posts WHERE cat :cat"; $stmt->bindParam(':cat', $catid, PDO::PARAM_INT); $stmt->execute(); $allcount = $db->query($query)->fetchColumn(); $qry = "SELECT * FROM posts WHERE cat :cat ORDER BY id ASC LIMIT LIMIT :rowperpage OFFSET :offset"; $stm = $db->prepare($qry); $stm->bindParam(':cat', $catid, PDO::PARAM_INT); $stm->bindParam(':rowperpage', $rowperpage, PDO::PARAM_INT); $stm->bindParam(':offset', $offset, PDO::PARAM_INT); $stm->execute(); $results = $stm->fetchall(PDO::FETCH_ASSOC); and i get error Fatal error: Call to a member function bindParam() on a non-object
  7. i get it like this LIMIT :rowperpage OFFSET :offset ?
  8. hehehe guess-what-my-problem-is game i get u soi do bind to all but offset and perpage limit how am i to bind them? $query = "SELECT count(id) AS allcount FROM posts WHERE cat = :cat"; $stmt->bindParam(':catUrl', $url, PDO::PARAM_INT); $stmt->execute(); $allcount = $db->query($query)->fetchColumn(); $qry = "SELECT * FROM posts WHERE cat = :cat ORDER BY id ASC LIMIT ?,? "; $stm = $db->prepare($qry); $stm->execute(array($offset,$rowperpage)); $results = $stm->fetchall(PDO::FETCH_ASSOC);
  9. whatis is the procedure to add the where clause to this query? i need to display where catid = 1; $catid = 1; $rowperpage = 3; $offset = 0; $query = "SELECT count(id) AS allcount FROM posts"; $allcount = $db->query($query)->fetchColumn(); $qry = "SELECT * FROM posts ORDER BY id ASC LIMIT ?,? "; $stm = $db->prepare($qry); $stm->execute(array($offset,$rowperpage)); $results = $stm->fetchall(PDO::FETCH_ASSOC); do i have to add $catid = 1; $rowperpage = 3; $offset = 0; $query = "SELECT count(id) AS allcount FROM posts WHERE cat = :cat"; $stmt->bindParam(':cat', $catid, PDO::PARAM_STR); $allcount = $db->query($query)->fetchColumn(); $qry = "SELECT * FROM posts WHERE cat = :cat ORDER BY id ASC LIMIT ?,? "; $stm = $db->prepare($qry); $stm->execute(array($offset,$rowperpage)); $results = $stm->fetchall(PDO::FETCH_ASSOC); please guide
  10. It is creating <a href="http://localhost//blogg/category/X/page/N"> but the yes if click it redricts to index.php
  11. this is how it looks now but still not working $pagination = ""; if($last_page > 1){ $pagination .= "<div class='pagination'>"; if($page > 1) $pagination.= "<a href='$pageName/page/1'>« First</a>"; else $pagination.= "<span class='disabled'>« First</span>"; if ($page > 1) $pagination.= "<a href='$pageName/page/".$prev."'>« Previous </a>"; else $pagination.= "<span class='disabled'>« Previous </span>"; if ($last_page < 7 + ($adjacents * 2)) { for ($counter = 1; $counter <= $last_page; $counter++) { if ($counter == $page) $pagination.= "<span class='current'>$counter</span>"; else $pagination.= "<a href='$pageName/page/".$counter."'>".$counter."</a>"; } } elseif($last_page > 5 + ($adjacents * 2)) { if($page < 1 + ($adjacents * 2)) { for($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if($counter == $page) $pagination.= "<span class='current'>$counter</span>"; else $pagination.= "<a href='$pageName/page/".$counter."'>".$counter."</a>"; } $pagination.= "..."; $pagination.= "<a href='$pageName/page/'".$second_last."'>".$second_last."</a>"; $pagination.= "<a href='$pageName/page/".$last_page."'>".$last_page."</a>"; } elseif($last_page - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href='$pageName/page/1'>1</a>"; $pagination.= "<a href='$pageName/page/2'>2</a>"; $pagination.= "..."; for($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if($counter == $page) $pagination.= "<span class='current'>$counter</span>"; else $pagination.= "<a href='$pageName/page/".$counter."'>".$counter."</a>"; } $pagination.= ".."; $pagination.= "<a href='$pageName/page/".$second_last."'>".$second_last."</a>"; $pagination.= "<a href='$pageName/page/".$last_page."'>".$last_page."</a>"; } else { $pagination.= "<a href='$pageName/page/1'>1</a>"; $pagination.= "<a href='$pageName/page/2'>2</a>"; $pagination.= ".."; for($counter = $last_page - (2 + ($adjacents * 2)); $counter <= $last_page; $counter++) { if($counter == $page) $pagination.= "<span class='current'>$counter</span>"; else $pagination.= "<a href='$pageName/page/".$counter."'>".$counter."</a>"; } } } if($page < $counter - 1) $pagination.= "<a href='$pageName/page/".$next."'>Next »</a>"; else $pagination.= "<span class='disabled'>Next »</span>"; if($page < $last_page) $pagination.= "<a href='$pageName/page/".$last_page."'>Last »</a>"; else $pagination.= "<span class='disabled'>Last »</span>"; $pagination.= "</div>"; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.