Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A <em>very</em> simple approach:</p> <pre><code>&lt;?php $action = 'list'; $arrActions = array ('list', 'add', 'update', 'delete'); if(isset($_GET['action']) &amp;&amp; in_array($_GET['action'],$arrActions)) { include('ajax_action_'.$_GET['action'].'.php'); } else { include('ajax_action_list.php'); } ?&gt; </code></pre> <p>With a simple file iike this you can 'route' your requests to other files ahd have those deal with them internally. There is a lot more to consider, but if you're starting out, keep it simple like this and then you'll be able to pick up elements you need specifically for your application in due time.</p> <p><strong>UPDATE</strong></p> <p>An issue was raised about number of files:</p> <p>This might help:</p> <pre><code>&lt;?php include("connection.php"); class controller { private $arrMethods = array('get','list','add','update','delete'); public function __construct() { if(isset($_GET['action'])) { $method = 'do'.ucwords($_GET['action']); // list=&gt;List, add=&gt;Add, etc if(method_exists($method,$this)) { $this-&gt;$method(); } } public function doGet () { $q=(int)(isset($_GET['q']) ? $_GET["q"] : 0); if(0 &lt; (int)$q) { $query="SELECT * FROM `contacts` WHERE `id` = '$q'"; // limit to 1? $result = mysql_query($query); if($result &amp;&amp; mysql_error()=='' &amp;&amp; mysql_num_rows($result) &gt; 0) { while($row = mysql_fetch_array($result)) { echo "Name: " . stripslashes($row['first']) . " &lt;br /&gt;"; echo "Surname: " . stripslashes($row['last']) . " &lt;br /&gt;"; } } mysql_close(); } } public function doList () { } public function doAdd () { } public function doEdit () { } public function doDelete () { } } $objController = new controller(); ?&gt; </code></pre> <p>This now becomes your gateway script with each function separated out.</p> <p>Does this give you a better starting point?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload