tablesorter icon indicating copy to clipboard operation
tablesorter copied to clipboard

Ask info for Pager plugin - Ajax

Open ieraora opened this issue 6 years ago • 1 comments

I'm sorry, I don't know very well Java. From this demo I tried to create the table connected with mysql. But where I put the data that I've selected?

With php I had create array (as scheme) with json_encode and save in a php file, but is correct this? And how I "import" this file because tablesorter see this?

I hope I was clear. Thank You.

my file.php is this

  <?php 
$hostname = "localhost";
$username = "root";
$password = "password";
$dbname = "database";

try {
    $dbh = new PDO("mysql:host=$hostname;dbname=generaphoto", $username, $password);

    $query = "select cf_id, allegato, p_description, p_lotto, p_cu FROM `xijhd_cf_product_data-2`";

    $stmt = $dbh->prepare($query);
    $stmt->execute();

    $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $values = array();

for($row = 0; $row < count($result); $row++)
    {
        $values[] = array('ID' => $result[$row]['cf_id'], 'Name' => $result[$row]['p_lotto'],
        'Country Code' => $result[$row]['allegato'],'District' => $result[$row]['p_description'],'Population' => $result[$row]['p_cu'],);
    }


    $to_encode = array('total_rows' => count($result), 
                        'cols' => ['ID', 'Name', 'Country Code', 'District', 'Population'],
                        'rows' => $values);
    echo json_encode($to_encode);

} catch (PDOException $e) {
    echo $e->getMessage();
}

?>

ieraora avatar Jan 18 '20 19:01 ieraora

Hi @ieraora!

Sorry, for the delay. I'm not that good with php. You might get better advice from Stack Overflow.

Mottie avatar Mar 03 '20 11:03 Mottie