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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:30:35+00:00 2026-05-31T11:30:35+00:00

This might be really simple, but i cannot figure out the problem with this

  • 0

This might be really simple, but i cannot figure out the problem with this code:

$sql = mysql_query("select * from Temporary_Stock_Transfer where Emp_ID = '$emp_id' and Company_ID = '$company_id'");
    if(mysql_num_rows($sql) == 0) {
        echo "<tr><td colspan='3'><i>You currenty have no items</i></td></tr>";
    }else {
        while($row = mysql_fetch_array($sql)) {
            echo mysql_num_rows($sql);
            echo 'reached';
            $book_id = $row[1];
            $sql = mysql_fetch_row(mysql_query("select title from Book where Book_ID = '$book_id'"));
            echo "<tr><td>".$sql[0]."</td><td>".$row[2]."</td><td><span class='label label-important'>Remove</span></td></tr>";
        }
    }

Now based on my database the query is returning 2 results, the echo mysql_num_rows($sql) also gives out 2. However the reached is echoed only once. Does anyone see a potential problem with the code?

P.S: My bad, $sql is being repeated, that was a silly mistake

  • 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-31T11:30:37+00:00Added an answer on May 31, 2026 at 11:30 am

    I think it’ll be because you are ressetting the sql variable

                $sql = mysql_fetch_row(mysql_query("select title from Book where Book_ID = '$book_id'"));
    

    when you are still using it in the while loop. 😛

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

Sidebar

Related Questions

I feel like this might be really simple but I'm just not getting it
So this might be really simple, but I haven't been able to find any
There might be a really simple solution to this question, but i just don't
I know this might be really a simple question but I don't know the
This might be a really simple thing but i was unable to find an
This might be really simple but i have a service that returns a string
this might be really simple, but just need some help in getting the syntax
I'm sure what I want is very simple but I cannot figure out how.
Ok, this might be a really odd problem. I am writing a web application,
This might be really simple question and I though the <text> tags were the

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.