title: select with join using a standard php function
body: <p>Im trying to use a php function to select data from a database, Im using a "standard" php function:</p>
  
  <pre><code> function select($table, $where, $other=''){
          try{
              $a = array();
              $w = "";
              $other=" ".$other;
              foreach ($where as $key =&gt; $value) {
                  $w .= " and " .$key. " like :".$key;
                  $a[":".$key] = $value;
              }
              $stmt = $this-&gt;bd-&gt;prepare("select * from ".$table." where 1=1 ". $w.$other); 
              $stmt-&gt;execute($a);
              $rows = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
              if(count($rows)&lt;=0){
                  $reponse["statut"] = "warning";
                  $reponse["message"] = "no data found.";
              }else{
                  $reponse["statut"] = "Success";
                  $reponse["message"] = "Success";
              }
                  $reponse["data"] = $rows;
  
          }catch(Exception $e){
              $reponse["statut"] = "Error";
              $reponse["message"] = 'selection failed: ' .$e-&gt;getMessage();
              $reponse["data"] = null;
          }
          return $reponse;
      }
  </code></pre>
  
  <p>The function works satisfyingly I faced problems only when I aimed to use a join and selecting from two tables.
  say we have these two tables:</p>
  
  <hr>
  
  <ul>
  <li><p>id-cat  | cat-name |    </p>
  
  <hr></li>
  <li><p>1       | aaaaaa   | </p></li>
  <li>2       | aaadda   |  </li>
  <li>3       | saaaca   |  </li>
  <li><p>4       | ahhaaa   |</p></li>
  <li><hr></li>
  </ul>
  
  <p>and </p>
  
  <hr>
  
  <ul>
  <li>id-cat  | sub-cat  |</li>
  <li>1       | 2   |</li>
  <li>1       | 3   |</li>
  <li>1       | 4   |</li>
  <li>2       | 3   |</li>
  <li>2       | 4   |
  
  <hr></li>
  </ul>
  
  <p>How to select the a category's subs name with given id-cat using MY FUNCTION ??</p>