-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

you may find "insert ... select" interesting for what you want hehe
try this:

$sql = "INSERT INTO client (c_name, c_company, c_worktel, c_directtel,
c_hometel, c_fax, c_cell, c_email, c_address, c_city, c_pcode,
c_country)
        SELECT p_name, p_company, p_worktel, p_directtel, p_hometel,
p_fax, p_cell, c_email, c_address, c_city, c_pcode, c_country FROM
prospects WHERE p_id='. $p_id .'";

mysql_query($q, $this->link) or die ("".mysql_error());



more information:
http://www.mysql.com/doc/en/INSERT_SELECT.html


Angelo Zanetti wrote:
HI all I have a Select that get a resultset, once I get this then I
use the values of this resultset to enter them into another table
using an INSERT statement. I get no errors from the statement but it
just doesn't seem to see my variables from the recordset,

below is my code:



$q="select * from prospects where p_id = '$p_id'"; $result=mysql_query($q, $this->link) or die ("".mysql_error());

while($a_row=mysql_fetch_array($result)) { $c_query="Insert into
client (c_name, c_company, c_worktel, c_directtel, c_hometel, c_fax,
c_cell, c_email, c_address, c_city, c_pcode, c_country) VALUES
($a_row['p_name'], $a_row['p_company'], $a_row['p_worktel'], $a_row['p_directtel'], $a_row['p_hometel'], $a_row['p_fax'], $a_row['p_cell'], $a_row['c_email'], $a_row['c_address'],
$a_row['c_city'], $a_row['c_pcode'], $a_row['c_country'])"; mysql_query($c_query,$this->link) or die ("".mysql_error()); }


I echo'd out the values from the Select just to make sure it was
getting the correct values.

any help will be appreciated, thanx in advance

Angelo

-------------------------------------------------------------------- Disclaimer This e-mail transmission contains confidential
information, which is the property of the sender. The information in
this e-mail or attachments thereto is intended for the attention and
use only of the addressee. Should you have received this e-mail in
error, please delete and destroy it and any attachments thereto
immediately. Under no circumstances will the Cape Technikon or the
sender of this e-mail be liable to any party for any direct,
indirect, special or other consequential damages for any use of this
e-mail. For the detailed e-mail disclaimer please refer to http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

- -- André Cerqueira
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


iD8DBQFAPhoRaxdA/5C8vH8RAhJcAKDAf1xmOleWw/6MiQZbY62zXlBalACfcHBf
M6dd6Cadf44qGVjc1RS3kSM=
=5ZMB
-----END PGP SIGNATURE-----

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to