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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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