ghaniz786 Posted March 21, 2010 Share Posted March 21, 2010 Hello this is my first post. I am very new to php I have not done any course about scripting I want to know if I want to make a list of files like "list.php" and when i need to call a file i just put in HTML tag <a Href "list.php?id=5>File 5</a> so file should open. Rather than call full file name I wnat to use that ids which was stored in a php file is it possible ? How to do this please help me. Thanks Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted March 21, 2010 Share Posted March 21, 2010 This can be done by using mysql database. You cant store ID's in php file. but you can show content of diffrent ID's on single php file. That is the use of database. Quote Link to comment Share on other sites More sharing options...
inversesoft123 Posted March 21, 2010 Share Posted March 21, 2010 Are you talking about this ? $id= $_GET['ID']; if($id == "1") { echo "Filename : xyz.mp3"; } else if($id == "2") { echo "Filename : abc.mp3"; } else { echo "ID is missing "; } ? Quote Link to comment Share on other sites More sharing options...
ghaniz786 Posted March 21, 2010 Author Share Posted March 21, 2010 Thanks For Reply Yeah I am talk about thing like this but i need full script with example how to link (cal) this. can I call html file with this method ? rather than page.html ? and what if I want to open html in new window (_blank) ? Please help because I have no idea Quote Link to comment Share on other sites More sharing options...
ghaniz786 Posted March 21, 2010 Author Share Posted March 21, 2010 Ooops so have to use mysql database ? but I have no Idea to use that where can learn or get what I want ? any suggestions ? I am not feel shy to ask which I don't know Please someonw help me how create mysql database for files which I want to call by IDs is there any complete example ?. Though someone will laugh on my stupidity but what I don't know I have to ask to seniors. Quote Link to comment Share on other sites More sharing options...
teamatomic Posted March 21, 2010 Share Posted March 21, 2010 list.txt file1.txt file2.html file3.php file4.mp3 list.php?id=x $array=array(); $files=("./files.txt"); $i=1; foreach($files as $file) { $file=trim($file); $array[$i]=$file; $i++; } $id = $_GET['id']; $fn= $array[$id]'; usage $link= "<a href=\"./$fn\">$fn</a>" include("./$fn"); $files_array=file("./$fn"); $file_string=file_get_contents("./$fn"); HTH Teamatomic Quote Link to comment Share on other sites More sharing options...
ghaniz786 Posted March 22, 2010 Author Share Posted March 22, 2010 Thanks for your reply although this example is too hard to understand for me coz I have no idea about php By this Example as far as I understand wwe have to make file list.txt file with the file name with extention then use script php but I could not understand what is the reason of loop ? Quote Link to comment Share on other sites More sharing options...
Bio Posted March 22, 2010 Share Posted March 22, 2010 <?php $page = $_GET['id']; if ($page == "1") { header('Location: http://www.your_url.com/page1.html'); } if ($page == "2") { header('Location: http://www.your_url.com/page2.html'); } if ($page == "3") { header('Location: http://www.your_url.com/page3.html'); } ?> etc.. Quote Link to comment Share on other sites More sharing options...
teamatomic Posted March 22, 2010 Share Posted March 22, 2010 The loop re-indexes the array to start at 1 instead of 0. HTH Teamatomic Quote Link to comment Share on other sites More sharing options...
ghaniz786 Posted March 25, 2010 Author Share Posted March 25, 2010 @ Bio Thanks For Reply Me would you please tell me how to call the file in list I mean <a href "???">file 1</a> Quote Link to comment Share on other sites More sharing options...
Bio Posted March 27, 2010 Share Posted March 27, 2010 It would be something like this... <a href="http://your_url_here/name_of_file.php?id=1">click here for file 1</a> or <a href="http://your_url_here/name_of_file.php?id=2">click here for file 2</a> etc.. If you need any more help dont hesitate to ask. Quote Link to comment Share on other sites More sharing options...
ghaniz786 Posted March 27, 2010 Author Share Posted March 27, 2010 Thanks you Sir for reply, Wow yes I was looking for it Thanks And Alot of best Wishes for You. now i will try to implement this and if I got any error I would ask you. Thanks Again Quote Link to comment 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.