Jump to content

Recommended Posts

I am having some major trouble comparing information from 2 tables. I am attempting to verify the information in similar columns, so that I can come up with a number.  The columns are setup as varchar(30).

 

The basic idea of the program is to obtain the Qualifying results for a race, and then add them to the table with Race results. Any help would be great.

 

Thanks

 

 

Trouble code

 

$result1 = mysql_query("SELECT * FROM QT WHERE DATE = '2007-08-28' ORDER BY Min, Sec, Hun"); 

echo '<tr>';
echo '<td>';
echo $Posr;
echo '</td>';



while ($row1 = @mysql_fetch_row($result1)){

$GT1 = $row["GT"];
$GT2 = $row1["GT"];

IF ($GT1 != $GT2){
	$Store + 1;
}
ELSE IF ($GT1 == $GT2){
	$SPos = ($Store + 1);
}
}

 

Added to working code.

 

//Query that is being run

$result = mysql_query("SELECT * FROM Race WHERE Date = '2007-08-28' ORDER BY THou, TMin, TSec, THun"); 

//this is a line break before the spit output

echo '<table border="1">';
echo '<tr>';
echo '<th>Fn</th>';
echo '<th>St</th>';
echo '<th>Driver</th>';
echo '<th>Car</th>';
echo '<th>Points</th>';
echo '<th>Purse</th>';
echo '<th>Laps</th>';
echo '<th>Race Time</th>';
echo '<th>Fastest Lap</th>';
echo '</tr>';

$Points = 35;
$Posr = 1;
$Purse = 15000;
$SPos = 0;
$Store = 0;

while ($row = @mysql_fetch_array($result))
{
if ($Points > 20)
{

//Query2 that is being run

$result1 = mysql_query("SELECT * FROM QT WHERE DATE = '2007-08-28' ORDER BY Min, Sec, Hun"); 

echo '<tr>';
echo '<td>';
echo $Posr;
echo '</td>';



while ($row1 = @mysql_fetch_row($result1)){

$GT1 = $row["GT"];
$GT2 = $row1["GT"];

IF ($GT1 != $GT2){
	$Store + 1;
}
ELSE IF ($GT1 == $GT2){
	$SPos = ($Store + 1);
}
}

echo '<td>';
echo $SPos;
echo '</td>';
echo '<td>'.$row["GT"].'</td>';
echo '<td>#'.$row["Car"].'</td>';
echo '<td>';
echo $Points;
echo '</td>';
echo '<td>';
echo $Purse;
echo '</td>';
echo '<td>'.$row["Laps"].'</td>';
echo '<td>'.$row["THou"].':'.$row["TMin"].':'.$row["TSec"].'.'.$row["THun"].'</td>';
echo '<td>'.$row["LMin"].':'.$row["LSec"].'.'.$row["LHun"].'</td>';
echo '</tr>';

$Points = ($Points - 3);
$Posr++;
$Purse = ($Purse - 250);
$SPos = 0;
}

 

Link to comment
https://forums.phpfreaks.com/topic/67092-comparing-results-from-two-tables/
Share on other sites

here is a link to the current php

 

http://www.onlinemotorsportsclub.com/league/test4.php

 

As you can see everything is there and can be pulled from Table Race, but I want the Qualifying position to show as ST.  But no matter what I do it either returns 0 or the full row count 19. 

 

The problem is I need to accumulate the row count from QT until it reaches the current GT return from Race. Does that make any since?  The idea behind this is to have two tables with the same column data to verify with.

 

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.