Login   Register  
PHP Classes
elePHPant
Icontem

File: addnews.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of milootooloo  >  Simple Abstract Table  >  addnews.php  >  Download  
File: addnews.php
Role: Example script
Content type: text/plain
Description: Manipulating exemples
Class: Simple Abstract Table
Store and retrieve objects from MySQL tables
Author: By
Last change:
Date: 2008-11-22 12:25
Size: 720 bytes
 

Contents

Class file image Download
<?php

// This page add an entry in the table news
// When called set_* or get_*, * means the name of the table field
// You have to connect to the mysql base yourself

require_once "news.table.class.php";


$news=new news();
$news->set_title("Hello");
$news->set_content("World!");
$news->save();

//This page can also update a row if the primary key is specified
if(isset($_GET['id'])){
    
$news=new news();
    
$news->set_id(addslashes($_GET['id']));
    
$news->set_title("Hello");
    
$news->set_content("New World!");
    
$news->save();
}

//And delete an entry
if(isset($_GET['id']) && isset($_GET['delete'])){
    
$news=new news();
    
$news->set_id(addslashes($_GET['id']));
    
$news->delete();
}



?>