使用MySQL中的SELECT从多个表中将数据插入到单个表中?这里cus_order是我的表有名称,快照,价格列...名称应该从寄存器表和快照,价格... ... [英] Insert data to single table from multiple tables using SELECT in MySQL? here cus_order is my table having name,snap,price columns...name should be retrived from register table and snap,price...

查看:147
本文介绍了使用MySQL中的SELECT从多个表中将数据插入到单个表中?这里cus_order是我的表有名称,快照,价格列...名称应该从寄存器表和快照,价格... ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<blockquote class="quote"><div class="op">Quote:</div>
<?php
	session_start();
	if(!(isset($_SESSION['unm']) && $_SESSION['unm']!=''))
	{
		header('location:index.php?dp=4');
	}
	else
	{
		$unm=$_SESSION['unm'];
		
		$con=mysql_connect("localhost","root","");
		$db=mysql_select_db("Project_Interior",$con);
		
		$query="select snap,SUM(price) from cart";
		$result=mysql_query($query);
		
		while($row=mysql_fetch_array($result))
		{
			$totbill=$row['SUM(price)'];	
			$snap=$row['snap'];
		}
		
		$nameQuery="select name from register where email_id='$unm'";
		$nameresult=mysql_query($nameQuery);
		
		while($row1=mysql_fetch_array($nameresult))
		{
			$name=$row1['name'];
		}
		
		$insquery="INSERT INTO cus_order (name,snap,price) ('$name',(SELECT snap,price from cart))";
		$insresult=mysql_query($insquery);
		
	}
	
?></blockquote>

推荐答案

_SESSION [' unm'])&&
_SESSION['unm']) &&


_SESSION [' unm']!= ' '))
{
header(' location:index.php?dp = 4');
}
其他
{
_SESSION['unm']!='')) { header('location:index.php?dp=4'); } else {


unm =


这篇关于使用MySQL中的SELECT从多个表中将数据插入到单个表中?这里cus_order是我的表有名称,快照,价格列...名称应该从寄存器表和快照,价格... ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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