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

  • SEARCH
  • Home
  • 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 6711865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:11:30+00:00 2026-05-26T08:11:30+00:00

I have an existing recordset that retrieves all the information from a table in

  • 0

I have an existing recordset that retrieves all the information from a table in mysql called $rrows. What I am hoping to do is to use this existing recordset within a new mysql query.

For example I have the following line that retrieves the “product code” from one table:

<?php echo $rrows['productcode']; ?>

I am trying to then gather the respective images from a new table using this productcode by something similar to:

<img src="<?php

mysql_select_db("dbname", $con);
mysql_set_charset('utf8');

$result = mysql_query("SELECT * FROM furnimages WHERE productcode='$rrows['productcode']'");

while($row = mysql_fetch_array($result))
{
    echo '' . $row['photo'] . '';   
}
mysql_close($con);
?>">

Can this be done? Originally I was going to LINK tables together to get all the information, but this doesnt work as some of the product codes in the main do not have corresponding data in the ‘furnimages’ table…..

Thanks in advance!
JD

  • 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-05-26T08:11:30+00:00Added an answer on May 26, 2026 at 8:11 am

    sprintf() is your best friend here.

    $sql = <<<sql
    SELECT * FROM furnimages 
    WHERE productcode=%d
    sql;
    
    $result = mysql_query(sprintf($sql, $rrows['productcode']));
    

    So, %d is the placeholder in the string to swap in the second argument in the call to sprintf();

    %d denotes an integer placeholder; if $rrows[‘productcode’] is a string, use %s.

    This is better than simply quoting value of the variable as it adds a type constraint which reduces the risk of nasty sql injection.

    It also makes it eminently more readable.

    Check out the PHP Data Objects extension, though, because that really is the only way forward for this type of thing.

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

Sidebar

Related Questions

I have a successful query that currently returns all data except for one table.
I have some existing code that accepts a java.sql.ResultSet that contains info retrieved from
After loading data from a csv into an existing Postgres table, I will have
I have existing code that uses CMNewProfileSearch to find then iterate over the color
I have existing java code and need to create Design Document based on that.
For whatever reason, I have a lot of clients that have existing data that's
So I have an existing ASP.NET solution that uses LINQ-to-SQL to insert data into
I have a single table with lots of records (> 100k) that I need
I have an existing database that was setup (for whatever reason??) to store a
I have a database that is MySQL / Php technology. I have a database

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.