FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!

Show table´s dates with mysqli




The code´s comments will explain this...

Code:

<?php
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
    echo "can´t connect to MySql: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";
///With port:
$mysqli = new mysqli("IP", "user", "password", "database", 3306);
if ($mysqli->connect_errno) {
    echo "can´t connect to MySql: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

$query = "SELECT * from Table_here ORDER BY id LIMIT 5";

if ($result = mysqli_query($link, $query)) {

    /* Obtener la información del campo de cada columna */
    while ($finfo = mysqli_fetch_field($result)) {

        printf("id:     %s\n", $finfo->id);
        printf("field2:      %s\n", $finfo->field2name);
        printf("field3:  %d\n", $finfo->field3name);
    }
    mysqli_free_result($result);
}
?>


the table in the database need to has the name "Table_here", and the 2 fields need to have the names "field2name" and "field3name", of course, you can change this



0 blog comments below




FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.