在表中插入多行数据 [英] Inserting multiple rows of data in table

查看:65
本文介绍了在表中插入多行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


目前正在进行的系统允许用户选择一些花...点击提交,他们点击的任何内容都传递到下一页,我现在希望他们点击订单,每个花都插入到表中。

用户名 - flowerid - 数量 - 总计

user1 ------------ 2 ------ - 1 ----- 1.99

user1 ------------ 3 ------- 5 ----- 2.55

user1 ------------ 6 ------- 1 ----- 0.50

i尚未设置会话尚未显示用户名等...只是试图将选择的花朵分成多行......这是迄今为止我所获得的代码。


第7行显示了我的位置,但是允许我插入记录的sql语句。


[PHP]<?php

包括constants / flowertimedbcnx.php;


echo''您选择了以下花句:< br>'';

foreach($ _ GET [''flowerid'']为$ flower){

$ res = mysql_query(" SELECT * FROM flowers WHERE flowerid = $ flower");

// $ order = mysql_query(" INSERT INTO bqt_order VALUES .......?

while($ row = mysql_fetch_array($ res)){

echo" $ flower {$ row [''flowername'']}" ;;

echo" {$ row [''flowerdesc'']}< br>" ;;

}

}

?> [/ PHP]



非常感谢任何可以帮助我的人!

Hi all,

The system im working on currently allows the user to select a number of flowers.. click submit and whatever they clicked is passed onto the next page, i now want them to click order and each flower is inserted into the table.

username - flowerid - qty - total
user1 ------------ 2 ------- 1----- 1.99
user1 ------------ 3 ------- 5----- 2.55
user1 ------------ 6 ------- 1----- 0.50

i havent set up the session yet to display the username etc... just trying to insrt the flowers selected into multiple rows... heres the code ive got so far.!

line 7 shows where i would but the sql statement that allows me to insert the records.

[PHP]<?php
include "constants/flowertimedbcnx.php";

echo ''You have chosen the following flowerids:<br>'';
foreach($_GET[''flowerid''] as $flower) {
$res = mysql_query ("SELECT * FROM flowers WHERE flowerid = $flower");
//$order = mysql_query ("INSERT INTO bqt_order VALUES ....... ?
while ($row = mysql_fetch_array($res)) {
echo "$flower {$row[''flowername'']}";
echo " {$row[''flowerdesc'']} <br>";
}
}
?> [/PHP]



many thanks in advance to anyone who can help me with this!

推荐答案

_GET [''flowerid''] as
_GET[''flowerid''] as

flower){
flower) {


res = mysql_query(" SELECT * FROM flowers WHERE flowerid =
res = mysql_query ("SELECT * FROM flowers WHERE flowerid =


这篇关于在表中插入多行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆