| | |
insrting from one table to another
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
well i guess the problem is that when i use the command
$res = select * from table where column = 'value';
then AN ENTIRE RECORD is returned into $res.
Then, when i try to assign the value of $res into the other table, i am trying to assign a RECORD into a COLUMN, which is probably causing he error....
in case this is correct, how do i get over this??
$res = select * from table where column = 'value';
then AN ENTIRE RECORD is returned into $res.
Then, when i try to assign the value of $res into the other table, i am trying to assign a RECORD into a COLUMN, which is probably causing he error....
in case this is correct, how do i get over this??
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
I have referredd to the links ou indicated, and this is the code i have come up with. But this doesnt seem to work either. I guess the error is based on the usage of ("") , ('') and (``) at different points in the query.
Somebody please clarify... with the code...
MY CODE
thx...
Somebody please clarify... with the code...
MY CODE
php Syntax (Toggle Plain Text)
$res = select * from table1 where column1 = 'value'; mysql_query("Update table2 set col2 = '$res[`1`]' ");
thx...
Last edited by peter_budo; Jul 10th, 2008 at 9:58 am. Reason: Keep It Organized - please use [code] tags
Okay. This is how you do it.
php Syntax (Toggle Plain Text)
$res = mysql_query("select * from table1 where column1='value'"); while($row = mysql_fetch_array($res)) { $value2 = $row['column2']; //assign column2 value to $value2 $query = mysql_query("update table2 set col2='$value2'"); //update col2 in table2 } ?>
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
The CODE
plz help...
thx...
php Syntax (Toggle Plain Text)
// retreiving data from table 1 $r1 = mysql_query("Select * from table1 where Column1 = '$test' ") or die(mysql_error()); // updating the other table while($row = mysql_fetch_array($r1)) { $value2 = $row['Rate']; $query = mysql_query("update table2 set amt = '$value2' "); }
plz help...
thx...
Last edited by peter_budo; Jul 9th, 2008 at 7:17 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Jun 2008
Posts: 46
Reputation:
Solved Threads: 0
•
•
•
•
Before while have this.
print mysql_num_rows($r1);I believe, your query doesn't return any records.
The above print statement, will print the number of records found for the select query.
Hey nav33n.
You were right. IO tried that command an it showed 0, indicating that no rows were returned by SQL.
Now pls suggest what i shud do...
i shall be highly grateful fr ur co-operation.
thx a lot...
![]() |
Other Threads in the PHP Forum
- Previous Thread: Back Button problem
- Next Thread: Storing button clicks
| Thread Tools | Search this Thread |
apache api array beginner binary body broken cakephp checkbox class cms code cron curl database date date/time delete display dynamic echo email error file files filter folder form forms function functions gc_maxlifetime global google host href htaccess html image include insert ip javascript joomla limit link list login mail memmory memory menu mlm msqli_multi_query multiple mycodeisbad mysql navigation oop parameter parsing paypal pdf php problem query radio random recourse recursion regex remote script search seo server sessions sms snippet source space sql static syntax system table thesishelp trouble tutorial update upload url validator variable video web webdesign wordpress xml youtube







