-
PHP/MySQL Problem -
Code here:
http://216.74.101.27/help.html
Example here:
http://216.74.101.27/admin/newsubcat.php
Thanx if anyone could help. I am trying to select from one table then use that to then insert into a difffernt table, with other data.
-
Once you get the data into an array (such as $results), you can do another query and just intepolate the variables in there.
Is that what you were asking? There's no special way to do it other than what I just said, if I understood your question correctly.
-
-
$dbh = mysql_pconnect(...);
mysql_select_db("...");
$qry = mysql_query("select..."); // must only return one row
$results = mysql_fetch_array($qry);
mysql_select_db("...");
$qry = mysql_query("insert ".$results['hi']."etc etc etc");
Do you want more of a description?
-
Yes.....sorrta.....i am very new to PHP and MySQL
Thanx
-
Going through my code line by line...
Connect to the DB with a persistent connection so it will last longer. (you need to fill this in)
Select the mysql db named ".." (you need to fill this in)
Run a select query (you need to fill this in)
Assign $results to the returned array
Select the DB to insert to
Do the insert query with interpolated variables.
-
The correct syntax for the "INSERT ..." is
INSERT INTO dbase SET field1='value1', field2='value2'
so change the line in your script into
Code:
$sql = "INSERT INTO subcategory SET ".
Chris
-
-
I just have no idea how to incorporate this into my code, using the select box, text area and text input box?