【发布时间】:2019-03-05 03:50:42
【问题描述】:
我已经手动将一些星星值插入到数据库中,我通过此代码获取并显示相关产品,现在我想在用户点击相关产品的星星时将新的星星值插入到数据库中
我使用php作为服务器端语言和mysql数据库
<?php
include("sessiondestroy.php");
include("functions.php");
$ip = getRealIPAddr();
include("header.php");
include("leftside.php");
?>
<td width="53%" style="align-left:15px;" valign="top" >
<div class="row" align="center" >
<?php
$con = mysqli_connect('localhost','root',"",'furniture_store');
mysqli_select_db($con,'furniture_store');
$query="select product_id, product_name, s_price, product_pick, rating from product";
$run=mysqli_query($con,$query);
while($row=mysqli_fetch_array($run)){
$id=$row['product_id'];
$name=$row['product_name'];
$image=$row['product_pick'];
$rating=$row['rating'];
?>
<div class="col-md-3" align="center" style="border:#CCCCCC solid 1px; margin:15px; padding:8; ">
<div class="container fill">
<div class="modal-body">
<form action="index.php" method = "post">
<table>
<tr align="centr">
<td align="center"><?php echo $name; ?></td>
</tr>
<tr>
<td>   </td>
</tr>
<tr>
<td ><img width="100px" height="140px" src="admin/AdminLTE/<?php echo $image; ?>"></td>
</tr>
<tr>
<td>   </td>
</tr>
<tr align="left">
<td style="padding-right:15px;"><input id="input-1" name="input-1" class="rating rating-loading" value="<?php echo $rating; ?>" data-min="0" data-max="5" data-step="0.1" data-size="" data-show-clear="false" data-show-caption="false"></td>
</tr>
<tr>
<td>   </td>
</tr>
<tr>
<td align="center"><a href="userside_productdetail.php?id=<?php echo $id; ?>"><input type="submit" name="detail" class="btn btn-success" value="Details"></a></td>
</tr>
</table>
</form>
</div>
</div>
</div>
<?php } ?>
</div>
</td>
<?php include("rightside.php"); ?>
<?php include("footer.php"); ?>
<script>
$("#input-id").rating();
</script>
</body>
</html>
【问题讨论】:
-
使用ajax
-
使用 Javascript 来动态更新类似这样的值 => document.getElementById('input-id').value
-
这是一个重复的问题。同一个话题有很多问题。从 UI 获取数据并保存在数据库中。
标签: javascript php ajax twitter-bootstrap