The Art of Listening

March 4, 2009

tangly basic functions #1

Filed under: My Experiences

function connect()
{
    global $con;
    $dbname="";
    $con=mysql_connect("localhost","root","");
    if(!$con)
    {
        echo"Not connected to database!";
    }
    mysql_select_db($dbname);
}

function add()
{
    if(isset($_POST["id"]))
    {
        $sql="INSERT INTO $table() VALUES() WHERE id=’".$_POST["id"]."’";
        mysql_query($sql) or die(mysql_error());
    }
}

function delete()
{
    if(isset($_GET["act"])&& $_GET["act"]==’delete’)
    {
        $sql="DELETE $table WHERE id=’".$_GET["id"]."’";
        mysql_query($sql) or die(mysql_error());
    }
}
function edit()
{
    if(isset($_GET["act"])&& $_GET["act"]==’edit’)
    {
        $sql="UPDATE $table
            SET $field=’".$_POST[""]."’
            WHERE id=’".$id."’";
        mysql_query($sql) or die(mysql_error());
    }
}






















Get free blog up and running in minutes with Blogsome
Theme designed by Minz Meyer