Adobe Dreamweaver Forums



Last 10 THreads :         catching errors from remotely invoked processes (Last Post : Amy Blankenship - Replies : 3 - Views : 4 )           »          A question for the gurus (Last Post : Amy Blankenship - Replies : 1 - Views : 2 )           »          Naming Layers CS4 Mac (Last Post : Type & Art - Replies : 0 - Views : 1 )           »          Flash CS4 on Windows 2003? (Last Post : Richard Morey - Replies : 0 - Views : 1 )           »          Where are the fonts located? (Last Post : Mike Blaustein - Replies : 1 - Views : 2 )           »          Help with Spry Paged View (Last Post : Skinwehr - Replies : 0 - Views : 1 )           »          ANN: Contact Form Solution Pack (Last Post : A.Translator - Replies : 8 - Views : 9 )           »          Help posting folder to server (Last Post : Alan - Replies : 1 - Views : 2 )           »          RoboHelp & Knowledge Bases (Last Post : Benjaminson - Replies : 1 - Views : 2 )           »          Screens get distorted (Last Post : Captiv8r - Replies : 4 - Views : 5 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver Application Development
 
Tags: , , , , ,



Reply
  #1 (permalink)  
Old 09-28-2008, 03:36 AM
Iain71
 
Posts: n/a
Diggs:
Default Search issue with dynamic dropdown array - PHP

I'm currently trying to set up a search with a couple of dynamic dropdowns,
basically to search for cars - so the parent list is car make, and the child is
car model.

I've gotten as far as a page with the dynamic array working, but not the
search :

http://www.mph.uk.com/leasing101.php

(Ignore the cars and vans radio buttons)

For testing there's an Audi A3 and and Audi A6, but this search doesn't work.

The select code looks like :

<select name="Model">
<option value="" <?php if (!(strcmp("", $row_rsModels['Model'])))
{echo "selected=\"selected\"";}
?>>Select a Model</option>
</select>


And the array code looks like :

<?php
if ($row_rsModels) {
echo "<SC" . "RIPT>\n";
echo "var WAJA = new Array();\n";

$oldmainid = 0;
$newmainid = $row_rsModels["Make"];
if ($oldmainid == $newmainid) {
$oldmainid = "";
}
$n = 0;
while ($row_rsModels) {
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_rsModels["ModelID"])."'".";\n";
echo "WAJA[".$n."][".$m."][1] =
"."'".WA_DD_Replace($row_rsModels["Model"])."'".";\n";

$m++;
if ($oldmainid == 0) {
$oldmainid = $newmainid;
}
$oldmainid = $newmainid;
$row_rsModels = mysql_fetch_assoc($rsModels);
if ($row_rsModels) {
$newmainid = $row_rsModels["Make"];
}
if ($oldmainid != $newmainid) {
$n++;
}
}

echo "var rsModels_WAJA = WAJA;\n";
echo "WAJA = null;\n";
echo "</SC" . "RIPT>\n";
}
function WA_DD_Replace($startStr) {
$startStr = str_replace("'", "|WA|", $startStr);
$startStr = str_replace("\\", "\\\\", $startStr);
$startStr = preg_replace("/[\r\n]{1,}/", " ", $startStr);
return $startStr;
}
?>

..to try and find the root of the problem, I've gotten as far as a similar
page, without the dynamic
array, with the child dropdown populated dynaically from the recordset :

http://www.mph.uk.com/leasing501.php

This seems to work exactly as advertised - all the car models are listed from
the recordset, and if
you search for Audi and A3, then it gets returned correctly.

The select code here looks like :

<select name="Model" id="Model">
<option value="">Select a Model</option>
<?php
do {
?>
<option value="<?php echo $row_rsModels['Model']?>"><?php echo
$row_rsModels['Model']?
></option>

<?php
} while ($row_rsModels = mysql_fetch_assoc($rsModels));
$rows = mysql_num_rows($rsModels);
if($rows > 0) {
mysql_data_seek($rsModels, 0);
$row_rsModels = mysql_fetch_assoc($rsModels);
}
?>
</select>

..so I guess the search is set up OK, but the issue is with how to pass the
model from the select code generated by the dynamic array correctly....

Its presumably because the option value is empty :

<option value="" <?php if (!(strcmp("", $row_rsModels['Model']))) {echo
"selected=\"selected\"";} ?>>Select a Model</option>

So I've been trying various possibilities with no joy, such as :

<?php if (!(strcmp("", $row_rsModels['Model']))) {echo
"selected=\"selected\"";} ?>

but without success.

Even then, I'd have though if the value was empty, "", then it would return
all results, rather than no results....?

hope that makes some sense, and someone can shed some light...

Cheers.



Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 07:54 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk