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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:45:57+00:00 2026-06-03T13:45:57+00:00

I have a script to insert values into a database and then once done

  • 0

I have a script to insert values into a database and then once done passes a header to a page where it checks for blank values in a certain column and returns them on the page which I will later make editable so they can be updated.

The problem I’m having is when I’m running the query its not returning the cells with the blank values.

$sql = "SELECT * FROM `data` WHERE `team`=''";

$result = mysql_query($sql, $conn);
if(!$result) {
    echo "Cannot do query" . "<br/>";
    exit;
}

$row = mysql_fetch_row($result);
$count = $row[0];

$each_results = mysql_fetch_row($result);

for ($i=0; $i<$each_results; $i++) {
    $row = mysql_fetch_assoc ($result);
    echo $row['rep_num'] . " " ;
    echo $row['team'] . " ";
    echo $row['description'] . "</br>";
}

I tried SELECT * FROM data and it returned all the results including the results with no team value. I ran the SELECT * FROM data WHERE team=” query in phpmyadmin and it did return the rows I expected it to with the missing cell data from the team row. So I guess its something wrong with my for loop at the bottom.

Thank you in advanced for your help.

  • 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-03T13:45:58+00:00Added an answer on June 3, 2026 at 1:45 pm

    $each_result does not contain the value you expect it to; you have fetched a row from the result set into it as an array, and cannot do a comparison like $i < $each_results) Rather than a for loop, iterate your rows with a while loop

    // Don't call fetch here, as it will advance the record pointer
    // before you intend to.
    //$row = mysql_fetch_row($result);
    //$count = $row[0];
    
    //$each_results = mysql_fetch_row($result);
    
    // Replace the for loop with a while loop
    while ($row = mysql_fetch_assoc($result)) {
        echo $row['rep_num'] . " " ;
        // Note, team should be blank because you queried team=''
        echo $row['team'] . " ";
        echo $row['description'] . "</br>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which captures tweets and puts them into a database. I
I have a problem using the MySQLdb library. I'm trying to insert values into
I have a PHP script that creates an entry into a mysql database. The
I have this query running in my PHP script: $insertQuery = "INSERT INTO blog_articles
I have the Execute SQL Script package that contains the script to insert about
If I have a script which inserts data then exits, the script will be
I have a VBA script that inserts long strings into Excel cells. In some
I have a Greasemonkey script that dynamically inserts an HTML form into some web
I have script like this : fullscript.sh if [ ! -f /opt/laks/linux-2.6.33.2.tar.bz2 ] then
I have some script in my default page that redirects users to language specific

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.