5 Replies - 2052 Views - Last Post: 19 July 2009 - 09:31 PM Rate Topic: -----

#1 Stofke  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 07-January 09

dynamic checkboxes

Posted 19 July 2009 - 04:48 AM

Hi all , i'm rebuilding an old script and want to redesign my search box.

this code generates a dynamicly filled select.



<select name="pt" size="1" style="height: 18px; width:125px;">
<option value="" selected="selected"><?php echo FORM_SELECT_ALL_TYPES; ?></option>
<?PHP 

	$rows = $sql->execute ( "SELECT * FROM " . $propertytypes_table .
		" ORDER BY propertytype ASC", SQL_RETURN_ASSOC );

	for ( $i = 0; $i < sizeof ( $rows ); ++$i )
	{
	  $row = $rows [ $i ];
	  
	  ?>
<option value="<?php echo $cgi->htmlEncode ( $row [ "id" ] ); ?>">
<?php
	  echo $cgi->htmlEncode ( $row [ "propertytype" ] ); ?>
</option>
<?php
	}

?>
</select>





Now i want to make it to a new form from wich the layout is allready finished.


http://antwerpfashio...html?loc=ikZoek


I want to change the option to the checkboxes but i have no clue how to manage this.

i tried the folowing


<?php if($display_search_types == "Y") { ?>
	<h3>Checkboxes</h3>
	
<label><input type="checkbox"><?php echo FORM_SELECT_ALL_TYPES; ?></label>
<?PHP 

	$rows = $sql->execute ( "SELECT * FROM " . $propertytypes_table .
		" ORDER BY propertytype ASC", SQL_RETURN_ASSOC );

	for ( $i = 0; $i < sizeof ( $rows ); ++$i )
	{
	  
	
	  $row = $rows [ $i ];
	  
	  
	  if ($i % 2 == 0 )
	{
	<div class='leftcol'>

	<label><input type="checkbox"><?php echo $cgi->htmlEncode ( $row [ "propertytype" ] ); ?> </label>
	<div>
	}
	else
	{
	<div class='rightcol'>
	<label><input type="checkbox"><?php echo $cgi->htmlEncode ( $row [ "propertytype" ] ); ?></label>
	</div>
	}
  
	  
	  
	  
	  ?>
<?php
	}

?>






is this a right way or should i do this otherwise ?

thx in advance !!

Kristof

This post has been edited by Stofke: 19 July 2009 - 04:49 AM


Is This A Good Question/Topic? 0
  • +

Replies To: dynamic checkboxes

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2983
  • View blog
  • Posts: 10,306
  • Joined: 08-August 08

Re: dynamic checkboxes

Posted 19 July 2009 - 08:09 AM

Here's a checkbox tutorial:
http://www.dreaminco...wtopic86370.htm
Was This Post Helpful? 0
  • +
  • -

#3 Stofke  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 07-January 09

Re: dynamic checkboxes

Posted 19 July 2009 - 01:23 PM

Hi,

Thx for the link.

But thislooks similar to my code. Tho there is a bug at the <div class=leftcol> any ideas?


Thx

k
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2983
  • View blog
  • Posts: 10,306
  • Joined: 08-August 08

Re: dynamic checkboxes

Posted 19 July 2009 - 02:16 PM

html != php
Was This Post Helpful? 0
  • +
  • -

#5 Stofke  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 07-January 09

Re: dynamic checkboxes

Posted 19 July 2009 - 03:06 PM

	 if ($i % 2 == 0 )
	{
	echo "<div class='leftcol'>"
	echo "<label><input type='checkbox'>" <?php echo $cgi->htmlEncode ( $row [ 'propertytype' ] ); ?> echo "</label>"
	echo "</div>"
	}
	else
	{
	echo "<div class='rightcol'>"
	echo "<label><input type='checkbox'>"<?php echo $cgi->htmlEncode ( $row [ "propertytype" ] ); ?>echo"</label>"
	echo "</div>"
	}



i forgot the echoes .

seems i can't do a <?php

This post has been edited by Stofke: 19 July 2009 - 03:25 PM

Was This Post Helpful? 0
  • +
  • -

#6 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: dynamic checkboxes

Posted 19 July 2009 - 09:31 PM

try this code
<?php
   if ($i % 2 == 0 )
    {
    echo "<div class='leftcol'>";
    echo "<label><input type='checkbox'>".$cgi->htmlEncode ( $row [ 'propertytype' ] )."</label></div>";
    }
    else
    {
    echo "<div class='rightcol'><label><input type='checkbox'>".$cgi->htmlEncode ( $row [ "propertytype" ] )."</label></div>";
    }
?>

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1