Note that there are some explanatory texts on larger screens.

plurals
  1. POreading many records for one user id
    primarykey
    data
    text
    <p>I create relation between two tables (login_pre , privilege ) and many accesslevel for one user id they are as follows:</p> <p>privilege table:</p> <pre><code>+----------------------------------+ | AccessLevel | login_id | pre_id| |----------------------------------| | 1 | 1 | 1 | | 2 | 1 | 2 | | 4 | 2 | 4 | +----------------------------------+ </code></pre> <p>and this is login_pre table:</p> <pre><code> +----------------------------------+ | username| userpass | login_id | |----------------------------------| | a | 123 | 1 | | a | 123 | 1 | | b | 1234 | 2 | +----------------------------------+ </code></pre> <p><strong>where admin who add accesslevel</strong> </p> <p>how can I create php code that read right many record for one user id</p> <p>I try this code many times but it output nothing </p> <pre><code> $query ="SELECT * FROM privilege AS privilege.login_id JOIN login_pre AS login_pre.login_id ON privilege.login_id=login_pre.login_id ";//output nothing </code></pre> <p>then I try :</p> <pre><code>$query = "SELECT * FROM privilege where login_id='".$_SESSION['sessionloginid']."' " ; </code></pre> <p>output as follows: </p> <p>in privilege page:</p> <pre><code> if(isset($_SESSION['sessionloginid']))// point to id of user logged in { $query = "SELECT * FROM privilege where login_id='".$_SESSION['sessionloginid']."' " ; $result = mysqli_query($link,$query) or die(''); while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $_SESSION['sessionloginid']= $row['login_id']; //output 11 $_SESSION['sessionaccess']= $row['AccessLevel'];//output 12 } } </code></pre> <p>and protect page:</p> <pre><code>function protect_page() { if($_SESSION['sessionloginid']== true &amp;&amp; $_SESSION['sessionaccess'] !=1 ) { //header ('location:http://localhost/database/agtdatabase/agt_site/agtSite/agt2.php'); //$_SESSION['sessionloginid']; // output 1 echo $_SESSION['sessionaccess'] ;//output 2 only for user loginid = 1 =&gt;the problem exit(); } } protect_page(); </code></pre> <p>side note I wrote this question before and follow answer but it outputs nothing and no reply after that so I write question more clear what I want a code to reading right many records for single user </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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