Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8374947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:03:04+00:00 2026-06-09T15:03:04+00:00

I’m running a query to select an array of id’s from one table, so

  • 0

I’m running a query to select an array of id’s from one table, so that I can update another table with the data from the resulting dataset.

//db query result
$query = "SELECT image_id FROM jos_jxgallery_images ORDER BY jos_jxgallery_images.image_id DESC LIMIT 25";
 $query_execute = mysql_query($query);
mysql_close($db_config);

 while ($items = mysql_fetch_array($query_execute)) {
 echo $items['image_id']; 
 echo '<br/>';
}

I think I need to do it in the while loop, I just have the echo there to see what’s in items variable. That works ok. I think the thing to do is in the while loop..I’d like to replace the ‘echoing’ with an actual update SET query for my other table. Something like…

while ($items = mysql_fetch_array($query_execute)) {
$q = "UPDATE jx_gallery_images_ratings SET image_id ='".$items.""; 
mysql_query($q);

But the new table has no data. Is there just a better way to write this…maybe even as one query or something? Any help is appreciated.

EDIT: I should explain a little better. The table is empty, and I could go ahead and use an insert from one table to another just to get the id’s there. However, after that…in a way it is somewhat a ‘temp’ table. But not really. Whatever ordering of image_id’s I have created in my SELECT query from my first table (There are other rows to sort by other than image_id, like ‘hits’, for example)…so the second table needs to be updated with the same ordering of image_id’s. Probably be running this several little snippet several times with a cron job. So, yeah, I’m trying to update the second table with the ordering of the SELECT query of the first table and just put the id’s in my second table, again…according to the order of the first SELECT query.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:03:05+00:00Added an answer on June 9, 2026 at 3:03 pm

    If the table is empty, you should do an insert. You can do it in a single query like this:

    INSERT INTO jx_gallery_images_ratings (image_id)
    SELECT image_id FROM jos_jxgallery_images ORDER BY jos_jxgallery_images.image_id DESC LIMIT 25
    

    Note that you probably wouldn’t really need the ORDER BY, adn you could do it for all images at once by removing the LIMIT

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.