[PHP] table formatting
This script by Rob Sossomon works great --Thanks! however could anyone tell me if its possible to make it run horizontally. at the moment the output is like this--- -- Round Game Winning team Wins 1 1 Collingwood 1 2 Melbourne 4 1 3 Fremantle 4 1 4 Brisbane 4 1 5 St Kilda 1 6 Port Adelaide 4 1 7 Kangaroos 4 1 8 West Coast 4 2 1 Richmond 2 2 Collingwood 4 2 3 Brisbane 4 2 4 West Coast 2 5 Essendon 2 6 Fremantle 2 7 Carlton 4 2 8 Hawthorn --I would like it like this Round game1wingame2 win game3 etc 1 Collingwood 4 Melbourne 4 Fremantle 4 ?php session_start(); include(connect.php); $Name = $_SESSION['first_name'] . . $_SESSION['last_name']; $sql = SELECT * FROM Selections WHERE Name = '$Name'; $result = mysql_query($sql); /* Determine the number of records returned */ while ($row = MYSQL_FETCH_array($result)) $number = mysql_numrows($result); /* Start printing to make it look good */ print table width=\30%\ cellspacing=\0\ cellpadding=\0\ border=\0\; print trthRound/ththGame/ththWinning Team/ththWins/th/tr; $total_points=0; /* Iterate through to make it clean */ while ($i $number) { $item_1 = mysql_result($result, $i,Round); $item_2 = mysql_result($result, $i,Game); $item_4 = mysql_result($result, $i,Winner); $item_5 = mysql_result($result, $i,Points); /* This makes it print out in 2 separate color, depending on rows. */ if ($i%8 == 0) { print tr bgcolor=\#99\tdcenter$item_1/center/tdtdcenter$item_2/ce nter/tdtdcenter$item_4/center/tdtdcenter$item_5/center/td /tr\n; } else { print tr bgcolor=\#66\tdcenter$item_1/center/tdtdcenter$item_2/ce nter/tdtdcenter$item_4/center/tdtdcenter$item_5/center/td /tr\n; } /* Increase record count and total_points to date */ $i++; $total_points += $item_5; } /* close everything up */ print trth colspan=5Total Points Earned: $total_points/th/tr; print /table; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] table formatting
Change the design of the HTML table. [Original Message] From: BigMark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: 06/04/2004 8:07:51 PM Subject: [PHP] table formatting This script by Rob Sossomon works great --Thanks! however could anyone tell me if its possible to make it run horizontally. at the moment the output is like this--- -- Round Game Winning team Wins 1 1 Collingwood 1 2 Melbourne 4 1 3 Fremantle 4 1 4 Brisbane 4 1 5 St Kilda 1 6 Port Adelaide 4 1 7 Kangaroos 4 1 8 West Coast 4 2 1 Richmond 2 2 Collingwood 4 2 3 Brisbane 4 2 4 West Coast 2 5 Essendon 2 6 Fremantle 2 7 Carlton 4 2 8 Hawthorn --I would like it like this Round game1wingame2 win game3 etc 1 Collingwood 4 Melbourne 4 Fremantle 4 ?php session_start(); include(connect.php); $Name = $_SESSION['first_name'] . . $_SESSION['last_name']; $sql = SELECT * FROM Selections WHERE Name = '$Name'; $result = mysql_query($sql); /* Determine the number of records returned */ while ($row = MYSQL_FETCH_array($result)) $number = mysql_numrows($result); /* Start printing to make it look good */ print table width=\30%\ cellspacing=\0\ cellpadding=\0\ border=\0\; print trthRound/ththGame/ththWinning Team/ththWins/th/tr; $total_points=0; /* Iterate through to make it clean */ while ($i $number) { $item_1 = mysql_result($result, $i,Round); $item_2 = mysql_result($result, $i,Game); $item_4 = mysql_result($result, $i,Winner); $item_5 = mysql_result($result, $i,Points); /* This makes it print out in 2 separate color, depending on rows. */ if ($i%8 == 0) { print tr bgcolor=\#99\tdcenter$item_1/center/tdtdcenter$item_2/ce nter/tdtdcenter$item_4/center/tdtdcenter$item_5/center/td /tr\n; } else { print tr bgcolor=\#66\tdcenter$item_1/center/tdtdcenter$item_2/ce nter/tdtdcenter$item_4/center/tdtdcenter$item_5/center/td /tr\n; } /* Increase record count and total_points to date */ $i++; $total_points += $item_5; } /* close everything up */ print trth colspan=5Total Points Earned: $total_points/th/tr; print /table; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Table formatting
Hi all. Last nite Ive came across a problem I wasnt able to figure out by my self. Its not difficult to make a loop that will make new *TABLE ROWS* (tr) to show several DB objects in a nice way what I need to do, is to display 2 or maybe even 3 of this objects stored in a DB per table row, separated in different *TABLE COLUMS* (td) how can I achieve this? What I usually do is: -- // DB QUERY $query = SELECT * FROM table_name; $result = mysql_query($query) or die(mysql_error()); $num_rows = mysql_num_rows($result); // NOW THE LOOP for ($i=0; $i$num_rows; $i++) { $row = mysql_fetch_array($result); echo tr; echo td; echo $row[whatever]; echo /td; echo /tr; } -- but how can I get 2 or 3 columns displaying different db objects? A loop inside a loop? Thanks in advance, mailto:[EMAIL PROTECTED] Cesar Aracena CE / MCSE+I Neuquen, Argentina +54.299.6356688 +54.299.4466621