Jump to content

Help with select box


EchoFool

Recommended Posts

PHP is server sided, so the posted form would not read the PHP code. I use the following below, which allows me to get all of my options from 2 text files, but you can modify it to fit your needs...

 

 

				$fileName = "../name.txt";
			$fh = fopen($fileName, 'r');
			$nameB = fread($fh, filesize($fileName));
			fclose($fh);
			$name = explode("\n",$nameB);
			$fileName = "../var.txt";
			$fh = fopen($fileName, 'r');
			$varB = fread($fh, filesize($fileName));
			fclose($fh);
			$var = explode("\n",$varB);
			for ( $id = 0; $id <= $maxid; $id += 1) {
				$indexfiletest = "../account/" . $user . "/" . $var[$id] . "/index.html";
				if(!file_exists($indexfiletest)){
					echo "<option value='$var[$id]'>$name[$id]</option>";
				}
			}

 

 

That will get the variable names from var.txt and the options from name.txt...

 

 

I just echo the whole option tag inside of the select tag.

Link to comment
https://forums.phpfreaks.com/topic/109258-help-with-select-box/#findComment-560433
Share on other sites

pugboy that looks over complicated for something that is probably simplistic to do. I am aware its server sided.

 

 

I am trying to deal with process (after _POST and on submit)

So value would come out as:

 

2,ITEM lets say in the form process.

Then i need to break that apart to get just:

$id = 2

$type = ITEM

 

At that point i can then put them in to the correct fields in my database.

Link to comment
https://forums.phpfreaks.com/topic/109258-help-with-select-box/#findComment-560438
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.