我有一个文件checkbalance.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CHECK BALANCE</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<img class="image" src="BITCOIN.jpg" height="100" width="100%" />
<ul class="nav" id="">
<li><a href="navbar.html">Home</a></li>
<li><a href="aboutus.html">About Us</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="logout.html">Logout</a></li>
</ul>
<ul class="nav2">
<li><a href="myprofile.html">My Profile</a></li>
<li><a href="">Order Chequebook/Passbook</a></li>
<li><a href="">Transactions</a></li>
<li><a href="">EFT</a></li>
<li><a href="">Change Password</a></li>
</ul>
<?php
$con=mysqli_connect('localhost','root','') or die("Failed to connect to
MySQL: " . mysql_error($con));
//select db
$db=mysqli_select_db($con,'sample1') or die("Failed to connect to MySQL:
MySQL: " . mysql_error($con));
$query="SELECT BALANCE FROM ac_holders WHERE username='$_POST[username]'";
$data = mysqli_query ($con,$query)or die(mysql_error());
$row = mysql_fetch_array($data);
$bal=$row['BALANCE'];
?>
<div class="text">
</br></br>
<h1> Your account balance is Rs.<?php echo $bal;?>
</h1>
</br>
</div>
</body>
</html>
在这里,我无法使用php Here's an image of the webpage的echo功能在
标签内的网页上显示余额。唯一显示的是:您的帐户余额为卢比 感谢提前!!!!!!
答案 0 :(得分:0)
<?php
$con = new mysqli("localhost", "root", "", "sample1");
$query="SELECT BALANCE FROM ac_holders WHERE username='".$_POST[username]."'";
$data = $con->query($query);
$row = $data->fetch_array(MYSQLI_ASSOC);
$bal=$row['BALANCE'];
?>
使用mysql语句或mysqli语句。建议使用mysqli,因为不推荐使用mysql