将值插入从

时间:2016-06-30 10:46:02

标签: php mysql database

我有一个完美的表格。我的数据库中有每个类别的表。我想直接将值发送到一个类别表,我将从我尝试这样做的形式中的类别输入中选择,但它不起作用!有任何想法吗?? thanx很多

$categorie=$_POST['categorie'];
$sql = "INSERT INTO '$categorie' (title, price, description, urlimage) VALUES ('$ad_title', '$ad_price', '$ad_description', '$ad_photo') ";
$conn->query($sql);


<form method="post" role="form" action="" enctype="multipart/form-data">                   
    <div class="row">
        <div class="col-lg-12 padding-top-10">
            <label for="title" class="control-label">Titre</label>
            <input type="text" class="form-control" name="title" placeholder="Title" required></input>
        </div>                                
    </div>
    <div class="row">
        <div class="col-lg-12 padding-top-10">
            <label for="price" class="control-label">Prix</label>
            <input type="text" class="form-control" name="price" placeholder="Price" required></input>
        </div>                     
    </div>
    <div class="row">
        <div class="col-lg-12 padding-top-10">
            <label for="categorie" class="control-label">categorie</label>
            <input type="text" class="form-control" name="categorie" placeholder="categorie" required></input>
        </div>                     
    </div>
    <div class="row">
        <div class="col-lg-12 padding-top-10">
            <label for="description" class="control-label">Description*</label>
            <textarea class="form-control" rows="5" name="description"></textarea> 
        </div>                      
     </div>  
     <div class="row">
        <div class="col-lg-12 padding-top-10">
            <label for="photo" class="control-label">Photo</label>
            <input type="file" class="form-control" name="photo" required></input>
        </div>                     
    </div>                   

                <div class="row">
        <div class="col-md-12 padding-top-10">   
            <button type="submit" class="btn btn-primary btn-lg btn-block" name="submit">Post</button>
        </div>      
   </div>                               
</form>    

1 个答案:

答案 0 :(得分:0)

你应该在这里使用“(双引号)或”后退。

$sql = "INSERT INTO `$categorie` ...