Here are 2 queries that do the same thing. Is there any advantange or disadvantage to each method?
Here is the one I like...
<?
mysql_pconnect("localhost", "username", "password");
mysql_selectdb("new_db");
$result = mysql_query("SELECT * FROM code_snippet");
while($r=mysql_fetch_array($result))
{
$snippetid=$r["snippetid"];
$snippet=$r["snippet"];
echo "<a href='details.php?id=$snippetid'>$snippet</a><br>";
}
?>
Any another way...
<?php
$user="username";
$host="localhost";
$password="password";
$database="new_db";
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
$query = "SELECT * FROM code_snippet";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
echo "<a href='details.php?id=" . $row["snippetid"] ."'>" . $row["snippet"] . "</a><br>\n";
}
?>