Totally Zenned
- Join Date:
- Aug 2009
- Location:
- Bedford, England
- Posts:
- 968
- Plugin Contributions:
- 0
Question For PHP GURUS
I am using the better together mod and am calling some cross sells from my existing Multi cross sells mod database table.
Originally I had this code which worked
$resultxsells = mysql_query("SELECT products_id, xsell_id FROM products_xsell1");
while($rowxsells = mysql_fetch_array($resultxsells)) {
$this->add_prod_to_prod($rowxsells['products_id'], $rowxsells['xsell_id'], "X", 0);
}
but after I read a post that DrByte said about while loops and having to be careful they don't spiral out of control i've now changed it to this:
$resultxsells = mysql_query("SELECT products_id, xsell_id FROM products_xsell1");
$rowxsells = mysql_fetch_array($resultxsells);
$countthem = count($rowxsells);
$f = 0;
while ($f < $count) {
$this->add_prod_to_prod($rowxsells['products_id'], $rowxsells['xsell_id'], "X", 0);
$f++;
}
can anyone advise if this is now a safe way of doing it? Many thanks
Phil Rogers
A problem shared is a problem solved.