Hi i need som help on php and java

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saranda
Forum Newbie
Posts: 15
Joined: Wed May 10, 2006 6:18 pm

Hi i need som help on php and java

Post by saranda »

i have this code thet it's not working and i don't know why can you tell me


<?

// Edit these values {{{

$sql_host = 'localhost';
$sql_user = 'administrator';
$sql_pass = '';
$sql_db = 'test';

// }}} End edit

?>

<script language="JavaScript">

var arItems = new Array()

arItems = [

<?

mysql_connect($sql_host, $sql_user, $sql_pass);
mysql_select_db($sql_db);

$qry = mysql_query('SELECT * FROM temp WHERE parent > 0');

while ($row = mysql_fetch_array($qry)) {
$arr.= '[' . $row['parent'] . ', ' . $row['id'] . ', \'' . $row['name'] . '\'],' . "\n\t";
}

$final = substr($arr, 0, -3);
echo $final;

?>

]

function fillItems( intStart ) {

var fTypes = document.form1.types
var fItems = document.form1.items
var a = arItems
var b, c, d, intItem, intType

if ( intStart > 0 ) {
for ( b = 0; b < a.length; b++ ) {
if ( a[1] == intStart ) {
intType = a[0];
}
}

for ( c = 0; c < fTypes.length; c++ ) {
if ( fTypes.options[ c ].value == intType ) {
fTypes.selectedIndex = c;
}
}
}

if ( intType == null ) {
intType = fTypes.options[ fTypes.selectedIndex ].value
}

fItems.options.length = 0;

for ( d = 0; d < a.length; d++ ) {
if ( a[d][0] == intType ) {
fItems.options[ fItems.options.length ] = new Option( a[d][2], a[d][1] ); // no line-break here
}

if ( a[d][1] == intStart ) {
fItems.selectedIndex = fItems.options.length - 1;
}
}
}

</script>

<form name="form1">
<select name="types" onChange="fillItems(0)">
<option value="#" selected="selected">Please select</option>
<?
mysql_connect($sql_host, $sql_user, $sql_pass);
mysql_select_db($sql_db);
$qry = mysql_query('SELECT * FROM temp WHERE parent = 0');
while ($row = mysql_fetch_array($qry)) {
?>
<option value="<?=$row['id'];?>"><?=$row['name'];?></option>
<?
}
?>
</select>

<select name="items"></select>
</form>
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

can you tell us what it is doing and what it is supposed to do?

Also please use the

Code: Select all

tags
saranda
Forum Newbie
Posts: 15
Joined: Wed May 10, 2006 6:18 pm

Post by saranda »

what i want is when i select a car in first dropdown menu the id of thet car to opear in the second dropdown menu and it should work in onchange event

the script thet you see was given to me by someone as on example but it didn't work so if you know how can i do thet please help
Post Reply