Re: "Sense" last record

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I would use some JavaScript on the client side to go through the table and change the classes once the whole page is loaded.

Otherwise, for a pure PHP solution, I might either load the whole table on an array, which is wasteful in memory, or defer the actual output of each record until the next record is read so, if no further records exist, I would change the class name of the row still in a variable and output the row right after the loop ends before the end of the table.

Satyam

----- Original Message ----- From: "Mário Gamito" <mgamito@xxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Monday, April 09, 2007 3:31 PM
Subject:  "Sense" last record


Hi,

I'm doing this site that has three news in the homepage.
You can see the static version here:
http://www.telbit.pt
As you can see, the two first news have "blocoTexto" class and the third, "blocoTextoLast"

Now, i'm developing a dinamyc structure where the news are stored in a MySQL database and retrieved from there.

My problem is with the third news and it's different class.
I'm using AdoDB recordSet to get the news from the database.
You can see it here:
http://www.telbit.pt/2/

How can i "sense" that i've reached the last row and apply the "blocoTextoLast" class to it ?

My code follows my signature.

Any help would be appreciated.

Warm Regards
--
:wq! Mário Gamito
--
<div id="blocoNews">
 <?php
  include('config.php');
  include('adodb/adodb.inc.php');

  // connect to MySQL
  $conn->debug=1;
  $conn = &ADONewConnection('mysql');

$conn->PConnect($host,$user,$password,$database);

  // get news data
$recordSet = &$conn->Execute("SELECT date, now, title, lead, body FROM news ORDER BY date DESC LIMIT 3");

 if (!$recordSet)
  print $conn->ErrorMsg();
 else
  while (!$recordSet->EOF) {
print '<div class="blocoTexto">' . ' <h3>' . $recordSet->fields[2] . '</h3>' . '<p class="data">' . $recordSet->fields[0] . '</p>' .
'<p>' . $recordSet->fields[3] . '</p>' . '</div>';

 $recordSet->MoveNext();
}
 echo "<br class=\"clear\">";
 $recordSet->Close();
 $conn->Close();
?>  <!-- end #secContent --> </div>

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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.0.0/752 - Release Date: 08/04/2007 20:34



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux