Infolinks

Breaking

Adsense

Monday, September 12, 2016

How To Update Record Using Bootstrap Modal PHP/MySQL

I am back guys! Been busy this past few weeks that's why I haven't posted for a while. I got new code snippets to share that maybe important using bootstrap modal.

Most of the newbies in bootstrap doesn't know how to update records from a list and display it in a bootstrap modal like in the image below.


I have here the files. You can download it here Update record using bootstrap modal, unzip it and then try to follow the procedures in running it. Put it in your xampp/htdocs if you're using XAMPP or wamp/www if using WAMPSERVER.

Step 1

Open your phpmyadmin in your web browser by typing localhost/phpmyadmin in your address bar.

Step 2

Create a database and name it inventory. But you can change that depending on your system. 
Import the sql file from dist/db/inventory.sql.

Step 3

Open the file dbcon.php from the folder dist/includes and change the last value to inventory or your desired database name.

$con = mysqli_connect("localhost","root","","database_name");

Step 4

Open the product.php file inside the pages folder. Just replace the following in
select * from product

Change the product to the table you want to display in the list.

echo $row['prod_name'];
echo $row['prod_unit'];
echo $row['prod_price'];

Change the content between the brackets ['column_name'] the name of the column you want to display.


Look for the anchor tag on the last td  and change the prod_id into the ID (primary key) in your table

Step 5


Change prod_id to the table's primary key. Same column in step 4.

Step 6

Change the form action to where you are going to be redirected after form submit like product_update.php

Step 7

mysqli_query($con,"update product set prod_name='$name',prod_unit='$unit',prod_price='$price',reorder='$reorder',supplier_id='$supplier',grams='$grams',
category='$category' where prod_id='$id'")or die(mysqli_error());

Change product to the table name you want to store the data. You need to change all columns found in you table.

You're good to go!
Hope this works for you!

Watch out for more articles related to programming and even systems administration. Please do hit the like button on the right sidebar of this page.

How To Update Record Using Bootstrap Modal PHP/MySQL

No comments:

Post a Comment

Adbox