Question
Style, technique, and best practices question
I have a database containing a number of products (say 1000).
These
products are categorized into 5 different categories.
I want to deal with these products in ways that lead me to wonder the
following -
1. Is it better to have multiple recordsets (one for each category), or to
have a single recordset loaded into an array which can then be manipulated
on the page, e.g.,
$blah = array();
do {
$blah[] = $row_recordset;
} while ($row_recordset = mysql_fetch_assoc($rsrecordset));
2. Also, at present I have this method implemented like this -
<?php
$tester = array();
$socketTester = array();
$adapter = array();
$accessory = array();
do {
if (($row_rsTesters['ItemCatID']) == 4) { $tester[] = $row_rsTesters; }
if (($row_rsTesters['ItemCatID']) == 6) { $socketTester[] =
$row_rsTesters; }
if (($row_rsTesters['ItemCatID']) == 2) { $accessory[] = $row_rsTesters; }
if (($row_rsTesters['ItemCatID']) == 3) { $adapter[] = $row_rsTesters; }
} while ($row_rsTesters = mysql_fetch_assoc($rsTesters));
?>
Could I do it with a single array key, instead of multiple arrays?
<?php
$products = array();
do {
if (($row_rsTesters['ItemCatID']) == 4) { $products['tester'] =
$row_rsTesters; }
elseif (($row_rsTesters['ItemCatID']) == 6) { $products['socketTester'] =
$row_rsTesters; }
elseif (($row_rsTesters['ItemCatID']) == 2) { $products['accessory'] =
$row_rsTesters; }
elseif (($row_rsTesters['ItemCatID']) == 3) { $products['adapter'] =
$row_rsTesters; }
} while ($row_rsTesters = mysql_fetch_assoc($rsTesters));
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
products are categorized into 5 different categories.
I want to deal with these products in ways that lead me to wonder the
following -
1. Is it better to have multiple recordsets (one for each category), or to
have a single recordset loaded into an array which can then be manipulated
on the page, e.g.,
$blah = array();
do {
$blah[] = $row_recordset;
} while ($row_recordset = mysql_fetch_assoc($rsrecordset));
2. Also, at present I have this method implemented like this -
<?php
$tester = array();
$socketTester = array();
$adapter = array();
$accessory = array();
do {
if (($row_rsTesters['ItemCatID']) == 4) { $tester[] = $row_rsTesters; }
if (($row_rsTesters['ItemCatID']) == 6) { $socketTester[] =
$row_rsTesters; }
if (($row_rsTesters['ItemCatID']) == 2) { $accessory[] = $row_rsTesters; }
if (($row_rsTesters['ItemCatID']) == 3) { $adapter[] = $row_rsTesters; }
} while ($row_rsTesters = mysql_fetch_assoc($rsTesters));
?>
Could I do it with a single array key, instead of multiple arrays?
<?php
$products = array();
do {
if (($row_rsTesters['ItemCatID']) == 4) { $products['tester'] =
$row_rsTesters; }
elseif (($row_rsTesters['ItemCatID']) == 6) { $products['socketTester'] =
$row_rsTesters; }
elseif (($row_rsTesters['ItemCatID']) == 2) { $products['accessory'] =
$row_rsTesters; }
elseif (($row_rsTesters['ItemCatID']) == 3) { $products['adapter'] =
$row_rsTesters; }
} while ($row_rsTesters = mysql_fetch_assoc($rsTesters));
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================
