Jump to content

thara

Members
  • Posts

    604
  • Joined

Everything posted by thara

  1. Can you give an example how I use two IF test in a query. Its completely new thing for me.
  2. date_expire column have in two tables (tutors, institutes) tutors.date_expire or institutes.date_expire ?? I need to check both
  3. When running the query it says But I have no idea to fix this reason is date_expires column have in two tables.
  4. I am trying to build a login system. But have a problem when I am creating the query for it. I will briefly explain what I need is. I have got username and password form login form. Now I need to check those values with my login table weather those are exist or not in the table. As well as I need to check users' registration is expired or not in the same query using tutors , institutes and students tables. students registration is not expiring. Further I need to check their profile is activated or not usingactive column in tutors and institutes tables. Again students table doesn't have a column 'active'. They don't need to activate their profile. These are columns which I need to get from query. login_id // From login table username // From login table login_type // From login table date-expire true or false // From tutors or institute or student. I tried it something like this but confusing in how to attach all my tables together in the same query. $q = "SELECT login_id, username, login_type, IF(date_expires >= NOW(), true, false) FROM login INNER JOIN tutors ON login.login_id = tutors.login_id INNER JOIN institutes ON login.login_id = institutes.login_id WHERE (username='$username' AND password='" . get_password_hash($password) . "' AND (tutors.active IS NULL || institutes.active IS NULL))"; But this query is not working. Can anybody tell me what is the mistake I have done? This is my table structure CREATE TABLE login ( login_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(30) NOT NULL, password VARBINARY(32) NOT NULL, login_type ENUM('tutor', 'institute', 'student') NOT NULL, PRIMARY KEY (login_id) ) CREATE TABLE institutes ( institute_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, login_id SMALLINT UNSIGNED NOT NULL, active CHAR(32), date_expires DATE NOT NULL, date_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (institute_id) ) CREATE TABLE tutors ( tutor_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, login_id SMALLINT UNSIGNED NOT NULL, active CHAR(32), date_expires DATE NOT NULL, date_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (tutor_id) ) CREATE TABLE students ( student_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, login_id SMALLINT UNSIGNED NOT NULL, date_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (student_id) )
  5. If I understood your question correctly you need to use mysql DISTINCT. When querying data from a database table, you may get duplicate records. In order to remove duplicate records, you use the DISTINCT keyword along with the SELECT statements. The syntax of the MySQL DISTINCT is as follows: SELECT DISTINCT columns FROM table_name WHERE where_conditions
  6. Nobody will code you here. At first try it by yourself and come again with your code when you stuck. Then you can learn PHP more and errors in your script can make correct through experts in PHP from here.
  7. Congratulations, Christian!
  8. Are you sure your query is correct? I mean your column name and table name (login & db_login). As well as from where the value come to $email?
  9. when you post your code again please place it inside code tag by clicking on the button '<>' in your editor It will help others to read your code easily
  10. I would like to know here anyone use 'Website X5' for creating their websites or anyone use such a third party software to build websites. If so pointed me main advantages and disadvantages of them. Thank you.
  11. Not sure what is your problem here. If it is top margin in your #glavno div remove margin property and its value from CSS... margin: 10px 0px 0px 0px;
  12. If you come back with your PHP code, You will welcome by this forum
  13. have you tried something with PHP? If not I am sure anyone won't help you regarding this.
  14. what have you done so far? Please post your code and then others will help you to fix your problem.
  15. @PFMaBiSmAd.. your solution is ok. but problem is I need to redirect to anther page after form processing submitted data. Like this // If category form from category.php successfully submitted then go to next page (subject.php) $_SESSION['category'] = $_POST['category']; $url = BASE_URI . 'subject.php'; // Define the URL: header("Location: $url"); exit(); // Quit the script. My problem is when I need to go to category.php page from subject.php page clicking on browser's back button its not going and not loading the page. I tried using GET method instead of POST then working but always I cant use GET method. Can I know is there a solution with POST method? Thank you.
  16. $Psycho. can we make this calender without displaying index values?
  17. can you please explain this little with an example? Thank you.
  18. Barand thanks for your help.. My problem is now solved. I am greatly appreciated your help. thanks again.
  19. Barand... This is result with 3 categories with 0 selected subjects.... This is result with 3 categories and 3 selected subjects to one category.. Array ( [select-subjectes] => Array ( [Grade 5 (Scholarship Exam)] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) [catcount] => Array ( [5] => 29 ) [submitted_subjects] => TRUE ) good And this is the result with 3 categories and 3 selected subject in each category. This is the correct way I am expecting.. but get this Array ( [select-subjectes] => Array ( [Grade 5 (Scholarship Exam)] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [Grade 6 - 10] => Array ( [0] => 6 [1] => 7 [2] => 8 ) [Grade 11 (O/L)] => Array ( [0] => 19 [1] => 20 [2] => 21 ) ) [catcount] => Array ( [5] => 29 ) [submitted_subjects] => TRUE ) You have not selected subjects in all categories It seems that this form when submitted... If the category has no subjects selected, it'll not be send this is what making the problem for me.. isn't it?
  20. Array ( [select-subjectes] => Array ( [Grade 5 (Scholarship Exam)] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) [catcount] => Array ( [5] => 5 ) [submitted_subjects] => TRUE ) good I have selected 2 categories and then select 0 subjects for 1st and 2 subjects for 2nd
  21. Its hard to understand actually what has happened there.. Somehow I need to check that condition with my form. Its important. can you explain your last post little.. Thank you..
  22. Barand, then how can I check that condition?
  23. Array ( [select-subjectes] => Array ( [Grade 11 (O/L)] => Array ( [0] => 10 [1] => 11 [2] => 12 [3] => 14 ) ) [catcount] => Array ( [9] => 26 ) [submitted_subjects] => TRUE ) when I selecting subjects for only one category..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.