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
ddragas
Forum Contributor
Posts: 445 Joined: Sun Apr 18, 2004 4:01 pm
Post
by ddragas » Wed Aug 25, 2004 2:16 pm
Hi all
I have problem with thois script
Code: Select all
<?php
$sql = "select * from apartmani where iznajmljivac = '$broj' order by vrsta_smjestaja";
$opts = array();
$sifra = array();
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($res)){
$opts[] = $row['vrsta_smjestaja'] . " - " . $row['Naziv_objekta'];
$sifra[] = $row['Sifra_apartmana'];
}
?>
<select name="drugi_smjestaj" onChange="MM_jumpMenu('parent',this,0)" class="txt">
<?php
foreach($sifra as $sif & $opts as $opt){
echo '<option value="http://localhost/plavi/hr/preview_app.php?Sifra_apartmana='.$sif.'">'.$opt.'</option>';
}
include("disconect.php");
?>
<?php
?>
Don't know how to connect these two, and I get parse error on line
foreach($sifra as $sif & $opts as $opt)
$shif should be ID of record, and $opt should be name of record
Please help
Last edited by
ddragas on Wed Aug 25, 2004 2:23 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Aug 25, 2004 2:19 pm
you cannot foreach 2 different arrays at the exact same time.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Aug 25, 2004 2:23 pm
why not.....
Code: Select all
while($row = mysql_fetch_array($res)){
$sifra[$row['Sifra_apartmana']] = $row['vrsta_smjestaja'] . " - " . $row['Naziv_objekta'];
}
//..................
foreach($sifra as $sif => $opt) ........
ddragas
Forum Contributor
Posts: 445 Joined: Sun Apr 18, 2004 4:01 pm
Post
by ddragas » Wed Aug 25, 2004 2:29 pm
OK. Thanx for help
Now It shows in jump menu ID of record and in next row nameof record. Could it be done to show only name of record. Without ID?
ddragas
Forum Contributor
Posts: 445 Joined: Sun Apr 18, 2004 4:01 pm
Post
by ddragas » Wed Aug 25, 2004 2:31 pm
Sorry
My mistake
Thanks for help
Works great
ddragas
Forum Contributor
Posts: 445 Joined: Sun Apr 18, 2004 4:01 pm
Post
by ddragas » Wed Aug 25, 2004 2:50 pm
one more problem
When new page loads (after selection of jump menu) it is selected first value in jump menu. How to select value that was choosen?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Aug 25, 2004 2:53 pm
ddragas
Forum Contributor
Posts: 445 Joined: Sun Apr 18, 2004 4:01 pm
Post
by ddragas » Wed Aug 25, 2004 3:07 pm
Thank you very much
Regards