[英]how select data from table and print
I looked but now nothing, there is some way to select something from a table.我看了但现在什么都没有,有一些方法可以从表中获取 select 的东西。
For example:例如:
two text boxes number1
and number2
and enter 10 and 20, then print all records in a table from register 10 to 20.两个文本框number1
和number2
并输入 10 和 20,然后打印表格中从寄存器 10 到 20 的所有记录。
It is possible to do with这是可能的
$query = "SELECT * FROM crm_vendas WHERE venda_id BETWEEN 'number1' and '$ number2'";
and also with并且还与
while ($ row =?
if someone can indicate something or help I would appreciate it如果有人可以指出某事或提供帮助,我将不胜感激
You need to use prepared statements.您需要使用准备好的语句。 Also, you do not put backticks around the entire query line.此外,您不要在整个查询行周围放置反引号。 The i's in the bind_param line indicated that the two variables you're using are integers. bind_param 行中的 i 表示您使用的两个变量是整数。
$number1 = 0;
$number2 = 100;
$query = "SELECT * FROM crm_vendas WHERE venda_id BETWEEN ? AND ?";
$stmt = $db->prepare($query);
$stmt->bind_param('ii', $number1, $number2);
$stmt->execute();
$result = $stmt->get_result();
echo '<table>';
while ($row = $result->fetch_row()) {
echo '<tr>';
foreach($row as $columnValue){
echo '<td><p>'.$columnValue.'</p></td>';
}
echo '</tr>';
}
echo '</table>';
$result->close();
$stmt->close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.