Jump to content

kamlooper

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by kamlooper

  1. I can give this a try, the only question i have with that is, there will be duplicate ID's, just want to avoid it erroring out when i have data that will be duplicate's in two columns. I am taking data from one table, inserting it into another table with hardcoded category numbers, its when the hardcoded category number and ID's both already exist that I need it to basically say F'it and skip this one and move onto the next insert. can you help me on this, I am a bit of a self tough hack. So any direction you can provide would be HUGE!
  2. I have no problem with that option. I am running this in php, ideally trying to get it to the point so it can auto load the php page in a cron job, and if it errors and continues so that any new data is added, that would be totally fine by me, so long as applicable data is still inserted if it errors. How would I do that though?
  3. I have the following to take data from one table and add it to a seperate table. It all works unless I have the data already in the table I am adding to. So what I wanted to do was add the first where statement to check the data prior to attempting to add it, but it does not seem to make a difference. Can someone help me with the clauses or statements i need to cross check the data from the two tables so that it does not error out if I have the data already in the table I am adding to. INSERT INTO wp_term_relationships (object_id, term_taxonomy_id, term_order) SELECT ID, 27, 0 FROM wp_posts WHERE wp_term_relationships.object_id = wp_posts.ID AND wp_term_relationships.term_taxonomy_id <> 27 AND WHERE post_title LIKE '%future%' AND post_status = 'publish' OR post_title LIKE '%option%' AND post_content LIKE '%fundamental%' AND post_status = 'publish'
  4. I used the following and it worked!!! THANK YOU. $sql="INSERT INTO wp_term_relationships (field1, field2, field3) SELECT ID, hardcoded number1, hardcoded number2 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' "; if (!mysql_query($sql,$con)) { die('Unfortunately the ID chosen is already in use please click the back button and select a different ID.' ); }
  5. I have looked at your suggestion and have a few questions. I am only pulling the ID information from one table to post into a second, leaving the other two columns to be auto populated with information I will provide. Example (value1, value2, value3) = (value1 carried out multiple times from a looking array, value2 a number i set, lavue 3 again a number i set) (row[iD], 25, 0) I dont know if this makes any sense, I have been looking at it so long i am cross eyed. basically i want to take ID data (multiple results) from a query of one table and insert it with other hard coded data into a separate table?
  6. 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')
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.