Show table data in div

Dear Experts

I have following codes

[php]<?php
if(isset($_get[‘submit’]))
{
// Connection variables
$host=“localhost”;
$username=“root”;
$password="";
$db_name=“asia”;

	// Connect to database 
	$con=mysqli_connect("$host", "$username", "$password"); 
	
	// Connect result 
	if(!$con){ 
		die('Error Connecting to Database: ' . mysqli_error()); 
	//die '<script type="text/javascript">alert("Error Connecting to Database"). mysqli_error($con);</script>';  
	} 
	else 
	{ 
		echo "<script type=\"text/javascript\">alert(\"Connected\")" . mysqli_error($con) . ";</script>";  
	} 
	
	// Database Selection 
	$sel =mysqli_select_db($con,"$db_name"); 
	
	// Database Selection result 
	if(!$sel){ 
	die('Error selecting Database: ' . mysqli_error()); 
	} 
	else 
	{ 
	//echo "Database Selected" . mysqli_error($con); 
	echo "<script type=\"text/javascript\">alert(\"Database Selected\")" . mysqli_error($con) . ";</script>";  
	} 
	//$result = mysqli_query("select sno,packing,weight from test");   
	  $result = $con->query("select sno,packing,weight from test");  
	  
	 if(!$result){ 
	  echo 'select query error or data not found'; 
	  } 
	  else 
	  { 
	  echo 'data found'; 

}

	  	  }
  ?>
BROWSE DATA
html {
overflow:auto;
}

body {
background-color:#FFFFFF;
margin:0 auto;
}

	
#mypopup2
{
float: left;
width: 250px; height: 350px;
background: #90bade; 
border: 1px solid #069;
text-align:center;
padding:2px;
margin-top:150px;
margin-left:50px;
overflow:auto;
}


#header
{
background-color:#3399FF;
background-position:left center;
line-height:25px;
font-size:22px;
color:#FFFF33;
font-weight:600;
border-bottom:1px solid #6699CC;
padding:10px;
}

.design12 {
background-image:url(Images/disk.png);
background-position:left center;
background-repeat:no-repeat;
background-color:#FF9;
border:1px solid #88de85;
-webkit-border-radius:7px;
-moz-border-radius:7px;
font-size:15px;
font-weight:700;
font-family:verdana;
color:#0d5f83;
width:100px;
cursor:hand;
padding:9px;
}

.design13 {
background-image:url(Images/reload_16.png);
background-position:left center;
background-repeat:no-repeat;
background-color:#CF9;
border:1px solid #88de85;
-webkit-border-radius:7px;
-moz-border-radius:7px;
font-size:15px;
font-family:verdana;
font-weight:700;
color:#0d5f83;
width:100px;
cursor:hand;
padding:9px;
}


.txt
{
width:150px;
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:300;
}

td
{color:#6600CC;}

</style>
Brows Data
<form name="form1" method="get" action="#">
  
  <table border="1" cellpadding="1" cellspacing="1" bgcolor="silver" align="center" width="95%" >
    <th width="20%">Code</th>
      <th width="50%">Product</th>
      <th width="20%">Weight</th>
  </table>
  
  <div style="margin-top:125px;text-align:center;margin-top:100px;">
    <input type="submit" name="submit" value="Brow" class="design12">
    <input type="submit" name="button2" value="Clear" class="design13">
  </div>
  
</form>
[/php]

When I run these codes it show php like in attachment.

I want to display table data into div under table columns

Please help


aa.jpg

It’s not to hard you just need to structure your code differently… Take a look at what I did, I moved your PHP Code blocks below You HTML table.

Now all you have to do is follow my comments in the code and code in the piece you need to display it.

[php]

BROWSE DATA
html {
overflow:auto;
}

body {
background-color:#FFFFFF;
margin:0 auto;
}

	
#mypopup2
{
float: left;
width: 250px; height: 350px;
background: #90bade; 
border: 1px solid #069;
text-align:center;
padding:2px;
margin-top:150px;
margin-left:50px;
overflow:auto;
}


#header
{
background-color:#3399FF;
background-position:left center;
line-height:25px;
font-size:22px;
color:#FFFF33;
font-weight:600;
border-bottom:1px solid #6699CC;
padding:10px;
}

.design12 {
background-image:url(Images/disk.png);
background-position:left center;
background-repeat:no-repeat;
background-color:#FF9;
border:1px solid #88de85;
-webkit-border-radius:7px;
-moz-border-radius:7px;
font-size:15px;
font-weight:700;
font-family:verdana;
color:#0d5f83;
width:100px;
cursor:hand;
padding:9px;
}

.design13 {
background-image:url(Images/reload_16.png);
background-position:left center;
background-repeat:no-repeat;
background-color:#CF9;
border:1px solid #88de85;
-webkit-border-radius:7px;
-moz-border-radius:7px;
font-size:15px;
font-family:verdana;
font-weight:700;
color:#0d5f83;
width:100px;
cursor:hand;
padding:9px;
}


.txt
{
width:150px;
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:300;
}

td
{color:#6600CC;}

</style>
Brows Data
<form name="form1" method="get" action="#">
   
  <table border="1" cellpadding="1" cellspacing="1" bgcolor="silver" align="center" width="95%" >
     <th width="20%">Code</th>
       <th width="50%">Product</th>
       <th width="20%">Weight</th>
<?php if(isset($_get['submit'])) { // Connection variables $host="localhost"; $username="root"; $password=""; $db_name="asia"; // Connect to database $con=mysqli_connect("$host", "$username", "$password"); // Connect result if(!$con){ die('Error Connecting to Database: ' . mysqli_error()); //die ''; } else { echo ""; } // Database Selection $sel =mysqli_select_db($con,"$db_name"); // Database Selection result if(!$sel){ die('Error selecting Database: ' . mysqli_error()); } else { //echo "Database Selected" . mysqli_error($con); echo ""; } //$result = mysqli_query("select sno,packing,weight from test"); $result = $con->query("select sno,packing,weight from test"); if(!$result){ echo 'select query error or data not found'; } else { //Loop through the results of your query here echo ''; echo 'Your Data Here'; echo ''; // End loop echo 'data found'; } } ?>
   </table>

  
   <div style="margin-top:125px;text-align:center;margin-top:100px;">
     <input type="submit" name="submit" value="Brow" class="design12">
     <input type="submit" name="button2" value="Clear" class="design13">
   </div>
  
 </form>
[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service