Created
December 29, 2010 22:59
-
-
Save ch1ago/759184 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mysql_db = "test"; | |
$mysql_user = "root"; | |
$mysql_pass = "root"; | |
$con = mysql_connect("localhost", $mysql_user, $mysql_pass); | |
mysql_select_db($mysql_db, $con); | |
$create_query = "CREATE TABLE emp_table (emp_id INT NOT NULL AUTO_INCREMENT, | |
emp_name VARCHAR(50), emp_designation VARCHAR(50), PRIMARY KEY (emp_id))"; | |
mysql_query($create_query, $con); | |
echo "Table <b>emp_table</b> Created Successfully!<br>"; | |
$insert = "INSERT INTO emp_table VALUES (1, 'sandeep', 'programmer')"; | |
$insert1 = "INSERT INTO emp_table VALUES (2, 'suman', 'sr. Gr Designer')"; | |
$insert2 = "INSERT INTO emp_table VALUES (3, 'ravi', 's/w developer')"; | |
mysql_query($insert, $con); | |
mysql_query($insert1, $con); | |
mysql_query($insert2, $con); | |
echo "Data inserted successfull<br><br>"; | |
$result = mysql_query("SELECT * FROM emp_table"); | |
echo "<table border='1'> | |
<tr> | |
<th>ID</th> | |
<th>Name</th> | |
<th>Designation</th> | |
</tr>"; | |
while ($row = mysql_fetch_array($result)) { | |
echo "<tr>"; | |
echo "<td>" . $row['emp_id'] . "</td>"; | |
echo "<td>" . $row['emp_name'] . "</td>"; | |
echo "<td>" . $row['emp_designation'] . "</td>"; | |
echo "</tr>"; | |
} | |
echo "</table>"; | |
mysql_close($con); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment