Link to home
Start Free TrialLog in
Avatar of designersx
designersx

asked on

hides more than 1 table from displaying in the dropdown.

this code below hides 1 table from the database named field_types and displays the other tables in a dropdown. i want to hide one more table that should not be displayed in the dropdown. please help me.

otherwise for 1 table, the code is working exactly fine.
i think we need to do something on line 8
<select onchange="changeTargetURL(this);" action="default.php">
        <option targetURL="" selected="selected">Select</option>
        <option targetURL="new.php">create new</option>
		<option>---------------</option>
		<?php
			$res = mysql_query("show tables") or die(mysql_error());
			while ($row = mysql_fetch_array($res)){
			   if ($row[0] == 'field_types') continue;
			   $my_tables[] = $row[0];
			}
			foreach ($my_tables as $tablename){			
		?><option targetURL="<?php echo $tablename.".php"; ?>"><?php echo $tablename; ?></option><?php 			
		} ?>
</select>

Open in new window

Avatar of fcardinaux
fcardinaux
Flag of Switzerland image

Put all the tables you need to hide in an array, and do this:

<select onchange="changeTargetURL(this);" action="default.php">
        <option targetURL="" selected="selected">Select</option>
        <option targetURL="new.php">create new</option>
                <option>---------------</option>
                <?php
                        $tables_to_hide = array('field_types', 'the_other_table');
                        $res = mysql_query("show tables") or die(mysql_error());
                        while ($row = mysql_fetch_array($res)){
                           if (in_array($row[0], $tables_to_hide) continue;
                           $my_tables[] = $row[0];
                        }
                        foreach ($my_tables as $tablename){                     
                ?><option targetURL="<?php echo $tablename.".php"; ?>"><?php echo $tablename; ?></option><?php                  
                } ?>
</select>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of fcardinaux
fcardinaux
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial