I have a database some short notes in a .txt format file and i have created a php webpage that includes a txt file in html format. Now I have to use "Next" and "Preview" links for that .txt format files.
Can anyone suggest me the php or JavaScript code for that..
I have a suggetion if i name that all short notes files as 1, 2, 3, ... so can i use next and preview by using loop in javascript or php?? Can you suggest me that code?? Please....

kirtan_thakkar
Recommended Answers
Jump to PostLogic:
i) Store the filenames in a Array $fnames=array("1.txt","2.txt","3.txt");
ii) Write the above code in a function with arguments as your filename
iii) on you click on next button call the function by passing the array valueTo process the same page again you can use:
Jump to PostLike
process($fname[0]);
process($fname[1]);
process($fname[2]);
Jump to PostUse following script, nothing more to do. Set your text directory path in currdirectory folder.
<?php $currdirectory="textfilesfolder";//path or your current directory from where you want to show files. i assume all files are text files if($_REQUEST['txtfile']=="") $txtfile=$currdirectory."/1.txt"; else $txtfile=$currdirectory."/".$_REQUEST['txtfile']; $files = scandir($currdirectory); $nextfile=$files[2]; for ($i=0;$i<count($files);$i++) { $content=$currdirectory."/".$files[$i]; …
Jump to PostMy fisrt script was better. it shows all files in your directory in file order. you may user a.txt... like that.
another version given below based on 1,2,3,4 series, which depends on series of number. if suppose 5.txt is not there then below script will fail.
All 13 Replies
urtrivedi 276 Nearly a Posting Virtuoso
vibhaJ 126 Master Poster

kirtan_thakkar

rajarajan2017

kirtan_thakkar

rajarajan2017
urtrivedi 276 Nearly a Posting Virtuoso

kirtan_thakkar

kirtan_thakkar
urtrivedi 276 Nearly a Posting Virtuoso

kirtan_thakkar
urtrivedi 276 Nearly a Posting Virtuoso

kirtan_thakkar
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.