Jump to content

How can I join these two html tables together?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
system32

system32

    Newbie

  • Members
  • PipPip
  • 24 posts
I want to create a compare sort of page. I currently have two tables with the information, but want it to be on table or join both together. The first row would show Name of brand, second would show cost, etc... I am grabbing the values of selected checkboxs and based on what they selected it get compared.


$testName = $_POST['testCompare'];
$rpl = str_replace("_", " ", $testName);
$firstOne = "$rpl[0]";
$secondOne = "$rpl[1]";
	echo "$firstOne";
	echo "<br/>";
	echo "$secondOne";


	$query = "SELECT * FROM test_table WHERE test_name = '$firstOne'";
	$query2 = "SELECT * FROM test_table WHERE test_name = '$secondOne'";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
	$result2 = mysql_query($query2) or die ("Error in query: $query2. " . mysql_error());


	if (mysql_num_rows($result) > 0 && mysql_num_rows($result2) > 0) {
	
	//if (mysql_num_rows($result) > 0) {
		
		while($row = mysql_fetch_row($result)) {			
			if ($firstOne == $row[1]) {
			{
				echo "<table border=1>";			
				echo "<tr>";
				echo "<td>" . $row[0] . "</td>";
				echo "<tr>";
				echo "<td>" . $row[1] . "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>" . $row[2] . "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>" . $row[3] . "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>" . $row[4] . "</td>";
				echo "</tr>";
				}
			}
			}echo "</table>";


		while($row2 = mysql_fetch_row($result2)) {			
			if ($secondOne == $row2[1]) {
			{	echo "<table border=1>";		
				echo "<tr>";
				echo "<td>" . $row2[0] . "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>" . $row2[1] . "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>" . $row2[2] . "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>" . $row2[3] . "</td>";
				echo "</tr>";
				echo "<td>" . $row2[4] . "</td>";
				echo "</tr>";
				}
			}
			}
			echo "</table>";
		}
	 else {
			echo "No Results";
		}


Thanks

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Get rid of the first </table> and the second <table boarder=1>
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users