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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:39:36+00:00 2026-05-27T15:39:36+00:00

I will admit right now I have gone through all of the posts though

  • 0

I will admit right now I have gone through all of the posts though I went through to 2008. My problem is that the if else statement is only receiving one row and calling all the others false off of both of the while loops or receives 2 when you use the form. I am trying to see if in all the rows if a item is bought using 2 different databases. Here is the code.

$id2 = $_SESSION['id'];
$naturesql = mysql_query("SELECT * FROM backgrounds WHERE type=2");
while($row = mysql_fetch_array($naturesql)) {
    $id = $row['id'];
    $name = $row['name'];
    $background = $row['background'];
    $pic = $row['image'];

    $check = mysql_query("SELECT * FROM store_items WHERE userid='$id2'");
    while($checkrow = mysql_fetch_array($check)) {
        $types = $checkrow['type2'];
    }

    if($id == $types) {
        $bought = 'This item has already been bought';
    } else {
        $bought = '<form>
                   </form>';
    // this form works fine
    }

    $display .= '<table width="100%"><tr><td><center><font size="+1">' . $name . '</font></center></td></tr><tr><td><center><img src="' . $pic . '" width="80px"></img></center></td></tr><tr><td>' . $bought . ' </td></tr></table>';
}

...

<?php echo $display ?>

What shows up.

1st result
Name 1
Pic 1
form shows up here

2nd result
Name 2
Pic 2
form also shows up here

3rd and last result
Name 3
Pic 3
This item has already been bought

This is what I get when I look on the page. If I bought a item this is what I get lets say 1st item.

1st result
Name 1
Pic 1
This item has already been bought

2nd result
Name 2
Pic 2
form also shows up here

3rd and last result
Name 3
Pic 3
This item has already been bought

It pops this up. Though when I refresh turns back into the the 1st one I shown only showing 1 result. Any thoughts why not working with the others.

It should be like this if you bought all but is not

1st result
Name 1
Pic 1
This item has already been bought

2nd result
Name 2
Pic 2
This item has already been bought

3rd and last result
Name 3
Pic 3
This item has already been bought

My only other question is there an alternative to this so keeps the loop and checks if the statement is true or not like a if else statement. If I can’t do it with if else statement.

  • 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-27T15:39:36+00:00Added an answer on May 27, 2026 at 3:39 pm

    I can’t post everything on here though here should give some in site what I did to get this to work. Surprisingly it worked like a charm. Note to everyone putting in 2 tables in one mysql_query didn’t help at all it just made things worse. So I wouldn’t advise it for this.

    Simple version I did

    $id = $_SESSION[id];
    
          $check = mysql_query("SELECT * FROM store_items WHERE userid='$id2'");
    while($checkrow = mysql_fetch_array($check)){
    
    $types = $checkrow['type2'];
    
    
    
    }
    
    
        $naturesql = mysql_query("SELECT * FROM backgrounds WHERE type=2");
    while($row = mysql_fetch_array($naturesql)) {
        $id = $row['id'];
        $name = $row['name'];
        $background = $row['background'];
        $pic = $row['image'];
    
    
    $check = mysql_query("SELECT * FROM store_items WHERE userid='$id2' AND type=2 AND type2='$id' AND other='$pic'");
    while($checkrow = mysql_fetch_array($check)) {
        $types = $checkrow['type2'];
    
    }
    if($id == $types) {
        $bought = 'This item has already been bought';
    } else {
        $bought = '<form>
                   </form>';
    // this form works fine
    }
    
    
    $display .= '<table width="100%"><tr><td><center><font size="+1">' . $name . '</font></center></td></tr><tr><td><center><img src="' . $pic . '" width="80px"></img></center></td></tr><tr><td>' . $bought . ' </td></tr></table>';
    
    }
    

    Like I promised I would post if I figured it out. Might of toke a little longer then I hoped but well there you go.

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

Sidebar

Related Questions

Right now i have a batch job I wrote that calls another file and
I have a fairly well project that I am developing right now, but I
First of all, I will admit I am a novice to web services, although
I will openly admit that I fall on the side of Test Driven Development.
The project I'm working on right now needs a reference system (currently they have
Right now I'm using Doctrine2 in conjunction with Symfony2. I have an entity called
I've got a rails 3 app in beta right now that uses Devise for
I'm using custom WordPress categories for some probably unintended functions, I will admit (things
I am trying to create a Wordpress MU admin plugin, that will insert some
I have had this problem for a while, still trying to work on a

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.