Jump to content

Page ID


xsorifc28

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

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.