11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

www.it-ebooks.infoCHAPTER 35 • PRACTICAL DATABASE QUERIEStd.alt {background: #CCCC99;}Now add the following line directly following the completion of the for loops in Listing 35-1:$table->altRowAttributes(1, null, array("class"=>"alt"));Executing the revised script produces output similar to that found in Figure 35-2.Figure 35-2. Alternating row styling with HTML_TableCreating a Table from Database DataWhile using arrays as the data source to create tables is great for introducing the basic fundamentals ofHTML_Table, chances are you’re going to be retrieving this information from a database. Therefore, let’sbuild on the previous examples by retrieving the sales data from a <strong>MySQL</strong> database and presenting it tothe user in a tabular format.The general process really doesn’t differ much from that presented in Listing 35-1, except this timeyou’ll be navigating through a result set rather than a standard array. Listing 35-2 contains the code.Listing 35-2. Displaying <strong>MySQL</strong> Data in Tabular Format

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!