Send PHP variable to bootstrap modal popup via Ajax

Send PHP variable to bootstrap modal popup via Ajax

Today, We want to share with you Send PHP variable to bootstrap modal popup via Ajax.
In this post we will show you Send PHP variable to bootstrap modal popup via Ajax, hear for Send PHP variable to bootstrap modal popup via Ajax we will give you demo and example for implement.
In this post, we will learn about Send PHP variable to bootstrap modal popup via Ajax with an example.

Hello friends, in this POST we will see How to Show all the Dynamic MySQL Data display on table in Bootstrap Modal edit records. using Bootstrap Modal with Dynamic MySQL Data using Ajax & PHP

i will show in my this post how you can easily all data display/show mysql data in bootstrap modal in your table and the mysql rows are all displayed dynamically in modal via ajax call and edit and delete popup modal for used to Send PHP variable to bootstrap modal popup via Ajax

Code for index.php

<div class="panel-body">
		<table cellpadding="0" cellspacing="0" border="0" id="example">
			<thead>
				<tr>
					<th>Sr.No</th>
					<th>Product Name</th>
					<th>SIM Code</th>
					<th>Action</th>
				</tr>
			</thead>
			<tbody>
			<?php
				$sql_content="select * from product_master where status=0";
				$sql_content_res=mysql_query($sql_content);
				$i=1;
				while($content=mysql_fetch_array($sql_content_res))
				{
			?>
				<tr>
					<td><?php echo $i;?></td>
					<td><?php 
						echo $content['product_name'];
					?></td>
					<td style="background:<?php echo $content['colorcode'];?>;"><?php 
						echo $content['colorcode'];
					?></td>
					<td class="center">
						<a href="#myModal" data-toggle="modal" data-target="#modalMyformData" data-id="<?php echo $content['product_id']; ?>" class="btn btn-primary btn-xs"><i class="glyphicon glyphicon-pencil"></i></a>
						
						<a href="product_mst.php?did=<?php echo $content['product_id']; ?>"  onclick="return confirm('Are you sure?')" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i></a>
					</td>
				</tr>
			<?php
			$i++;
				}
			?>
			</tbody>
		</table>
	</div>

<!-- Edit Modal -->
<div class="modal fade" id="modalMyformData" tabindex="-1" role="dialog" 
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- Modal Header -->
            <div class="modal-header">
                <button type="button" class="close" 
                   data-dismiss="modal">
                       <span aria-hidden="true">×</span>
                       <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    Edit Products
                </h4>
            </div>
            
            <!-- Modal Body -->
            <div class="modal-body">
                <div class="fetched-data"></div> 
            </div>
           
        </div>
    </div>
</div>
<!-- End Modal Footer -->

Code for Script-main.js

<script>
$(document).ready(function(){
    $('#modalMyformData').on('show.bs.modal', function (e) {
        var rowid = $(e.relatedTarget).data('id');
        $.ajax({
            type : 'post',
            url : 'fetch_data_records.php', //Here you will fetch records 
            data :  'rowid='+ rowid, //Pass $id
            success : function(data){
            $('.fetched-data').html(data);//Show fetched data from database
            }
        });
     });
});
</script>

Code for : fetch_data_records.php

 
 <?php include 'include/config.php';
if($_REQUEST['rowid']) {
    $con_id = $_REQUEST['rowid']; //escape string 
	$sql_content1="select * from productmst where amenities_id='$con_id'";
	$sql_content_res1=mysql_query($sql_content1);
	$content_data=mysql_fetch_array($sql_content_res1);
	echo "<form method='POST'>
                  <div class='form-group'>
                    <label for='exampleInputEmail1'>Product Name</label>
					
                      <input type='text' class='form-control'
                      id='exampleInputEmail1' name='amname' value='".$content_data['amenities_name']."' placeholder='Product Name'/>
                  </div>
				<div class='form-group'>
				  <label for='exampleInputEmail1'>sim Code</label>
				  <div class='input-group demo2'>
					  <input type='text' value='".$content_data['cms_text_color_code']."' class='form-control' name='color_code1'/>
					  <span class='input-group-addon'><i></i></span>
				  </div>
				  </div>
				  <input type='hidden' name='p_id' value='".$content_data['product_id']."'/>
                  <input type='submit'  class='btn btn-primary' name='product_update' value='Update'/>
					<button type='button' class='btn btn-default'
							data-dismiss='modal'>
								Close
					</button>
                </form>";
 }
?>

View Demo

Also Read This 👉   Laravel Blade check if variable is empty/isset

We hope you get an idea about Send PHP variable to bootstrap modal popup via Ajax
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

Searches related to : Send PHP variable to bootstrap modal popup via Ajax

  • pass php variable to modal window
  • pass php variable to bootstrap modal
  • php pass data to bootstrap modal
  • send variable to bootstrap modal
  • pass id to bootstrap modal
  • pass variable to modal popup
  • pass a current $row value to bootstrap modal
  • pass value to modal php