Hi guys! Im kinda new here and lately I'm developing a PHP MySQL Module Generator that will help us to easily manipulate the database. since I want to make thing fast and I know lots of you agree with me that doing data manipulation stuffs like MySQL is boring so I decided to create this one and I just want it to share with you guys :)

Please tell me what you think. Im open for constructive criticism and the only purpose of this Generator is to help us programmers. Thank you! :D


Here's the URL: http://easycode.unoprojects.com/index.html

PHP and MySQL Module Maker


This tool help Developers to create PHP and MySQL functions in a table such as adding, editing, deleting, viewing and viewing table data by search as easy as 1 , 2, 3! as said, this tool will create those functions effieciently!

How to use: It's simple. just fill up the forms and click submit. :D
example script:
Tablename: personinfo
Primarykey: ID * NOTE: MUST BE AUTO INCREMENT!!!
Colums: Name, Age, Gender, Address

include("connect.php"); //this is where the connection parameters.
include("inc.sqlcmd.php"); //this is the module
$data = new personinfo(); //create a new object

$data->Name = "Ms.Moo"; //set the variables
$data->Age = "15";
$data->Gender = "Mooo";
$data->Address = "USAA";
$data->add(); //add the data to your DB
$data->first(); //go to the first recordset
$data->Name = "MooGeek Talay";

$data->update(); //Update the first row
$data->last(); //go to the last recordset
$data->delete(); //deletes the last row
print_r($data); //prints the data

This is the inc.sqlcmd.php. And also an example code that is generated by the Page

class personinfo
{
  public $ID;
  
  
  public $Name; 
  public $Age; 
  public $Gender; 
  public $Address;

public function __construct()
{
$this->first();
}

public function add()
{
mysql_query("INSERT INTO personinfo (Name,Age,Gender,Address)
VALUES ('$this->Name','$this->Age','$this->Gender','$this->Address')") or die(mysql_error());  
}

public function update()
{
mysql_query("
UPDATE personinfo
SET Name = '$this->Name',Age = '$this->Age',Gender = '$this->Gender',Address = '$this->Address'
WHERE ID = '$this->ID'
 ") or die(mysql_error());  
}

  public function delete()
  {
mysql_query("DELETE FROM personinfo WHERE ID='$this->ID'") 
or die(mysql_error());  
   }
   public function next()
   {
   $ID++;
  $this->view($this->PrimaryKey); 
 
   }
   
  public function previous()
   {
   $this->ID--;
  $this->view($this->ID); 
 
   }
             
   public function first()
    {
   
     $result = mysql_query(" SELECT * FROM personinfo ORDER BY ID LIMIT 1");
     
     $row = mysql_fetch_array($result) or die(mysql_error());  
     
          $this->ID = $row["ID"];
           
     $this->view($this->ID); 

      }
      
      public function last()
   {                                      
     $this->ID = $this->gettotalrows();
  
  $this->view($this->ID); 
 
   }
        
  public function gettotalrows()
  {
  $query = mysql_query("SELECT * FROM personinfo"); 
  $total = mysql_num_rows($query);
  return $total;
  }           
public function view($ID)
{

if($this->gettotalrows() > 0)
{
$result = mysql_query("SELECT * FROM personinfo WHERE ID = '$this->ID' ");
  
$row = mysql_fetch_array($result) or die(mysql_error());  
 
 
 $this->Name = $row["Name"];
 $this->Age = $row["Age"];
 $this->Gender = $row["Gender"];
 $this->Address = $row["Address"];
          }
   }

  }

Problem? Comments or Suggetion? Please let us know immedietly!

Its what every good developer should have in his tool box created by themselves and every competent should have in a framework.

It's hard to see without seeing your class.

class example? I see. I'm gonna put an example then. Thank you :)

O_O I Forgot to put the URL LOL

Its what every good developer should have in his tool box created by themselves and every competent should have in a framework.

It's hard to see without seeing your class.

I'm sorry I forgot to put the URL T____T

http://easycode.unoprojects.com/index.html

I suggest you change your gettotalrows function to:

SELECT COUNT(*) AS count FROM personinfo

and return that result. There is no need for generating all those rows if you do nothing with them.

Also, your previous and next functions may point to an ID that is no longer available.

Your last function should be like your first function, except use ORDER BY id DESC.

I suggest you change your gettotalrows function to:

SELECT COUNT(*) AS count FROM personinfo

and return that result. There is no need for generating all those rows if you do nothing with them.

Also, your previous and next functions may point to an ID that is no longer available.

Your last function should be like your first function, except use ORDER BY id DESC.

WOW! Thank you for the tips. I'd really appreciate it :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.