这是我选择和回显数据的代码
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static',filename='css/style.css') }}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<script src="https://js.stripe.com/v3/"></script>
<script src="{{ url_for('static',filename='js/stripe-local.js') }}"></script>
<link href="https://fonts.googleapis.com/css?family=Lora:700i|Titillium+Web" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-inverse navbar-default navbar-fixed-top">
<ul class="nav navbar-nav">
<li class=><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li><a href="#pay">Pay</a></li>
</ul>
</nav>
<div class="jumbotron" id="home">
<div class="container-fluid">
<h1>Design Something</h1>
</div>
</div>
<div class="container-fluid" id="about">
<div class="row">
<h1 class="anchor">About</h1>
<img src="{{ url_for('static', filename='img/img.jpg') }}" class="img-rounded center-block"></img>
<div class="container">
<p>blah blah blah blah blah</p>
</div>
</div>
</div>
<div class="container-fluid" id="contact">
<div class="row">
<h1 class="anchor">Contact Me</h1>
<p>email@address.com</p>
</div>
</div>
<div class="container-fluid" id="pay">
<h1 class="anchor">Pay Now</h1>
<a href="#popupPay" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all ui-icon-check ui-btn-icon-left">Pay Now</a>
<div data-role="popup" id="popupPay" class="ui-content" style="min-width:250px;">
<form method="post" action="charge.py">
<div>
<h3>Payment Form</h3>
<label for="name" class="ui-hidden-accessible">Name:</label>
<input type="text" name="name" id="name" placeholder="name">
<input type="submit" data-inline="true" value="Pay $">
<div class="outcome">
<div class="error" role "alert"></div>
<div class="success">
Success! Your Stripe token is <span class="token"></span>
</div>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
我有2张桌子
1。)Select maintable.movie_title, group_concat(genres.genres_name) AS genres_name
FROM maintable
JOIN genres USING (tmdb_id)
GROUP BY maintable.tmdb_id,maintable.movie_title
HAVING find_in_set('$category1', genres_name) AND find_in_set('$category2', genres_name)
LIMIT $limit OFFSET $start
// Then fire it up
$stmt->execute();
// Pick up the result as an array
$result = $stmt->fetchAll();
2。)maintable
表
两个表都使用genres
(请不要询问展示,我尝试了什么。相信我,这会让问题更加混乱)
答案 0 :(得分:1)
如果你还需要$ totalrows的数量,它有$ category1和$ category2 您应该使用where in子句
Select maintable.movie_title, group_concat(genres.genres_name) AS genres_name, count(*) as total_rows
FROM maintable
JOIN genres USING (tmdb_id)
where genres.genres_name in ('$category1', '$category2' )
GROUP BY maintable.tmdb_id, maintable.movie_title
LIMIT $limit OFFSET $start
如果你只需要tital_rows,你只能选择这个值(并使用$ totalrows = $ result-&gt; fetchColumn();)或者在这个fecth第2列使用
$totalrows = $result->fetchColumn(2);
或使用fetchAll
$result = $stmt->fetchAll();
foreach($result as $key=>$row){
echo $row['total_rows'] ;
}
答案 1 :(得分:0)
你想要这个吗?
if ($stmt = $mysqli->prepare($query)) {
/* execute query */
$stmt->execute();
/* store result */
$stmt->store_result();
printf("Number of rows: %d.\n", $stmt->num_rows);
/* close statement */
$stmt->close();
}