Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can i put a column of results into an array and compare then with another column with PHP?
    primarykey
    data
    text
    <p>My system is base on driving permit application. Where users can apply for different level of permit, for example if user want to apply for class 5 permit, they must have pre requisites of class 2 and 3.</p> <p>In my database, i have 2 related tables, 1 is the permit where it stores all the permit that users have applied for or is waiting for approval. The other table is the description of the permit type where it indicates each available permit that users can apply for together with its pre-requisites and description.</p> <p>permit ( PID,EID, PTYPE,STATUS,DATETIMEAPP)</p> <p>type (TYID,PTYPE, PREREQ1, PREREQ2, REQEXP, DES)</p> <p>My plan is to retrieve data from the database</p> <pre><code>$query= "select PTYPE from permit where eid = $user" $result = mysql_query($query, $conn); </code></pre> <p>Store the result as an array</p> <pre><code>while ($row = mysql_fetch_assoc($result)) { $result_array[] = $row; } </code></pre> <p>retrieve the pre requites from the type table</p> <pre><code>$query= "select PREREQ1 , PREREQ2 from type where TYID = $appliedPermit" $result = mysql_query($query, $conn); </code></pre> <p>Compare the 2 results together with a boolean ( I not sure how can i code this)</p> <p>If result is true then proceed else return to previous page with a pop up to inform user that they have not met pre-requisites. ( i know i need the if else statement but not sure how to write the condition)</p> <p>Do you guys think that i am on the right path?? I am not sure if it will work...but hope any one here have a better suggestion.</p> <p>Restructure a little:</p> <p>My system aims to allow users to apply for driving permit...there are a total of 9 permits -Class 1, Class 2, Class 3. Cat 2PG, Cat 3PG, Car4PG, Cat 1OR, Cat 2OR, Cat 3OR, Cat 2TT and Cat 3TT. For example Cat 3TT require users to have Cat 2TT and Cat 2PG. in another words, the pre-requisites of Cat 3TT is Cat 2TT and Cat 2PG.</p> <p>I would like to use PHP to draw all the required values from the database and compare them to see if the user have met the pre-requsites before allowing him to proceed to the medical questionnaire if he haven got 1.</p> <p>The Problem is: I do not know how to code it out logically, I tried but it did not work. Hoping to get more opinions and solutions to my problem. Thank You very much. Help is greatly appreciated.</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.
 

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