scbookz Posted July 31, 2009 Share Posted July 31, 2009 a)i have a list of numbers lets say 10,000 b)i have a function and php code for each number to pull from an html page c)i want to duplicate b) for 10,000 numbers so i have 10,000 pages on the server ------------ i will have ------------------ 1.php 2.php 3.php 4.php 10,000 times, and each page will have the same code, except for one line in each page that corresponds to the number 1 2 3 4 respectively Quote Link to comment Share on other sites More sharing options...
scbookz Posted July 31, 2009 Author Share Posted July 31, 2009 in other words i want to create 10,000 pages all with the same code but one small difference i would like to do this automatically Quote Link to comment Share on other sites More sharing options...
scbookz Posted July 31, 2009 Author Share Posted July 31, 2009 i guess i use this but how do i stop it at 10,000? $ourFileName = "testFile.txt"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted July 31, 2009 Share Posted July 31, 2009 Use for loop. <?php for($i = 0; $i < 10000; $i++) { // Do somthing 10000 times.. } Quote Link to comment Share on other sites More sharing options...
scbookz Posted July 31, 2009 Author Share Posted July 31, 2009 [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /var/www/osc/osc/osc/marksfolder/guess.php on line 7 i cant even open one file much less 10,000 i tried to create a file with a .php file and it gave that error here is my code --------------------------------------------- <?php $ourFileName = "http://xx.xx.xx.xx:81/osc/osc/osc/marksfolder/044651652X.php"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); ?> i did a changemod 777 so it is writeable in that directory maybe i need to change all directories backwards Quote Link to comment Share on other sites More sharing options...
scbookz Posted July 31, 2009 Author Share Posted July 31, 2009 ? Reply Quote Xian Re: HTTP wrapper does not support writeable connections five years ago To try Larry's suggestion, I *think* you would just need to replace $homedirectory with $_SERVER['DOCUMENT_ROOT'] OR possibly realpath($_SERVER['DOCUMENT_ROOT']). Reply Quote Quote Link to comment Share on other sites More sharing options...
scbookz Posted July 31, 2009 Author Share Posted July 31, 2009 ok that worked this code works but no content was created just an empty file <?php $ourFileName = "044651652X.php"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); ?> ------- how do i add content automatically? Quote Link to comment Share on other sites More sharing options...
scbookz Posted July 31, 2009 Author Share Posted July 31, 2009 i am new to php so i am learning as i go i am my own admin for my own server i have created pages .php now i need to now how to add content to the pages i created with the same script Quote Link to comment Share on other sites More sharing options...
scbookz Posted July 31, 2009 Author Share Posted July 31, 2009 will this work? <? $body_content="This is my content"; // Store some text to enter inside the file $file_name="test_file.txt"; // file name $fp = fopen ($file_name, "w"); // Open the file in write mode, if file does not exist then it will be created. fwrite ($fp,$body_content); // entering data to the file fclose ($fp); // closing the file pointer chmod($file_name,0777); // changing the file permission. ?> Quote Link to comment Share on other sites More sharing options...
dadamssg Posted July 31, 2009 Share Posted July 31, 2009 why don't you just create on template php page with certain places for different data to fill in certain spaces. Then just query the database using an id number like yoursite.com/whatever.php?id=3. then your template(whatever.php) will have the information with what your query the database with that number. that way you have ONE page with limitless possibilities of data filling in the gaps. Thats the basic theory with websites that have have a gigabillion different "pages" Quote Link to comment Share on other sites More sharing options...
scbookz Posted July 31, 2009 Author Share Posted July 31, 2009 oh! no someone please explain template page for me Quote Link to comment Share on other sites More sharing options...
dadamssg Posted July 31, 2009 Share Posted July 31, 2009 ok....make your html page with places for data. For this example ill just use a basic table with person's info. so we have <table> <tr><td>Name:</d> <td>?</td> </tr> <tr><td>Gender:</d> <td>?</td> </tr> <tr><td>State:</d> <td>?</td> </tr> </table> and we want a "page" for each person in our database. Well, we'll just replace those three question marks with actual data. So...save this template page as "template.php" or something like that. Now our actual url will end up looking like this "www.yoursite.com/template.php?id=32". What this is saying is go to the template page but use the person whoever has the ID of 32 to fill out the information. So the php would look something similar to this. <?php $id_number = $_GET['id'];//this will get that id number out of the url //then connect to the database $cxn = mysqli_connect($host,$user,$passwd,$dbname) or die("Couldn't connect"); //then write a simple query that will pull up the person's info based on that id number $query = "SELECT * FROM your_table WHERE id_number = '$id_number'"; //run the query $result = mysqli_query($cxn,$query) or die("Couldn't execute select query."); //assign the results to a variable $row = mysqli_fetch_assoc($result); now we go back and add places to insert the data we just pulled up...so go to edit template.php <table> <tr><td>Name:</d> <td><?php echo $row['name']; ?></td> </tr> <tr><td>Gender:</d> <td><?php echo $row['gender']; ?></td> </tr> <tr><td>State:</d> <td><?php echo $row['state']; ?></td> </tr> </table> now...put the php we just wrote at the very top of your html page like so <?php $id_number = $_GET['id'];//this will get that id number out of the variable //then connect to the database $cxn = mysqli_connect($host,$user,$passwd,$dbname) or die("Couldn't connect"); //then write a simple query that will pull up the person's info based on that id number $query = "SELECT * FROM your_table WHERE id_number = '$id_number'"; //run the query $result = mysqli_query($cxn,$query) or die("Couldn't execute select query."); //assign the results to a variable $row = mysqli_fetch_assoc($result); ?> <html> <head></head> <body> <table> <tr><td>Name:</d> <td><?php echo $row['name']; ?></td> </tr> <tr><td>Gender:</d> <td><?php echo $row['gender']; ?></td> </tr> <tr><td>State:</d> <td><?php echo $row['state']; ?></td> </tr> </table> </body> </html> save that as template.php and put it in a directory and go to www.yoursite.com/template.php?id=23.. This script will grab all the info associated with the number 23. NOTE: this assumes your table is called "your_table" and you have fields in the table labeled "name", "gender", "id_number", and "state" 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.