Jump to content

Recommended Posts

Hello, I'm a newbie here at PHPfreaks.

I have a script that creates an array from a directory, then creates an option selection form. Once an option is selected, it goes to that directory.

What I would like to know is..

How is it possible to give ID's to the opions in the selection list and display it as

index.php?id=1

index.php?id=2

index.php?id=3

and so on...

Right now it is displayed as:

http://site.com/directory/selected option/

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/142544-page-id/
Share on other sites

Heh, sorry.

Get directory and sort into array:

<?php
$results = array();
$dirPath = 'artists';
if ($handle = opendir($dirPath)) {
   while (false !== ($file = readdir($handle))) {
   if ($file != '.' && $file != '..')
   $results[] = $file;

         }
      }
   closedir($handle);
?>

Echo array as <option> list:

<?php
$results = str_replace(" ", " ", $results);

foreach ($results as $key => $value)
{
echo '<OPTION value='.$value.'> '.$value.'';
}
echo '</select>';

?> 
</select>
<input type="submit" value="Git" />
</form>

As you see, the action is to go to process.php:

<?php
$item = $_POST['item'];
?>
<h4>Loading page...</h4>
<meta http-equiv="refresh" content="2;url=DIRECTORY/<?php echo $item ?>" />

And this refreshes the page. At the url you will see http://site.com/DIRECTORY/[selected option]

Instead of this, i want it to be index.php?id=[sELECTED OPTION].

I was thinking it had something to do with $_GET instead of $_POST, but i dont know what else to do from there.

I don't know how else to explain it.. :-[

 

Link to comment
https://forums.phpfreaks.com/topic/142544-page-id/#findComment-748514
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.