Ivan007 Posted February 4, 2023 Share Posted February 4, 2023 Quote $stmt = $pdo->query("SELECT tblseeker.First_Name,tblseeker.Last_Name, tblseeker.Phone_No,tblseeker.Tel_No,Email,Address, tblqualification.Qualification_type,tbllocation.District,Job_Preference, tbljobcategory.Category,tblcontracttype.Contract_type,Seeker_pic,status_id from tblseeker INNER JOIN tblqualification on tblseeker.qualification_id=tblqualification.Qualifi_id INNER join tbllocation on tblseeker.State=tbllocation.Location_ID INNER JOIN tbljobcategory on tblseeker.category_id= tbljobcategory.category_id INNER JOIN tblcontracttype on tblseeker.contract_id =tblcontracttype.contract_id where tblseeker.First_Name='$txtfname' or tblseeker.Last_Name='$txtlname' or tblseeker.Phone_No='$txtpnum' or tblseeker.Tel_No='$txttel'or tblqualification.Qualification_type='$txtquali' or tbllocation.District='$txtlocation' or tbljobcategory.Category='$txtcategory' or tblcontracttype.Contract_type='$txtcontract';"); //here the data output when I used var dump while($rows = $stmt->fetch(PDO::FETCH_ASSOC)){ //at this point nothing is output echo ("<tr>"); echo "<td>". htmlentities($rows['First_Name']) ."</td>"; echo "<td>". htmlentities($rows['Last_Name']) ."</td>"; echo "<td>". htmlentities($rows['Phone_No']) ."</td>"; echo "<td>". htmlentities($rows['Tel_No']) ."</td>"; echo "<td>". htmlentities($rows['Email']) ."</td>"; echo "<td>". htmlentities($rows['Address']) ."</td>"; echo "<td>". htmlentities($rows['District']) ."</td>"; echo "<td>". htmlentities($rows['Job_Preference']) ."</td>"; echo "<td>". htmlentities($rows['Qualification_type']) ."</td>"; echo "<td>". htmlentities($rows['Category']) ."</td>"; echo "<td>". htmlentities($rows['Contract_type']) ."</td>"; Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/ Share on other sites More sharing options...
Barand Posted February 4, 2023 Share Posted February 4, 2023 And the problem is what, exactly? Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605371 Share on other sites More sharing options...
mac_gyver Posted February 4, 2023 Share Posted February 4, 2023 16 minutes ago, Ivan007 said: //here the data output when I used var dump what exactly did you use var_dump() on and what output did it produce? Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605372 Share on other sites More sharing options...
Ivan007 Posted February 4, 2023 Author Share Posted February 4, 2023 when I var_dump($stmt) I got the right result but nothing is output at this stage while($rows = $stmt->fetch(PDO::FETCH_ASSOC)){ //at this point nothing is output echo ("<tr>"); echo "<td>". htmlentities($rows['First_Name']) ."</td>"; echo "<td>". htmlentities($rows['Last_Name']) ."</td>"; echo "<td>". htmlentities($rows['Phone_No']) ."</td>"; echo "<td>". htmlentities($rows['Tel_No']) ."</td>"; echo "<td>". htmlentities($rows['Email']) ."</td>"; echo "<td>". htmlentities($rows['Address']) ."</td>"; echo "<td>". htmlentities($rows['District']) ."</td>"; echo "<td>". htmlentities($rows['Job_Preference']) ."</td>"; echo "<td>". htmlentities($rows['Qualification_type']) ."</td>"; echo "<td>". htmlentities($rows['Category']) ."</td>"; echo "<td>". htmlentities($rows['Contract_type']) ."</td>"; Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605373 Share on other sites More sharing options...
Barand Posted February 4, 2023 Share Posted February 4, 2023 Have you checked your data and input variable values? Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605374 Share on other sites More sharing options...
mac_gyver Posted February 4, 2023 Share Posted February 4, 2023 41 minutes ago, Ivan007 said: when I var_dump($stmt) I got the right result but nothing is output at this stage and what is the right result? if it displayed the sql query string, and not a false or null value, all that means is that the query didn't fail with an error. it doesn't mean that the query matched any rows of data. Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605375 Share on other sites More sharing options...
Ivan007 Posted February 4, 2023 Author Share Posted February 4, 2023 object(PDOStatement)#6 (1) { ["queryString"]=> string(1422) "SELECT tblseeker.First_Name,tblseeker.Last_Name, tblseeker.Phone_No,tblseeker.Tel_No,Email,Address, tblqualification.Qualification_type,tbllocation.District,Job_Preference, tbljobcategory.Category,tblcontracttype.Contract_type,Seeker_pic,status_id from tblseeker INNER JOIN tblqualification on tblseeker.qualification_id=tblqualification.Qualifi_id INNER join tbllocation on tblseeker.State=tbllocation.Location_ID INNER JOIN tbljobcategory on tblseeker.category_id= tbljobcategory.category_id INNER JOIN tblcontracttype on tblseeker.contract_id =tblcontracttype.contract_id where tblseeker.First_Name='ivan' or tblseeker.Last_Name='' or tblseeker.Phone_No='' or tblseeker.Tel_No=''or tblqualification.Qualification_type='Choose...' or tbllocation.District='Choose...' or tbljobcategory.Category='Choose...' or tblcontracttype.Contract_type='Choose...';" } I got this value when using var_dump($stmt) Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605376 Share on other sites More sharing options...
ginerjm Posted February 4, 2023 Share Posted February 4, 2023 (edited) A var dump of the object simply shows you the query, no results. Are you checking for how many rows were returned? PS - when you write a query you can use an alias for the table name such as just a 't' instead of the whole table name. Saves an awful lot of typing. Ex. $q = select t.field1, t.field2, t.field3 from tablename t where t.id='abc'"; Edited February 4, 2023 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605377 Share on other sites More sharing options...
ginerjm Posted February 4, 2023 Share Posted February 4, 2023 BTW - do you really expect your database values to contain html code in them? Like will someone's last name have something other than a legitimate name value in it? Or a phone number? or a contract type? Those values should have been validate before being saved so as to guarantee that they were valid values. A contract type should have been checked against a lookup table that contains all of the valid types so that you know that your database is accurate. I really don't see how any of your table elements would have any html code in them if you did all of the checking during the save process. Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605381 Share on other sites More sharing options...
Barand Posted February 4, 2023 Share Posted February 4, 2023 Apparently hasn't yet learned how to use option value attributes within <select> inputs. Quote Link to comment https://forums.phpfreaks.com/topic/315878-inner-join-is-not-displaying-in-php/#findComment-1605382 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.