Forum Moderators: coopster

Message Too Old, No Replies

Get sql query array in specific cells of HTML table

         

vikypaws

9:50 am on Nov 25, 2011 (gmt 0)

10+ Year Member



Hi All,

I need to get data into the table mentioned below.

Test cycle name|P1|P2|P3P4
Pass|||
Fail|||
Block|||
Not Tested|||
Total|| |


<html>
<head>
<title>Get Status</title>
</head>
<body>
<?php

// Disbale eror reporting error_reporting(E_ALL ^ E_NOTICE);

$con = mysql_connect('localhost','test','Test');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("test", $con);

$query = "Select count(TS.status) as STATUS,TS.status as STAT,tcv.priority from TESTCYCLE TC, TESTCASE_VERSION TCV,
TESTCASE_STATUS TS where
TS.status = 'Pass' and
TC.id = TS.testcycle_id and
TCV.testcase_id = TS.testcase_id and
TC.name = 'testcycle1'
group by TCV.priority";

$result1 = mysql_query($query) or die(mysql_error());



if($result1 === FALSE) {
die(mysql_error()); // TODO: better error handling
}

while($row1 = mysql_fetch_array($result1))
{

echo $row1['STATUS']. " - ". $row1['STAT'];
echo "<br />";

}

mysql_close($con);
?>
</body>
</html>


I am aware that the echo part of the code is wrong. That is where I need to amke changes but I am not sure how.Any help would be great.

The output I get form my query:
Count1STATUS priority
226Not Tested 1
138Pass 2
83Fail 3

Thanks,
Vivek

eelixduppy

5:25 pm on Dec 6, 2011 (gmt 0)



Hello and Welcome to WebmasterWorld!

Where are the data for the P1|P2|P3|P4 columns coming from? Are you trying to pivot the tables into 4 columns when outputting?