 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
ghostly
Joined: 07 May 2008 Posts: 1
|
Posted: Wed May 07, 2008 8:45 am change fields of one table to another in my sql |
|
|
|
sry for my english
i'm working on project and i need help...i'm devolopment him in html, php and mysql using wampserver
i need to change one record that are in one table to another
both tables have the same fields, and i put de primary key of table 1 on table2, only put one new primary key to table 2
ex:
table 1 ----------> tabel2
key:cod_table1 -----------------> key:code_table2
name: Jonh -----------------> id:code_table1
city: new york -----------------> name:jonh
....etc -----------------> city:new york
-----------------> ...etc
__________________________________________
i try some like this (but doesn't work):
___________________________________________
form.php
<?php
$con = mysql_connect("localhost","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$sql ="INSERT INTO table2 (code_table1, name, city, etc)
SELECT * ($cod_table1, $name, $city, etc) FROM table1 WHERE code_table1 ='$_POST[cod_table1]';";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record Changed";
?>
_______________________________________________
form.hmtl
<form action="form.php" method="post">
code_table1:<input type="text" name="code_table1" />
<input type="submit" value="Submit" />
</form>
_______________________________________________
sry for my very, very, very, bad english, hope someone understand that, and can help me...
thx for read |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
 |
|
|
|
|
|
|
|