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 6348481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:25:41+00:00 2026-05-24T21:25:41+00:00

the problem I am having I will describe it as best as I can….The

  • 0

the problem I am having I will describe it as best as I can….The user chooses three selections and the image appears on the screen, and the selections they made are sent and stored in the database, the PHP function below then finds the image for the selection and returns them as variables so the latest selection they made and the images corresponding to the selection is still displayed in the placeholders after the page is refreshed, the SQL code I have below I want to incorporate into one Query but I need it so where the data for $driver1 is found it is placed into the $image1 variable and the same for $driver2 into $image2, and $driver3 to $img3 so I can return them to the page and echo the correct images in the correct placeholders. The images for the selections they made need to appear in the placeholders that they originally appeared in. It works fine as it is now, but I am sure that the SQL querys can be shortened to one? to save lines of code.

The code I have posted below is the main important bits so you can hopefully understand what I am asking.

Any help would be great, thank you.

//HTML CODE
<?php
list($img1, $img2, $img3) = checkteam();
?>

<img onclick="return removedriver1(this)" id="advert" src="images/delete.gif"  border="0"/>
    <img id="placeholder1" src="<?php echo "$img1";?>" alt="" />
<img onclick="return removedriver2(this)" id="advert src="images/delete.gif" border="0"/>
    <img id="placeholder2" src="<?php echo "$img2";?>" alt="" />
<img onclick="return removedriver3(this)" id="advert" src="images/delete.gif" border="0"/>
        <img id="placeholder3" src="<?php echo "$img3";?>" alt="" />


//PHP CODE
function checkteam(){

$sql="SELECT image FROM drivers WHERE drivers_id = '$driver1'"; 
                $result=mysql_query($sql);
                $row = mysql_fetch_array($result);

                $image1=$row[image];

$sql="SELECT image FROM drivers WHERE drivers_id = '$driver2'"; 
                $result=mysql_query($sql);
                $row = mysql_fetch_array($result);

                $image2=$row[image];

$sql="SELECT image FROM drivers WHERE drivers_id = '$driver3'"; 
                $result=mysql_query($sql);
                $row = mysql_fetch_array($result);

                $image3=$row[image];

return array ($image1, $image2, $image3);
}
  • 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-24T21:25:41+00:00Added an answer on May 24, 2026 at 9:25 pm

    You could do one query only:

    $sql = "SELECT drivers_id id, image FROM drivers WHERE drivers_id in ($driver1, $driver2, $driver3)";
    

    You would need to myqsl_fetch_array three times, of course.

    while ($row = mysql_fetch){
        if ($driver1 == $row['id'])
         $image1 = $row['image'];
        else if ($driver2 == $row['id'])
         $image2 = $row['image'];
        else if ($driver3 == $row['id'])
         $image3 = $row['image'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems when publishing services on IIS. First, I will describe my scenario.
I'm having problem with handling multiple security context files. Let me describe what I'm
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
I'm having problem when running my Windows Forms program. In the program, I have
I'm having problem with Rails plugin attachment_fu . On every upload, I get validation
i'm having problem to deal with charset in ruby on rails app, specificially in
I am having problem in getting reference of Ajax control extender using $find() or
I'm having problem selecting an element with an id like this <li =0f:Bactidol_Recorder.mp4>. I
I'm having problem restricting a query in mdx, using except function at where clause.
I am having problem that when i am trying to submit the form by

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.