Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to display record from database in modal bootstrap

Featured Replies

I want to create a page view and update by using the bootstrap modal, but every time I click on a link view existing data in the database can not display the page to bootstrap modal. How can I make the data in the database available to display the bootstrap modal?

 

<table class="table table-striped table-bordered table-hover">
<thead>
<tr class="alert alert-info text-center">
<th>
ID
</th>
<th>
USERNAME
</th>
<th>
LEVEL
</th>
<th>
BLOK
</th>
<th>
ACTION
</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT * FROM users";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
do
{
$id_user = $data["id_user"];
$username = $data["username"];
$password = $data["password"];
$level = $data["level"];
$blok = $data["blok"];
?>
<tr>
<td class="text-center">
<?php echo $id_user; ?>
</td>
<td>
<?php echo $username; ?>
</td>
<td class="text-center">
<?php echo $level; ?>
</td>
<td class="text-center">
<?php
if($blok == "Y")
{
print "Yes";
}
else
{
print "No";
}
;?>
</td>
<td class="text-center">
<a href="?page=update&user=<?php echo $id_user; ?>#edit-panitia" href="../../bootstrap/" role="button" data-toggle="modal"><i class="icon-edit"></i>Update</a>
<a href="?page=delete&user=<?php echo $id_user; ?>"><i class="icon-trash"></i>Delete</a>
</td>
</tr>
<?php
}
while($row = mysql_fetch_array($result));
?>
</tbody>
</table>

I was working on this like three days ago!! lol

Heres my code

 

This works on bootstrap v2.3 make sure to include add the correct bootstrap files

///////////////////////////// The code ///////////////////////////////

 

** where is says event add the link to the file where your php/json/etc.. is i this example its event.php

 

<script type="text/javascript">
$(function(){
$(document).on('click', '.edit-record', function(e){
e.preventDefault();
$(".modal-div").html('');
$(".modal-div").addClass('loader');
$("#dialog-example").modal('show');
$.post('event.php',
{id: $(this).attr('data-id') },
function(html){
$(".modal-div").removeClass('loader');
$(".modal-div").html(html);
}
);
});
});
</script>

//////the link that sets off the event
$id = add your variable here
<a href="#" class="edit-record" data-id="'.$id.'">Placeholder text</a>.'
///event.php
**this where you add your dynamic logic, from the post variable posted above
<?php
echo '
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body"><div class="te">'.$_POST['id'].'Excitavit hic ardor milites per municipia plurima, quae isdem conterminant, dispositos et castella, sed quisque serpentes latius pro viribus repellere moliens, nunc globis confertos, aliquotiens et dispersos multitudine superabatur ingenti, quae nata et educata inter editos recurvosque ambitus montium eos ut loca plana persultat et mollia, missilibus obvios eminus lacessens et ululatu truci perterrens.</div></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Book event</button>
</div>
</div>';
?>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.