Select * from two tab;es and display them!

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
gasoga
Forum Commoner
Posts: 36
Joined: Thu Apr 17, 2003 4:15 am
Location: Ireland

Select * from two tab;es and display them!

Post by gasoga »

Hi

I have two tables wich i want display together. The following is the code i am useing to do this:

Code: Select all

$db = odbc_connect($dbsource, $dbuser, $dbpass) or die(odbc_errormsg);
	
	$Q12 = "select * from $dbcall2, $dbcall where $dbcall2.cust_username='$cust_username' and $dbcall2.company_name='$company_name' and $dbcall.cust_username='$cust_username' and $dbcall.company_name='$company_name'"; 
	$result =odbc_exec($db,$Q12)or die(mysql_error());
	
	
	echo("<b>Previous Calls you have logged:</b>");
	echo "<table border='1' align = 'left' CELLSPACING='6' CELLPADDING='6' CLASS='TextField2' WIDTH='300'> \n ";
	echo "<br>";
	
	while(odbc_fetch_row($result))
	&#123;
		
	$Call_ID=odbc_result($result,1);
	//print("<tr>");
	echo "<tr align ='left'><th>Call ID</th>";
	print("<td align ='right'>$Call_ID</td></tr>");
	$company_name=odbc_result($result,2);
	echo "<tr align ='left'><th>Company Name</th>";
	print("<td align ='right' colspan='3'>$company_name</td></tr>");
	$cust_username=odbc_result($result,3);
	echo "<tr align ='left'><th>Customer User Name</th>";
	print("<td align ='right'>$cust_username</td></tr>");
	$date=odbc_result($result,4);
	echo "<tr align ='left'><th>Date</th>";
	print("<td align ='right'>$date</td></tr>");
	$time=odbc_result($result,5);
	echo "<tr align ='left'><th>Time</th>";
	print("<td align ='right'>$time</td></tr>");
	$call_type=odbc_result($result,6);
	echo "<tr align ='left'><th>Call Type</th>";
	print("<td align ='right'>$call_type</td></tr>");
	$description=odbc_result($result,7);
	echo "<tr align ='left'><th>Description</th>";
	print("<td align ='right'>$description</td></tr>");
	$priority=odbc_result($result,8);
	echo "<tr align ='left'><th>Priority</th>";
	print("<td align ='right'>$priority</td></tr>");
	$res_call_imm=odbc_result($result,9);
	echo "<tr align ='left'><th>Where You Able To Resolve Call Immediately</th>";
	print("<td align ='right'>$res_call_imm</td></tr>");
	$solution=odbc_result($result,10);
	echo "<tr align ='left'><th>If 'Yes', what was the solution?</th>";
	print("<td align ='right'>$solution</td></tr>");
	$technician=odbc_result($result,11);
	echo "<tr align ='left'><th>If 'No', Assign a Technician:</th>";
	print("<td align ='right'>$technician</td></tr>");
	$resolved=odbc_result($result,12);
	echo "<tr align ='left'><th>Was that technician able to resolve problem?</th>";
	print("<td align ='right'>$resolved</td></tr>");
	$solution2=odbc_result($result,13);
	echo "<tr align ='left'><th>If 'Yes', what was the solution?</th>";
	print("<td align ='right'>$solution2</td></tr>");
	$call_closed_date=odbc_result($result,14);
	echo "<tr align ='left'><th>Close Call :: Date(YYYY-MM-DD)</th>";
	print("<td align ='right'>$call_closed_date</td></tr>");
	print("</tr>");


	&#125;
	echo "</table>\n";
	echo("<br>");
The problem is that is is only taking the information from the first table and displaying it. Any ideas on why this is happening, could possibly be to do with my select statement, would be much appreciated!!!
:)
saleemkhan
Forum Newbie
Posts: 4
Joined: Tue May 06, 2003 6:32 am

Post by saleemkhan »

try this,

$db = odbc_connect($dbsource, $dbuser, $dbpass, SQL_CUR_USE_ODBC) or die(odbc_errormsg);
Post Reply