Jump to content

Relations... Query


cyrixware

Recommended Posts

Both query are correct. i was wondering how to integrate this one this is my old query:

 

<?php

$q = "SELECT student.*, studentgrade.* FROM student, studentgrade 
					WHERE student.SuID = studentgrade.SuID ORDER BY SuGrade DESC ";

$r = mysql_query($q) or die(mysql_error()."<Br /><Br / >".$q);
if(mysql_num_rows($r) >0)
{
	$i = 0;
                ........................
?>

 

Let say i want to create a relationship between two tables and heres the new one. The problem is how to integrate or add new tables in this line of codes? (table student and studentgrade)

 

<?php
$q = "SELECT SuGrade, SuID FROM studentgrade ORDER BY SuGrade DESC";
// i just want to include the tbl student here and the primary key is the SuID//
?>

 

;)

Link to comment
https://forums.phpfreaks.com/topic/93516-relations-query/
Share on other sites

Here is the actual code:

 

<?php
$q = "SELECT SuGrade, SuID FROM studentgrade ORDER BY SuGrade DESC";
// so let say in this line i want to included the tbl student with a primary key SuID//
$r = mysql_query($q) or die(mysql_error()."<Br /><Br / >".$q);
if(mysql_num_rows($r) >0){
$i = 0;
echo "<table><tr><td>User</td><td>Score</td><td>Rank</td></tr>";
while($row = mysql_fetch_assoc($r))
{
	if($row['SuGrade'] != $score)
	{
		$i++;
	}
		echo "<tr><td>".$row['SuID']."</td><td>".$row['SuGrade']."</td><td>".$i."</td></tr>";
		$score =$row['SuGrade'];
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/93516-relations-query/#findComment-479125
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.