Jump to content
Killersites Community
falkencreative

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

Recommended Posts

Hi Ben,

 

I don't know how to make php display the error, i have editephp.ini and still cannot see what's the error message:  i know it's a syntax error but i don't know where?

 

please help.

 

 

Screen Shot 2018-10-28 at 11.58.12 PM.png

Share this post


Link to post
Share on other sites

It's a HTTP 500 error ... which means the whole web server went nuts.

So, first thing is to strip all PHP from the page to get the page loading at least. Then step by step, add the PHP to see what breaks it.


Stef

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×