Quantcast
Channel: Topic Tag: MySQL | WordPress.org
Viewing all articles
Browse latest Browse all 5527

DionDesigns on "How to run two queries one after another in php"

$
0
0

You need to fetch the data in the first query. Something like:

$retrval = "select user_id from user_dtls where u_emailid='{$mid}'";
$result1 = mysqli_query($connection, $retrval);
$row = mysqli_fetch_assoc($result1);
$user_id = $row['user_id'];
mysqli_free_result($result1);

You can then add the variable into your insert:

$insertquery = "insert into utmp_orders (tord_dt, user_id, file_path, file_name, cat_id, pay_flag) values ('{$curr_dt}', $user_id, '{$filepath}', '{$filename}', 1, 'N')";

Note that you should always free the result set after fetching data. The DB connection is left open if you don't, and you risk having your program abort with a MySQL "too many open connections" error.


Viewing all articles
Browse latest Browse all 5527

Trending Articles