This is my code

<?php
$ebits = ini_get('error_reporting');
error_reporting($ebits ^ E_NOTICE);

mysql_connect("localhost","root","") or die(mysql_error());
echo"Connected to MySQL<br /><hr/>";
mysql_select_db("college") or die(mysql_error());
echo "Connected to database<br /><hr />";

$query = "select student.Rollno, departments.Dept_name, student.Name, student.PercentsgeSoFar from student inner join(departments 
inner join studentdept on studentdept.Dept_id = departments.Dept_id)on student.Rollno = studentdept.Rollno ";

$result =  mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo $row['Rollno']. "  " . $row['Dept_name ']."     ". $row['Name']."     ". $row['PercentageSoFar'];
echo "<br />";
}
?>

The result is :
376 Ankita
789 Arushi
567 Shubham
456 Goldie

Its not showing the other parameters like Dept_name Percentageso far.
Please help, WHAT SHOULD I DO?

$query = "select student.Rollno, departments.Dept_name, student.Name, student.PercentsgeSoFar from student inner join(departments
inner join studentdept on studentdept.Dept_id = departments.Dept_id)on student.Rollno = studentdept.Rollno ";

in the above query use alias names like as shown below:

$query = "select student.Rollno rollno, departments.Dept_name deptname, student.Name sname, student.PercentsgeSoFar percent from student inner join(departments
inner join studentdept on studentdept.Dept_id = departments.Dept_id)on student.Rollno = studentdept.Rollno ";

the print like this:

echo $row['rollno']. "  " . $row['deptname']."     ". $row['sname']."     ". $row['PercentageSoFar'];

What if I want the result in this form:


Rollno Dept_name SName Percentage


as in rollno under heading Rollno Department name under the heading Dept_name and so on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.