For crying out loud just use the following
<?php require_once('Connections/vendorshomepages.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_vendorshomepages, $vendorshomepages);
$query_Parent = "SELECT * FROM categories";
$Parent = mysql_query($query_Parent, $vendorshomepages) or die(mysql_error());
$row_Parent = mysql_fetch_assoc($Parent);
$totalRows_Parent = mysql_num_rows($Parent);
mysql_select_db($database_vendorshomepages, $vendorshomepages);
$query_Child = "SELECT * FROM companies";
$Child = mysql_query($query_Child, $vendorshomepages) or die(mysql_error());
$row_Child = mysql_fetch_assoc($Child);
$totalRows_Child = mysql_num_rows($Child);
<?php
if ($row_Child) {
echo "<SC" . "RIPT>\n";
echo "var WAJA = new Array();\n";
$oldmainid = 0;
$newmainid = $row_Child["comp_cat_id"];
if ($oldmainid == $newmainid) {
$oldmainid = "";
}
$n = 0;
while ($row_Child) {
if ($oldmainid != $newmainid) {
echo "WAJA[".$n."] = new Array();\n";
echo "WAJA[".$n."][0] = '".WA_DD_Replace($newmainid)."';\n";
$m = 1;
}
echo "WAJA[".$n."][".$m."] = new Array();\n";
echo "WAJA[".$n."][".$m."][0] = "."'".WA_DD_Replace($row_Child["comp_id"])."'".";\n";
echo "WAJA[".$n."][".$m."][1] = "."'".WA_DD_Replace($row_Child["comp_name"])."'".";\n";
$m++;
if ($oldmainid == 0) {
$oldmainid = $newmainid;
}
$oldmainid = $newmainid;
$row_Child = mysql_fetch_assoc($Child);
if ($row_Child) {
$newmainid = $row_Child["comp_cat_id"];
} …