这里我试图检查条件if if var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
context.beginPath();
context.moveTo(100, 150);
context.lineTo(450, 50);
context.lineWidth = 10;
context.strokeStyle = '#ff0000';
context.stroke();
context.beginPath();
context.moveTo(100, 150);
context.lineTo(450, 50);
context.lineWidth = 10;
context.strokeStyle = '#ffffff';
context.stroke();
if if返回true如果返回true,则返回true function($String) == true
我正在检查页面中的if条件,但我无法看到任何语句或页面重定向。
可能是什么问题?
这就是我所做的。
header('Location: home.php')
功能:
<?php
if(ifproductPublished($qs) == true){
echo "hey its true";
} else {
header('Location: index.php');
}
?>
答案 0 :(得分:1)
如@ chris85所述,您可以更改sql然后简化函数,如:
function ifproductPublished( $productID ){
$conn = new mysqli( DB_HOST, DB_USER, DB_PASS, DB_NAME );
if ( $conn->connect_error ) die("Connection failed: " . $conn->connect_error);
$sql = "SELECT `product_status` FROM `product_list` WHERE `product_id`='$productID' and `product_status`=1;";
$result = $conn->query( $sql );
$status = false;
if ( $result->num_rows > 0 ) {
$status=true;
} else {
echo "No results found";
}
$conn->close();
return $status;
}