EXplanation help


Posted on 16th Feb 2014 07:03 pm by admin

Hey all,

I am still fairly new to PHP programming and I am trying to put together a page where you select search terms from a drop down menu and it keeps the menu at your search choice in the menu after the search.

Here is the code I was suggested to use, but I am having problems understanding how it keeps the choice in the menu.

I can almost understand how it works, but I need a little push to grasp it.

Here is the code:

foreach($options as $key => $content)
{
if ($key == $value) $select = ' selected="selected"';
else $select = NULL;
$html .=
'<option value="' . htmlspecialchars($key) . '"' . $select .
'>' . htmlspecialchars($content) . '</option>' . "n";
}

Now I understand how to walk through the code, but I am having trouble understanding how it holds over the choice.

THanks in advance for the help...

No comments posted yet

Your Answer:

Login to answer
195 Like 47 Dislike
Previous forums Next forums
Other forums

Wrong Info sent Using $get in form
Hi i have this code that i tried to make to send some info from one page to aother with lots of ppls

background color imagefill
Hello

I would like to ask you why I see this square in red color just in my local xampp insta

button help
i originally had this but realised it is much easier to have a button.

Code: <?php

XML Grouping
I'm using xml_parse_into_struct to get all my elements, but now I need to group them. For example, h

2 things: enter doesn't work in IE & empty form
i have this search form that works well except for 2 things.

1) on IE when i hit enter instea

session checking in page load
hai all I have a web site is www.Mryas.com in this my login page is Page1.aspx its co

Secure FTP
Hi experts,
There is no SFTP action in MII workbench.
This means it needs developing custo

I have a parse error in this query help..
Code: $query1="INSERT INTO `rating` (`item_name`, `rating`, `ip_address`, `date_rated`) VALUES

insert quotes
Hi,

I have an output like this:
Code: john,18,Cancer
How can I change this to
Code:

Checking if variable is 0 as opposed to NULL/Empty...
I'm trying to write some code that will retrieve a user's access level from my database and if it do

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash