Hjælp til database i script
Hej AlleMit problem er at få lagt data fra en database ind i arrayet i javascriptet.
I denne variabel "$manufacturers_query" ligger det data jeg skal bruge man hvordan ligger jeg den i toparray.
Håber at nogen kan hjælpe mig.
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="classic.css">
<script type="text/javascript" src="fade.js"></script>
<script type="text/javascript" src="select.js"></script>
<script type="text/javascript" src="writeSelect.js"></script>
</head>
<body>
<!-- infobox_start //-->
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td height="14" class="infoBoxHeading"><BR></td>
<td width="100%" height="14" class="infoBoxHeading"> Test Box</td>
<td height="14" class="infoBoxHeading" nowrap><BR></td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="1" class="infoBox">
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="3" class="infoBoxContents">
<tr>
<td align="center" class="boxText">
<?php
$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
$manufacturers_array = array();
if (MAX_MANUFACTURERS_LIST < 2) {
$manufacturers_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);
}
echo "\n". '<script>';
echo "\n". 'topArray = new Array();';
$taeller=0;
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$manufacturers_name = ((strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturers['manufacturers_name']);
//$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
// 'text' => $manufacturers_name);
echo "\n". 'topArray['.$taeller.'] = new Option(<nobr title="This takes you back to the main page">' .strlen($manufacturers['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN. '?' .substr($manufacturers['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' . $manufacturers['manufacturers_name'].'</nobr>, "http://localhost/standard/catalog/index.php?'.$manufacturers['manufacturers_id']. '&' .$http_get_vars['osCid'];
$taeller = $taeller + 1;
}
echo "\n". 'writeSelectBox(topArray, "select2", 1, "window.open(this.options[this.selectedIndex].value, \'_top\')", "margin-left: 10; width: 140;");';
echo "\n". '</script>';
echo "\n";
//echo $manufacturers_array;
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- infobox_slut //-->
</body>
</html>
