I have tried several attempts and can get data to select and using echo display it, however, I need to take this data and insert it into the database in a separate table. I have the following which does hafl the job, can I get some pointers on the rest. I have looked everywhere and not found a solution, at all.
// Selects the data I need
<?php
mysql_connect("PRIVATE INFO","PRIVATE INFO","PRIVATE INFO") or
die("Could not connect: " . mysql_error());
mysql_select_db("wpdb");
$result = mysql_query("SELECT ID FROM wp_posts
WHERE post_title LIKE '%future%'
AND post_status = 'publish'
OR post_title LIKE '%option%'
AND post_content LIKE '%fundamental%'
AND post_status = 'publish'
ORDER BY post_date DESC");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo $row['ID'];
echo "<br />";};
?>
Thought maybe something like the following would work, but am at a loss:
INSERT INTO wp_term_relationships (object_id, term_taxonomy_id, term_order)
SELECT ID FROM wp_posts
WHERE post_title LIKE '%future%'
AND post_status = 'publish'
OR post_title LIKE '%option%'
AND post_content LIKE '%fundamental%'
AND post_status = 'publish'
ORDER BY post_date DESC
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
VALUES
($row['ID'], '25', '0')