Search the Community
Showing results for tags 'unset'.
-
Hello, I am trying to unset from array using array_search, it's working, except the first array value "a+" is not working $bloodType_list = ['a+','a-','b+','b-','o+','o-','ab+','ab-']; if($key = array_search('a+',$bloodType_list)){ unset($bloodType_list[$key]); } foreach($bloodType_list as $bloodType_lists){ echo $bloodType_lists."<br>"; }
- 7 replies
-
- php
- array_search
-
(and 1 more)
Tagged with:
-
Hi Freaks I have an update page for an online groundwater information system. I am using Postgresql/PostGIS. This is a screenshot of the update page with 2 select boxes. My problem is I don't want the columns 'well_no' or 'geom' to appear in the first select element, i.e. the column to update, as they should NOT be updated. The code for the first selection drop-down list is as follows: <p> Columns available - select the column to update</p> <form class="my-form" method="post"> <select name='up_column' id='up_column'> <?php try { $result = $pdo->query("select column_name from information_schema.Columns WHERE table_schema = 'public' AND table_name = '{$table}' ORDER BY column_name desc"); foreach ($result as $row) { unset($row['well_no']); unset($row['geom']); echo "<option value={$row['column_name']}>{$row['column_name']}</option>"; } } catch (PDOException $e) { echo "Error: " . $e->getMessage(); } ?> </select> No need to comment that I am not using prepared statements, as I am in a test environment and will rewrite the query before going into production. Please focus on why my use of unset is not working, as both the forbidden columns are appearing in the select list.