0

Hi
This is just a straight-forward dynamic field, but I still can't seem to get it to stay sticky....I have tried all kinds of things, including

if (!empty($add_area)) echo......

or equivalent fieldnames...

Any help would be really appreciated...many thanks

<label for="add_area"></label>
                              <select name="add_area" id="add_area">
                                <?php
do {  
?>
                                <option value="<?php echo $row_rs_areas['district_area']?>"><?php if (!empty($add_area)) echo $row_rs_areas['district_area']?></option>
                                <?php
} while ($row_rs_areas = mysql_fetch_assoc($rs_areas));
  $rows = mysql_num_rows($rs_areas);
  if($rows > 0) {
      mysql_data_seek($rs_areas, 0);
	  $row_rs_areas = mysql_fetch_assoc($rs_areas);
  }
?>
2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by ebanbury
0

At line 6 (or actually, the unnumberd line underneath six, the way i see it) You use an echo() without a ;, which should fail if i'm correct.
Also, does a if-loop without brackets ( { } ) work?
I know it does in some languages, as long as the code block (that is to be executed if the statement is true) is only one line long, but i'm not sure about PHP.

Also, you're referencing to $add_area, but does that actually exist?
If you're talking about the label's ID, or the select's name/ID, remember that PHP cannot reference to HTML content, JavaScript would be better for that.

Sorry if i'm not much of a help, can't really get much out of your code, since it seems incomplete :)

0

Hi Thanks for getting back to me....yes the

if (!empty($add_area))

is just what I was adding to try things...makes no difference either way.

The code is pretty complete - it is the entire code for that field. The whole lot is generated automatically via dreamweaver by selecting the form field for a list and then selecting the dynamic source from a recordset....

Maybe I should write it by hand might be easier? But then I have another dynamic drop down which I'm also trying to make sticky - which is written without dreamweaver :0)

0

Heya,
I can't find the solution to your problem atm, seen as i am no sticky expert...
But yes, i would always recommend writing your own code: to my idea, dreamweaver and other code-generating programs always write unclear or messy code.

I once saw a website made with the WYSIWYG editor of dreamweaver, when we added a table to the bottom later on, the entire site got defaced... bit of an extream case, but you get the point :P

try doing one thing at a time: make it sticky first, then dynamic, or the other way around

edit: did you try using selected=selected in the right field?

Edited by phoenix_2000: n/a

0

Hi in case this may help anyone in the future...I rewrote without using dreamweaver and this seems to be working:

<?php $query = @mysql_query('SELECT DISTINCT district_zone FROM property_districts')
	or die('Query failed: ' . mysql_error());
	
	//// Start SELECT PART
	$sticky = '';
	if(isset($_GET['submit'])) {
	$sticky = $_GET['district_zone'];
}
	$pull_zone = "\r\n<select name=\"district_zone\">\r\n";
	
	while ($line = mysql_fetch_array($query, MYSQL_NUM)) {
	$district = mysql_real_escape_string($line[0]);

	if ($line[0] == $sticky) {
	$pull_zone .= "<option value=\"$line[0]\" selected=\"selected\">$line[0] $line[1]\r\n</option>\n";
} else {
	$pull_zone .= "<option value=\"$line[0]\">$line[0] $line[1]\r\n</option>\n";
}
}

	echo '</select>';
	echo "$pull_zone";
//// end select
//// END DISTRICT PULLDOWN ?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.