23.08.2014, 13:19
Код:
<?php $con = new mysqli("localhost", "mysql_user", "mysql_password"); if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } if($result = mysqli_query($con, "SELECT id, name FROM mytable")) { while ($row = mysqli_fetch_assoc($result)) { printf ("ID: %s Name: %s", $row["id"], $row["name"]); } mysqli_free_result($result); } mysqli_close($con); ?>