• Resolved eagleonemedia

    (@eagleonemedia)


    Good afternoon!

    Please could you kindly help me with this? I am trying to fetch an Array from a php file and when I run it in the console the format is the same as the example. But the plugin returns no rows found which is odd,

    Do I have something wrong? I have linked the PHP file in links and the code below. Thank you in advance.

     $dbconn = pg_connect("host=$dbhost dbname=$dbname user=$dbuser password=$dbpass")
    
            or die('Could not connect: ' . pg_last_error());
    
        $query = 'SELECT statistics.player_ucid, players.name, SUM (kills) AS total, SUM (kills_planes) AS A2A, SUM (kills_ground) AS A2G, SUM (deaths) AS losses
    
            FROM STATISTICS
    
            INNER JOIN players on statistics.player_ucid = players.ucid
    
            GROUP BY player_ucid, players.name
    
            ORDER BY total DESC';  
    
        $result = pg_query($query) or die('Error message: ' . pg_last_error());
    
        $return_array = array(); // Initializing the array that will be used for the table
    
        
    
        while ($row = pg_fetch_assoc($result)){
    
            $return_array[] = array('UCID' => $row[player_ucid],'NAME' => $row[name]);
    
        }
    
        echo serialize( $return_array );
    
        print_r($return_array)
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter eagleonemedia

    (@eagleonemedia)

    The exact error – Table in data source has no rows.

    Plugin Author wpDataTables

    (@wpdatatables)

    Hello,
    When we try using your PHP code and placing it on a PHP file on our Server, we are also getting the same error if we try to create a PHP Table : Table in data source has no rows.

    But if we try with our own PHP array sample file, then we can not get any errors.

    What you can do now to troubleshoot is, first  try our sample PHP test file,  and try to make a PHP Array table from it on your WordPress.

    Here is the link to our PHP test file :https://wpdatatables.com/sample_files/show_documentation.php

    This PHP file works on our?Test site for the Lite wpDataTables.
    Here is a screenshot :

    If this works on your site when you make a new PHP Table,

     it means that the issue you have is not coming from our plugin,

    but it is either a server issue or an issue with the file itself.

    If it turns out that the issue is not coming from our plugin, but rather  file/server/permission issue, or the way how you formatted your file,

    unfortunately, our support does not cover searching for errors in your file, or fixing server/permission issues.

    The correct format for our Plugin of the serialized array should be the following: 2D-array, where the parent level is an indexed array, and the second level is an associative array. Parent array entries will be parsed as rows, child array keys will be parsed as column headers, and child array values as cell values.

    ?Please check more details explained on our Documentation here.?

    And you can also examine how we formatted it on our Test file, then try to edit your PHP file in order to get the right format for our Plugin.

    We hope this helps.

    Kind regards.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘No rows found’ is closed to new replies.