xsorifc28 Posted January 26, 2009 Share Posted January 26, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/142544-page-id/ Share on other sites More sharing options...
work_it_work Posted January 26, 2009 Share Posted January 26, 2009 you have to be more explicit, and eventually show an example ... Quote Link to comment https://forums.phpfreaks.com/topic/142544-page-id/#findComment-747013 Share on other sites More sharing options...
Maq Posted January 26, 2009 Share Posted January 26, 2009 Can you post the relevant code, it would make life easier Quote Link to comment https://forums.phpfreaks.com/topic/142544-page-id/#findComment-747027 Share on other sites More sharing options...
xsorifc28 Posted January 28, 2009 Author Share Posted January 28, 2009 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.. Quote Link to comment https://forums.phpfreaks.com/topic/142544-page-id/#findComment-748514 Share on other sites More sharing options...
xsorifc28 Posted February 1, 2009 Author Share Posted February 1, 2009 Bump :-\ Quote Link to comment https://forums.phpfreaks.com/topic/142544-page-id/#findComment-752051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.