Skip to content

Instantly share code, notes, and snippets.

@stuartelimu
Last active October 3, 2019 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartelimu/817f44e9b54364dd682d2c295f1f750d to your computer and use it in GitHub Desktop.
Save stuartelimu/817f44e9b54364dd682d2c295f1f750d to your computer and use it in GitHub Desktop.
PHP MySQL Revision

connect to the database, CRUD

$con = mysql_connect("localhost","root","");

// select database 
mysql_select_db("database-name");

// perform query 
// insert query
$query = "insert into table-name values(value1, value2,...);

// update query
$query = "update table-name set column-name=value1 where column-name1=value1;

// delete query
$query = "delete from table-name where column-name=value;

// select query
$query = "select * from table-name;

// execute query
$result = mysql_query($query);

echo "<table border=1">;
echo "<tr> <th>column-names</th> </tr>"
while($row = mysql_fetch_array($result)) {
    echo "<tr>";
    echo "<td>$row[column-name]</td>"
    echo "</tr>";
}

echo "</table">;

some notes on how to connect to mysql and perform crud(create,retrieve,update,delete) operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment