我正在寻找一种方法来查找产品的结果后更新数据库的计数,但它一直返回一个错误和/或不更新计数。我找到了更新计数的方法,但没有找到结果。如果我瞎了,请重定向我。如果我忽视任何事情,我很抱歉。 RAM返回结果后的更新计数
<?php
//Variables for connecting to your database.
//These variable values come from your hosting account.
require_once '../connect/connect.php';
$usertable = "UPC_Product";
$yourfield2 = "Product";
$yourfield1 = "UPCA";
$yourfield3 = "Gluten Free";
$yourfield4 = "Company";
$yourfield5 = "search_cnt";
$yourfield6 = "CompName";
$yourfield7 = "id";
$search_id = $_POST["search_id"];
//Connecting to your database
mysql_connect($hostname, $username, $password) or die("Unable to
connect to database! Please try again later.");
mysql_select_db($dbname);
//Fetching from your database table.
$query = "SELECT * FROM $usertable WHERE UPCA = $search_id";
$result = mysql_query($query);
if ($result) {
while ($row = mysql_fetch_array($result)) {
$name = $row["$yourfield2"];
$upca = $row["$yourfield1"];
$gluten = $row["$yourfield3"];
$count = $row["$yourfield5"];
$id = $row["$yourfield7"];
}
//update count
$ucount = "UPDATE $usertable SET search_cnt = ($count + 1)";
mysql_query($ucount);
}
?>
<head>
<link rel="icon"
type="image/png"
href="../images/GluteFreefavicon.jpg">
<meta name="viewport" content="width=device-width">
<title>Result Page</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="/style.css" media="screen" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-39600334-1', 'glutefree.com');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="wrap">
<div id="top"></div>
<div id="content">
<div class="header">
<a href="index.html"><img src="/images/glutefreefacebookbanner.jpg"/></a>
</div>
<div class="breadcrumbs">
<center> <a href="index.html">Home</a> · <a href="../search">Search</a> · <a href="../application">Application</a> · <a href="../newuser">Register</a> · <a href="../contact_us">Contact Us</a> · <a href="../aboutus">About Us</a> · <a href="">Games</a>
</center>
</div>
<div class="result">
<center>Your Results
<br/>
</center>Product:
<?php echo $name; ?>
<br/>
<div class="product">Gluten Free?
<?php echo $gluten; ?>
<br>
<br>UPC:
<?php echo $upca;?>
<br>Search count:
<?php echo $count;?>
<br/>
</div>
</div>
<p>No Result? Click <a href="../submit_error.html">here</a> to fill out information on the product you were searching for.</p>
</div>
<div id="bottom"></div>
</div>
<div id="footer">
</a>
</div>
</body>
</html>
什么是$计数? – Roopendra
你会得到什么错误? –
它与css有什么关系? – NoobEditor