A simple PHP database connection script to start-up


<?php
$host = “localhost”; //database location
$user = “s”; //database username
$pass = “s”; //database password
$db_name = “sw”; //database name

//database connection
$link = mysql_connect($host, $user, $pass);
mysql_select_db($db_name);

$sqlstr = mysql_query(“SELECT * FROM a”);
if (mysql_numrows($sqlstr) != 0) {
while ($row = mysql_fetch_array($sqlstr)) {
?>
<p><?= $row[‘name’] ?></p>
<p><?= $row[‘userid’] ?></p>
<p><?= $row[‘id’] ?></p>
<?php
}
}
?>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s