Jump to content
Killersites Forums

Basic PHP System: View, Edit, Add, Delete records with MySQLi


falkencreative
 Share

Recommended Posts

  • 11 months later...

My dear friend Falken,

I just registered to the forum to ask you a question. 

Is there any chance tonight or tomorrow you will update your PHP Pagination Tutorial so Ajax, jQuery and Prepared Statements are used ? 

That way, whole pages won't need reloading to update data on our pagination pages. Plus we get SQL injection proof added. 

I am a PHP Student. Still on procedural style and Mysqli and prepared statements. Haven't got into pdo or Oop style or JavaScript or any other programming language yet. 

Also your pagination contains the page number links at the top of the page. Would be great if there were a copy on the bottom of the page too.

Also can you update it to make it Mobile Responsive for all devices ? Don't bother revolving around Twitter's bootstrap as better not to be dependant on a commercial company's template.

Do drop me a PM after you've updated your tutorial to 2019 standard.

 

PS - May we see a PHP Mysqli & Prepared Statement tutorial from you on Member Registration & Login site ? 

And another tutorial where you teach us how to build a search chengine (Search feature, Crawler, Index, etc) with mysqli and prepared statements and Ajax and jQuery ?

Thank You!

Edited by LiverSite
Link to comment
Share on other sites

  • 3 weeks later...

I am using this script and all works fine but is it possible to add a active class to the pagination so when on page 6 for example, the number 6 is highlighted so know which page number I am on, below is the current code I have

// Count the total records
$total_records = mysqli_num_rows($result);

//Using ceil function to divide the total records on per page
$total_pages = ceil($total_records / $per_page);

//Going to first page
echo "<div class='btn-group' style='margin:0 auto;display:table;'>";
echo "<br><br><center><a href='view-all-customers.php?page=1' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".'First Page'."</a>";

for ($i=1; $i<=$total_pages; $i++) {

echo "<a href='view-all-customers.php?page=".$i."' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".$i."</a>";
};
// Going to last page
echo "<a href='view-all-customers.php?page=$total_pages' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".'Last Page'."</a></center>";
echo "</div>";

UPDATE: I managed to get it working using the following coding

//check page and add active class

for ($i=1; $i<=$total_pages; $i++) {
    $isActive = '';
    if($i == $page){
        $isActive = 'active';
    }

    echo "<a href='view-all-customers.php?page=".$i."' class='".$isActive."btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".$i."</a>";
};

The complete code is below if anyone else needs it

// Count the total records
$total_records = mysqli_num_rows($result);

//Using ceil function to divide the total records on per page
$total_pages = ceil($total_records / $per_page);

//Going to first page
echo "<div class='btn-group' style='margin:0 auto;display:table;'>";
echo "<br><br><center><a href='view-all-customers.php?page=1' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".'First Page'."</a>";

//check page and add active class

for ($i=1; $i<=$total_pages; $i++) {
    $isActive = '';
    if($i == $page){
        $isActive = 'btn-active';
    }

echo "<a href='view-all-customers.php?page=".$i."' class='".$isActive." btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".$i."</a>";
};
// Going to last page
echo "<a href='view-all-customers.php?page=$total_pages' class='btn btn-primary float-button-light' style='color:#FFFFFF;padding:6px 15px;'>".'Last Page'."</a></center>";
echo "</div>";

 

Edited by ianhaney
solved the issue
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...