PHP script “TOP debtors of the Nika billing system”

Let me give you an example of a PHP script displaying a list of debtors from the Nika ASRM database:

<?php
// database access data
$db_host="192.168.1.1";
$db_user="ixnfo";
$db_password="password";
$db_name = "base";
$table_name = "abon";
 
// connection to the database
mysql_connect($db_host, $db_user, $db_password) or die (mysql_error());
mysql_select_db($db_name) or die (mysql_error());
mysql_query("SET NAMES 'utf8'");
 
// query
$query = 'SELECT * FROM `'.$table_name.'` WHERE `depozit`<0 ORDER BY `depozit` ASC LIMIT 100;';
$sql = mysql_query($query);
 
// process the result
$num_rows = mysql_num_rows($sql);
echo $num_rows.' debtors shown:<br />';
 
// output data
while ($sql_data = mysql_fetch_array($sql)) {
    echo '<table cellpadding="5" cellspacing="3" border="0"><tr><td>';
    echo '<tr><td>'.$sql_data['depozit'].'</td><td>'.$sql_data['id'].'</td><td>'.$sql_data['first_name'].'</td><td>'.$sql_data['second_name'].'</td></tr>';
    echo '</tr></td></table>';
}
?>

See also my article:
Simple page caching

Leave a comment

Leave a Reply