Re: [PHP-DB] printing an array

2002-10-24 Thread Ignatius Reilly
Hi,

usually, one issues an HTML row for each row of the query result.
BTW, don't forget TR elements!

But your query results has only one row, and your table has 4 columns.

Can you explain in more detail what you want to do?

Ignatius

- Original Message -
From: Chris Grigor [EMAIL PROTECTED]
To: PHP Gen [EMAIL PROTECTED]
Cc: PHP DB [EMAIL PROTECTED]
Sent: Thursday, October 24, 2002 10:07 AM
Subject: [PHP-DB] printing an array


 Hey there all


 Im sure that someone out there can answer this question..

 I have a problem, how can I print each element in an array so that is
 returned into a table?


 eg
 table width=100%
 th width=25% nowrap
 Test1
 /th
 th width=25% nowrap
 Test2
 /th
 th width=25% nowrap
 Test3
 /th
 th width=25%
 Test4
 /th

 ?php
 include(common.inc);
 $link_id = mysql_connect($dbhost, $username, $password)
 or die (Connection Failed);

 mysql_select_db($db);
 $query = select Routine_Tests_Count from CDT_Routine_Tests where Ref_num
=
 '$ref_num'
 order by Routine_Tests_Link;

 $result = mysql_query($query, $link_id)
 or die (Query on $dbhost failed);

 while ($row = mysql_fetch_object($result)) {
 print td$row-CDT_Routine_Count/td;---
(This
 value holds the Results of test1 test 2 etc
 that I need to print into the table)
 }
 mysql_free_result($result);

 ?
 /table

 Any help with this or direction would be appreciated !

 Regards
 Chris



 --
 Chris Grigor
 --



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] printing an array

2002-10-24 Thread Jason Wong
On Thursday 24 October 2002 19:39, Chris Grigor wrote:
 If you look further down where I print

 print trtd$row-Routine_Tests_Count/td;

 The value $row-Routine_Tests_Count is various numbers that need to printed
 in sepearte columns (Test 1 test 2 etc). So this
 means I have to put it into an array to print??

 Could anyone direct me on how to print it into an array

For each iteration of your while-loop you need to:

1) Open a new table row: 
   echo tr;

2) Create a column and print out the contents for each field in your $row:
   echo td$row-Routine_Tests_Count/td;
   echo ...

3) Close the table row: 
   echo /tr;

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
You have mail.
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] printing an array

2002-10-24 Thread Chris Grigor
Hey there all


Im sure that someone out there can answer this question..

I have a problem, how can I print each element in an array so that is
returned into a table?


eg
table width=100%
th width=25% nowrap
Test1
/th
th width=25% nowrap
Test2
/th
th width=25% nowrap
Test3
/th
th width=25%
Test4
/th

?php
include(common.inc);
$link_id = mysql_connect($dbhost, $username, $password)
or die (Connection Failed);

mysql_select_db($db);
$query = select Routine_Tests_Count from CDT_Routine_Tests where Ref_num =
'$ref_num'
order by Routine_Tests_Link;

$result = mysql_query($query, $link_id)
or die (Query on $dbhost failed);

while ($row = mysql_fetch_object($result)) {
print td$row-CDT_Routine_Count/td;--- (This
value holds the Results of test1 test 2 etc
   
 that I need to print into the table)
}
mysql_free_result($result);

?
/table

Any help with this or direction would be appreciated !

Regards
Chris



--
Chris Grigor
--



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php