Select Product";
$q = "SELECT ID, Name FROM ".$tables['Products']." WHERE Active='Y'";
$r = mysql_query($q);
while($ra = mysql_fetch_array($r))
{
$check = false;
//Get all the scientific info for this product
$q2 = "SELECT SI.ID FROM ".$tables['ScientificInfo']." SI, ".$tables['ScientificInfoSiteAssociation']." SISA, ".$tables['SciProdAssociation']." SIPA WHERE SI.ID=SISA.AssocA AND SISA.AssocB=".$configOptions['SiteIDMarker']." AND SI.ID=SIPA.AssocA AND SIPA.AssocB=".$ra['ID'];
$r2 = mysql_query($q2);
while($ra2 = mysql_fetch_array($r2))
{
$check = true;
// $scienceList .= "".$ra['Name']." \n";
}
if($check == true)
{
$scienceList .= "".$ra['Name']." ";
}
}
$scienceLinks = "
";
$q = "SELECT SI.ID, SI.Name FROM ".$tables['ScientificInfo']." SI, ".$tables['ScientificInfoSiteAssociation']." SISA WHERE SI.ID=SISA.AssocA AND SISA.AssocB=".$configOptions['SiteIDMarker']." ORDER BY SI.Name ASC";
$r = mysql_query($q);
while($ra = mysql_fetch_array($r))
{
$scienceLinks .= "".$ra['Name']." ";
}
$scienceLinks .= " ";
$short = false;
if(!isset($ID) || $ID == "")
{
//Generate a random id
$q = "SELECT SI.ID FROM ".$tables['ScientificInfo']." SI, ".$tables['ScientificInfoSiteAssociation']." SISA WHERE SI.ID=SISA.AssocA AND SISA.AssocB=".$configOptions['SiteIDMarker']." ORDER BY RAND() LIMIT 0,1";
$r = mysql_query($q);
$ra = mysql_fetch_array($r);
$ID = $ra['ID'];
$command = "displayMe";
$short = true;
}
if(isset($command) && $command == "displayMe")
{
$ps = new ScientificInfo();
$ps->ID = $ID;
$ps->getFromDatabase($tables['ScientificInfo']);
$name = $ps->name;
if($ps->description != "" && $short == false)
{
$description = $ps->description;
}
else
{
$description = $ps->shortDescription;
if($short == true && $description == "")
{
$description = $ps->description;
}
}
}
if(isset($command) && $command == "displayProduct")
{
$code = "";
$q = "SELECT SI.ID, SI.Name, SI.ShortDescription, SI.Description FROM ".$tables['ScientificInfo']." SI, ".$tables['ScientificInfoProductAssociation']." SIPA, ".$tables['ScientificInfoSiteAssociation']." SISA WHERE SI.ID=SISA.AssocA AND SISA.AssocB=".$configOptions['SiteIDMarker']." AND SI.ID=SIPA.AssocA AND SIPA.AssocB=".$ID;
$r = mysql_query($q);
while($ra = mysql_fetch_array($r))
{
$code .= $frmObj->makeOpenTable();
$code .= $frmObj->makeDisplayField("".$ra['Name']." ");
if($ra['Description'] != ""){ $code .= $frmObj->makeDisplayField($ra['Description']); } else { $code .= $frmObj->makeDisplayField($ra['ShortDescription']); }
$code .= " ";
}
}
@mysql_close($db);
/**
// Retrieve the scientific study of the selected product (if any)
$scInfo = array("","");
if (isset($pid) || $pid != "") {
$q = "SELECT P.Name, S.Description FROM DVProducts P, DVScientificInfo S , DVScientificInfoProductAssociation A WHERE A.AssocB='".$pid."' AND S.ID=A.AssocA AND P.ID=".$pid;
$r = mysql_query($q);
$scInfo = mysql_fetch_array($r);
}
// Retrieve from DB and list the products with scientific studies
$q = "SELECT P.ID, P.Name FROM DVProducts P, DVScientificInfoProductAssociation A WHERE A.AssocB=P.ID";
$r = mysql_query($q);
$studies = "";
while ($ra = mysql_fetch_array($r)) {
$studies .= "".$ra['Name']." ";
}
**/
?>
www.livelongereducationalfoundation.com - Science Behind Traditional Medicine
Science Behind Traditional Medicine