Please what are the default numbers of php pages need to be created for database relation in managing a dynamic website? Eg: admin.php, delete.php etc

Recommended Answers

All 8 Replies

All depends on the structure of your file and your logical of programming. Personaly, the basic are 4 pages (index.php, base.php is for connexion class, derive.php & param.inc.php)
index.php

require('*.php');
  require('*.php');
  include_once('*.inc.php');

  $mysqli = new mysqli(MYHOST, MYUSER, MYPASS, BASE);
  $objDerive = new Derive(***);

  $objDerive->X(***);

base.php

class Base
  {
      /* DECLARATION DES METHODES */
       public function connex()
      {
          /* STYLE ORIENTE OBJET */
          if (mysqli_connect_errno()) {
              printf("Échec de la connexion : %s\n", mysqli_connect_error());
              exit();
          }
      }
  }//Fin de Classe

derive.php

require_once('clsbase.php');

  class Derive extends Base
  {
      //DECLARATION DES DATAS MEMBRES
      protected $1;
      protected $2;

      //DECLARATION DES METHODES
      function __construct() //ctor.
      {
      }

      public function add()
      {
         ***
      }

      public function update()
      {
         ***
      }

      public function del()
      {
        ***
      }
  }//FIN Cls.

param.inc.php

define("MYHOST","localhost");
  define("BASE","*");
  define("MYUSER","*");
  define("MYPASS","*");

@homeboy: why build a connection class for mysqli, as it already is a class?

Actualy, I use the class Base is for connexion testing.

Although I do not understand why, I still wonder why you are creating classes, but use the procedural version of mysqli... makes no sense to me. It's probably me... I'll drop it, too off-topic.

Pritaeas, I use the object-oriented version of MySQLi. I also wrap my connection to MySQL within my own Database class. It gives me the freedom to do some things I need to do everytime a query is executed, such as determine which database server the query should be sent to.

@Dani: Yes, I understand why you would want to do that (because it makes sense to encapsulate the class). But that's not what homeboy's doing.

Oops! My mistake. I didn't check what I wrote in my code. What I would like to say is: I usally use class Base for connexion to Server. In this case class Base is useless.

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.