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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:42:46+00:00 2026-05-21T09:42:46+00:00

I’m a beginner to PHP/mySql. I’m writing a CMS and still in the early

  • 0

I’m a beginner to PHP/mySql. I’m writing a CMS and still in the early stage.
I wrote a code to take the information from the mySql table and but it into a HTML table. The problem is , before applying a certain IF statement, the whole data in the mySql table is shown, which is what I want… But after applying that IF statement part of my data simply disappears! (the first raw to be specific) .. So here’s my code that will be efficient for you to diagnose my issue .. If you needed additional pieces just tell me.

First of all, here’s my HTML table BEFORE applying IF statement:

before

And here’s AFTER :

after

Here’s my code WITHOUT IF statement:

<?php
function make_table() {
    $myResult = get_ind_info_fam();
    $ind_field_count = mysql_num_fields($myResult) -1;

            // Table to show ALL individuals info.
            echo "<table>" ;

            // Table Headers:
            for ($i = 2 ; $i <= $ind_field_count ; $i++) {
                    $field_name = mysql_field_name($myResult, $i);
                    $field_name = ucwords($field_name);
                    if ($i ==2) {
                        $field_name = "Individual Name";
                    }
                    echo "<th>{$field_name}</th>";
                }

            // Table Data :
                while ($myData = mysql_fetch_array($myResult)){
                    echo "<tr>";
                    for ($i = 2 ; $i <= $ind_field_count ; $i++) {
                        echo "<td>{$myData[$i]}</td>";
                    }
                    echo "</tr>";
                }
            echo "</table>" ;
  }
 ?>

And the Code WITH the IF statement :

<?php
function make_table() {   
     $myResult = get_ind_info_fam(); 
// Checking if a correct $_GET["fam"] is entered
//  (not out of range) so an empty table won't be shown :

    if (isset($myResult)) {

        if($myData = mysql_fetch_array($myResult)) {
            $ind_field_count = mysql_num_fields($myResult) -1;

            // Table to show ALL individuals info.
            echo "<table>" ;

            // Table Headers:
            for ($i = 2 ; $i <= $ind_field_count ; $i++) {
                    $field_name = mysql_field_name($myResult, $i);
                    $field_name = ucwords($field_name);
                    if ($i ==2) {
                        $field_name = "Individual Name";
                    }
                    echo "<th>{$field_name}</th>";
                }

            // Table Data :
                while ($myData = mysql_fetch_array($myResult)){
                    echo "<tr>";
                    for ($i = 2 ; $i <= $ind_field_count ; $i++) {
                        echo "<td>{$myData[$i]}</td>";
                    }
                    echo "</tr>";
                }
            echo "</table>" ;
        }
    }
   }
?>

And this is my get_ind_info_fam() function:

function get_ind_info_fam()
{
   //****Family name is clicked*****

    //This function gets Family ID from addresse bar
    //and extract individual info according to that ID by $_GET variable
    //
    //NOTE : this function is used in the article to show content of
    //       selected family name.

        if(is_numeric($_GET["fam"])) {
            $query ="SELECT * FROM individual
                        WHERE g_id={$_GET["fam"]}";
            $result = mysql_query($query);
             return $result ;
        }
}

I don’t really know what exactly to tell you to get the full picture but if there is any thing that isn’t clear enough let me know.

  • 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-21T09:42:46+00:00Added an answer on May 21, 2026 at 9:42 am

    You’re fetching your data rows in two places with the if() version:

    if($myData = mysql_fetch_array($myResult)) {
    

    and

    while ($myData = mysql_fetch_array($myResult)){
    

    The first row is thrown away, as you simply output the table header row without every outputting the row data.

    As well, your initial isset() check will not do what you want. mysql_query() will return SOMETHING, regardless of how the query executed. If it fails, you get a boolean FALSE, otherwise you get a result set handle. That means isset() will always succeed, because that value is (big surprise) always set. What you want is:

    $myResult = get_ind_info_fam(); 
    
    if ($myResult === FALSE) {
       die(mysql_error());
    }
    if (mysql_num_rows($myResult) == 0) {
        echo "nothing found";
    } else {
        .... print out the results ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.