Mysqli connet and queries

http://stackoverflow.com/questions/15251095/display-data-from-sql-database-into-php-html-table 
 Mysqi connect
===================
$db_host = 'localhost';
$db_user = 'root';
$db_password = '';
$db_name = 'dbname';
$mysqli = new mysqli($db_host, $db_user, $db_password, $db_name);

// Insert and Update
=====================
if(!empty($_POST['id'])){
    $query = "UPDATE siteinfo SET site_name = '".$_POST['site_name']."', site_url = '".$_POST['site_url']."' WHERE id=".$_POST['id'];
}else{
    $query = "INSERT INTO siteinfo SET site_name = '" . $_POST['site_name'] . "', site_url = '" . $_POST['site_url'] . "' ";
}
$mysqli->query($query);

// fetch result
==============================
if ($result = $mysqli->query("SELECT * FROM siteinfo"))
{
    while($row = $result->fetch_array(MYSQLI_NUM))
    {
        echo '<pre>';
        print_r($row);
        echo '</pre>';
    }
}

Mysql connect and fetch data
==========================
<?php
$dbname 
'mysql_dbname';

if (!
mysql_connect('mysql_host''mysql_user''mysql_password')) {
    echo 
'Could not connect to mysql';
    exit;
}
$sql "SHOW TABLES FROM $dbname";$result mysql_query($sql);

if (!
$result) {
    echo 
"DB Error, could not list tables\n";
    echo 
'MySQL Error: ' mysql_error();
    exit;
}

while (
$row mysql_fetch_row($result)) {
    echo 
"Table: {$row[0]}\n";
}
mysql_free_result($result);?>