Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ect ID、Name、Price from lamps,其中ID='$WHERE'和Price='$something'不存在?我在查询中尝试的第一件事就是这个确切的语句,但仍然存在这个问题设置变量后最终的sql是什么样子的?ie:执行sql时是否可以按_Php_Mysql_While Loop_Session Variables - Fatal编程技术网

Php ect ID、Name、Price from lamps,其中ID='$WHERE'和Price='$something'不存在?我在查询中尝试的第一件事就是这个确切的语句,但仍然存在这个问题设置变量后最终的sql是什么样子的?ie:执行sql时是否可以按

Php ect ID、Name、Price from lamps,其中ID='$WHERE'和Price='$something'不存在?我在查询中尝试的第一件事就是这个确切的语句,但仍然存在这个问题设置变量后最终的sql是什么样子的?ie:执行sql时是否可以按,php,mysql,while-loop,session-variables,Php,Mysql,While Loop,Session Variables,ect ID、Name、Price from lamps,其中ID='$WHERE'和Price='$something'不存在?我在查询中尝试的第一件事就是这个确切的语句,但仍然存在这个问题设置变量后最终的sql是什么样子的?ie:执行sql时是否可以按原样显示sql当对多个变量执行sql时,它只显示列的标题,但当只有一个变量时,它显示该变量的所有信息;产品名称和价格能否添加最终呈现的sql语句?或者$\u SESSION['cart']的内容?我在查询中尝试的第一件事就是这个确切的语句,但仍


ect ID、Name、Price from lamps,其中ID='$WHERE'和Price='$something'不存在?我在查询中尝试的第一件事就是这个确切的语句,但仍然存在这个问题设置变量后最终的sql是什么样子的?ie:执行sql时是否可以按原样显示sql当对多个变量执行sql时,它只显示列的标题,但当只有一个变量时,它显示该变量的所有信息;产品名称和价格能否添加最终呈现的sql语句?或者
$\u SESSION['cart']
的内容?我在查询中尝试的第一件事就是这个确切的语句,但仍然存在这个问题设置变量后最终的sql是什么样子的?ie:执行sql时是否可以按原样显示sql当对多个变量执行sql时,它只显示列的标题,但当只有一个变量时,它显示该变量的所有信息;产品名称和价格能否添加最终呈现的sql语句?或者
$\u会话['cart']
的内容?
$wherein = implode(',', $_SESSION['cart']);
$sql = "select ID, Name, Price from lamps WHERE ID = '$wherein'";
$result = mysqli_query($conn, $sql);

echo "<table style='width:100%' border='1' >";
echo "<tr>";
echo "<th> Product Name</th>";
echo "<th>Product Price </th>" ;
echo "<th>Quantity </th>" ;
echo "</tr>";

while ( $row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
    echo "<tr>";
    echo "<td>" . $row['Name'] . "</td>";
    echo "<td> $". $row['Price'] . "</td>" ;
    echo "<td> <select>
        <option value= '1'>1</option> 
        <option value= '2'>2</option> 
        <option value= '3'>3</option> 
    </select>
    </td>";

    echo "</tr>";
}

echo "</table>";
$wherein = implode("','", $_SESSION['cart']);
$sql = "select ID, Name, Price from lamps WHERE ID IN ( '$wherein' )";
$wherein = implode("','", $_SESSION['cart']);
$sql = "select ID, Name, Price from lamps WHERE ID IN ( '$wherein' )";
$result= mysqli_query( $conn, $sql );

echo "
    <table style='width:100%' border='1' >
        <tr>
            <th> Product Name</th>
            <th>Product Price </th>
            <th>Quantity </th>
        </tr>";

while ( $row = mysqli_fetch_object( $result ) ){
    echo "
        <tr>
            <td>{$row->Name}</td>
            <td>${$row->Price}</td>
            <td>
                <select>
                    <option value= '1'>1
                    <option value= '2'>2
                    <option value= '3'>3
                </select>           
            </td>
        </tr>";
}
echo "
    </table>";


/* Example of using an array of IDs and imploding to generate where conditions for IN clause */

$cart=array('BGL1','BJL');
/* session - cart */

$wherein=implode( "','", $cart );
/* correctly add quotes around each string */

$sql="select ID, Name, Price from lamps WHERE ID IN ('$wherein');";
/* use the new $wherein string within quotes */
echo $sql;

>> select ID, Name, Price from lamps WHERE ID IN ('BGL1','BJL');