html - How to retrieve data from multiple tables using a PHP form? -


i want retrieve data multiple tables using dot operator/join arguments passed html/php form.

html code

<input name="rollno" type="text" placeholder="roll number" required> <input name="submit_view_details" type="submit" value="proceed"> 

php code

if(isset($_post['submit_view_details'])) {     $rollno = (int) $_post['rollno'];     $query = "select * table1, table2 table1.{$rollno}=table2.{$rollno}";     $result=mysqli_query($connection,$query); } 

in browser if enter input 1 , echo query looks follows:
select * table1, table2 table1.1=table2.1

and no row fetched despite of having data in table(s).

it works if query looks follows:
select * table1,table2 table1.rollno=table2.rollno

however, in case fetches rows need row of rollno user entered in above mentioned form.

i not able work out. appreciated. thanks!

use and keyword specify rollno.

select * table1, table2 table1.rollno = table2.rollno  , table1.rollno = {$rollno}; 

you use keyword join instead :

select * table1 natural join table2  rollno = {$rollno}; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -