php mysql 示例代码

php mysql 示例代码

<?php
$con = mysql_connect("localhost","root","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test", $con);

$result = mysql_query("SELECT * FROM tb");

if (!$result )
  {
  die ("Can\'t use test_db : " . mysql_error());
  }

while($row = mysql_fetch_array($result))

  {
    echo $row['id'];
    echo ' <a href="'.$row['url'].'">'.$row['remark'].' </a>';
    echo "<br />";
  }

mysql_close($con);
?>

你可能感兴趣的:(php mysql 示例代码)