我正在学习如何使用PHP和SQL,我面临着一个小麻烦。
如何使用PHP从SQL中添加和选择多行项。
$queryy = [
$idSala = addslashes ($_POST['idSala']),
$organizer = addslashes ($_POST['organizer']),
$date = $_GET['date'],
$time_start = $_GET['starthour'],
$time_end = $_GET['endhour'],
$subject = $_POST['subject'],
$description = $_POST['description'],
$attendee = $_POST['invitee1']
];
}
$sql = "INSERT INTO logs ". "(toIdSala,organizer,date,hourstart,hourend,subject, description, attendee) ". "VALUES('$idSala','$organizer','$date','$time_start','$time_end','$subject','$description','$attendee')";
mysql_select_db('scheduler');
$retval = mysql_query( $sql, $conn );
header('Refresh: 3; URL=sendmail.php?' . http_build_query($queryy));如果我在“description”上使用多行,当我从该表中选择时,就不会得到多行返回。“‘description”是一个文本类型列。
示例
填写“描述”的表格如下:
We are going to talk about topics:
1 - PHP & SQL basics
2 - great discussion over hereSQL查询只回答一行:
We are going to talk about topics: 1 - PHP & SQL basics 2 - great discussion over here有谁可以帮我?我知道这不是一个很难解决的问题。我一直在寻找这个问题的答案,但当大多数“多行或多行”教程和问题与其他问题相关时,很难找到相关的内容。
发布于 2015-10-30 09:09:15
您可能在html中打印来自description的结果。尝试调用echo nl2br($description);或用<pre>标记包围它,它可能会出现在多行中。
发布于 2015-10-30 09:07:12
您将需要一个while循环来从数据库中获取所有结果。因此,在$retval = mysql_query( $sql, $conn );之后,您将需要:
while ($row = mysql_fetch_array($retval)) {
// $row holds the results
}此外(一如既往.),请考虑使用新的mysqli函数。
发布于 2015-10-30 09:08:51
在显示数据时尝试这样做
htmlentities($description);https://stackoverflow.com/questions/33432101
复制相似问题