Avance Zone

MySql php Connection

<div id="Avance Zone">
<?php
echo "php started.....";
$sqlConn = mysql_connect('localhost', 'dbuname', 'dbpwd');
//this is comment
//dbuname is the database username
//dbpwd is the database password
if (!$sqlConn)
{
die('Connect error'.mysql_error());
//the error will be displayed if php cannt connet to your database
}
else
{
echo "Connected";
//connected will be displayed once your php connected with mysql
}
//$query = "show databases;";
//select which database you want to edit
$db=mysql_select_db("dbname");
//dbname is the database name
if(!$db)
{
die('mysql select error'.mysql_error());
//if db cannot be connected this shows this message
}
//select the table
$result = mysql_query("select * from R");
$numofrows = mysql_num_rows($result);
echo "No of rows".$numofrows;
echo "<br>";
echo "<table border='1'>
<tr>
<th>FirstName</th>
<th>Lastname</th>
<th>City</th>
<th>Mobile</th>
<th>email</th>
<th>pre_emp</th>
<th>Experience</th>
<th>Qualification</th>
<th>college</th>
<th>skill set</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['first_name'] . "</td>";
echo "<td>" . $row['last_name'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['mobile'] . "</td>";
echo "<td>" . $row['email1'] . "</td>";
echo "<td>" . $row['department'] . "</td>";
echo "<td>" . $row['Experience'] . "</td>";
echo "<td>" . $row['previous_employer'] . "</td>";
echo "<td>" . $row['college'] . "</td>";
echo "<td>" . $row['skillset'] . "</td>";
echo "</tr>";
}
echo "</TABLE>";
mysql_close($sqlConn);
?>
</div>

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Avance Zone