单个条目中的PHP SQL多行

时间:2015-10-30 08:59:04

标签: php mysql

我正在学习如何使用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'上使用多行,当我从该表中选择时,我不会多行。 '描述'是一个TEXT类型列。

示例

表格填写'说明'如下:

We are going to talk about topics:
1 - PHP & SQL basics
2 - great discussion over here

SQL查询回复一行:

We are going to talk about topics: 1 - PHP & SQL basics 2 - great discussion over here

任何人都可以帮助我吗? 我知道这不是一个难以解决的问题。我一直在寻找这个问题的答案,但是当大多数"多行或多行时,很难找到相关内容。教程和问题与其他问题有关。

3 个答案:

答案 0 :(得分:0)

您需要一个while循环来从数据库中获取所有结果。所以在template <typename T> using type = typename T::value_type; void show_element(type i){ //type i must be sthg like *data.begin() std::cout << i << endl; } 之后你需要:

$retval = mysql_query( $sql, $conn );

此外(一如既往......),请考虑使用较新的mysqli-functions。

答案 1 :(得分:0)

在显示数据时尝试此操作

/*global define, Backbone, React, $, Request, Router, Route, Link */

var App = React.createClass({
    render: function () {
        return (
            <div>
                <h1>App</h1>
                // this will not unmount when routes are changed
                <Timer /> 
                <ul>
                    <li><Link to="/about">About</Link></li>
                </ul>
                // this will unmount/mount when routes are changed
                {this.props.children}
            </div>
        )
    }
});

var About = React.createClass({
    render: function () {
        return <h3>Here is about page</h3>
    }
});

var Timer = React.createClass({
    getInitialState: function() {
        return {counter: 0};
    },
    render: function () {
        return (
            <div>
                <h2>Time is running over...</h2>
                <b>{this.props.interval}</b>
                <p>{this.state.counter}</p>
            </div>
        )
    },
    componentDidMount: function () {
        this.loadCommentsFromServer();
        setInterval(this.loadCommentsFromServer, 1000);
    },
    loadCommentsFromServer: function () {
        this.setState({counter: this.state.counter + 1});
    }
});

React.render((
    <Router location="history">
        <Route path="/" component={App}>
            <Route path="about" component={About} />
        </Route>
    </Router>
), document.body);

答案 2 :(得分:0)

您可能在html中打印description的结果。尝试拨打echo nl2br($description);或用<pre>标签将其包围,它可能会出现在多行中。