我遇到一个问题,我在点击时重定向到页面时没有获取数据。只有在页面刷新一次时才会获得数据。
有人可以帮我在加载前或加载后刷新一次页面吗?
由于
这是代码
<?php
include('libraries/config.php');
$getID = $_GET['id'];
echo $getID;
$stmt = $db->prepare("SELECT * FROM category where categoryID = ?");
if ($stmt->execute(array($_GET['id']))) {
while ($row = $stmt->fetch()) {
// print_r($row);
// echo $row['tips'];
$sol = $row['tips'];;
$str= $sol;
preg_match_all('/"(.*?)"/', $str, $matches);
//print_r(array_map('intval',$matches[1]));
$int_arr = array_map('intval',$matches[1]);
//print_r($int_arr);
foreach ($int_arr as $x) {
$stmt1 = $db->prepare("SELECT * FROM tip where tipID = ?");
if ($stmt1->execute(array($x))) {
while ($row = $stmt1->fetch()) {
// print_r($row);
// echo $row['tips'];
$sol = $row['title'];
//echo $sol;
}
}
}
}
}
if(isset($_POST['tipid'])) { echo $_POST['tipid']; }
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex, follow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome To LensPal</title>
<link rel="stylesheet" href="css/jquery.mobile.structure-1.3.2.min.css">
<link rel="stylesheet" href="css/style.css">
<link rel="shortcut icon" href="demos/_assets/favicon.ico">
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.3.2.min.js"></script>
<link rel="stylesheet" type="text/css" href="engine1/style1.css" />
<script type="text/javascript" src="engine1/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('img').live('click', function(){
// alert(this.id);
//alert(this.src);
var s = this.id;
var s1 = s.split("_");
var s2 = "unlike";
var s3 = s2 + "_" + s1[1];
var s4 = "like";
var s5 = s4 + "_" + s1[1];
//alert(s3);
//alert(s5);
if(s1[0] == "like"){
//if(this.src == "http://localhost/deepthi/acuvue-lenspal/images/ic_like_unselect.png"){
//this.src ="images/ic_like_select.png";
$("#tipid").val(1);
document.getElementById(s).src="images/ic_like_select.png";
document.getElementById(s3).src="images/ic_unlike_unselect.png";
}
if(s1[0] == "unlike"){
$("#tipid").val(0);
document.getElementById(s).src="images/ic_unlike_select.png";
document.getElementById(s5).src="images/ic_like_unselect.png";
//this.src ="images/ic_unlike_select.png";
}
});
});
</script>
</head>
<body>
<div id="main-wrapper">
<div data-role="header" id="header" data-position="fixed">
<div id="back-btn">
<a href="#" onClick="window.history.back();" ><img src="images/back_btn.png" width="42" height="41" /></a>
</div>
<div id="logo">
</div>
<div id="tc-btn">
<a href="tc_list.html" data-transition="slide"><img src="images/tc_btn.png" width="42" height="41" /></a>
</div>
</div>
<div id="content-area">
<br/>
<div id="wowslider-container1">
<form action="#" method="post">
<div class="ws_images">
<ul>
<?php
if ($stmt->execute(array($_GET['id']))) {
while ($row = $stmt->fetch()) {
$counter =0;
foreach ($int_arr as $x) {
if ($stmt1->execute(array($x))) {
while ($row1 = $stmt1->fetch()) {
// print_r($row);
//echo $row1['title'];
?>
<li><img src="engine1/bg.png" alt="" title="" id="wows1"/><div>
<span style="font-size:12px;text-transform:uppercase;"><b><?php echo $_GET['id'];?></b></span><br
><span style="color:#3B8BD7;font-size:22px;"><?php echo $row1['title'];?></span></div>
<img src="images/list_hr.png" style="background-repeat:repeat-x;width:303px;height:4px;margin-top:-3px;" />
<span style="font-size:12px;"><?php echo $row1['body'];?><br><br><br></span>
<img src="images/list_hr.png" style="background-repeat:repeat-x;width:303px;height:4px;"/>
<div align="center"><b><p style="color:#3B8BD7;font-size:14px;">Helpline?</p></b>
<img src="images/ic_like_unselect.png" height="40" width="40" id="like_<?php echo $counter;?>" name="offer" /> <img src="images/ic_unlike_unselect.png" height="40" width="40" id="unlike_<?php echo $counter;?>" name="offer"/></div>
<input type="hidden" name="tipid" id="tipid" value="" />
<input type="hidden" name="tip" id="tip" value="<?php echo $counter;?>" /></li>
<?php $counter++;}}}}} ?>
</ul> </div>
<div class="ws_bullets">
<div align="center">
<?php if ($stmt->execute(array($_GET['id']))) {
while ($row = $stmt->fetch()) {
foreach ($int_arr as $x) {
if ($stmt1->execute(array($x))) {
while ($row1 = $stmt1->fetch()) {
// print_r($row);
//echo $row1['title'];
?>
<a href="#" ></a>
<?php }}}}}?>
</div></div>
<div class="ws_shadow">
</div>
</form>
</div>
</div>
<script type="text/javascript" src="engine1/wowslider.js"></script>
<script type="text/javascript" src="engine1/script.js"></script>