Nicholas_Roge Posted August 31, 2008 Share Posted August 31, 2008 Okay, I'm trying to make a PHP script that will alow me to enter information for a manga (i.e.: How many pages it has, chapters, etc...) and from that information, it will create HTML pages equal to the number of pages it has. Now the problem I seem to be running into, is that It will create the first page perfectly, but the second and subsequent pages will be created without the list values being there. Another problem I'm having, is that down near the bottom, when it's creating the onClick javascript code for the "Next Page" button, on the last page it shouldn't have anything in between the parenthesis, but before that, it should have the page number. The problem is, it doesn't put the page number at all. The same goes for the "Previous Page" button, but instead it doesn't put any numbers in the parenthesis after the first page. The code for the page with the forms entitled mangaCreatorForm.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <form action="mangaCreator.php" method="get"> What Manga is this for: <input type="text" name="mangaName" /><br /> What chapter is this for: <input type="text" name="chapNum" /><br /> How many Chapters are there TOTAL: <input type="text" name="chapVal" /><br /> What volume is this: <input type="text" name="volNum" /><br /> How many volumes are there TOTAL: <input type="text" name="volVal" /><br /> How many pages are there: <input type="text" name="pageNum" /><br /> <input type="submit" name="Submit" value="Submit"/> </form> <body> </body> </html> And the and the second page entitled mangaCreator.php (it's probably really unstructured, so don't give yourself a headache looking at it): <?php $i1 = 0; $i2 = 0; $i3 = 0; $i4 = 0; while ($i1<$pageNum){ $i1++; /* $thisdir = getcwd(); if(mkdir($thisdir ."/testDocs" , 0777)) { echo "Directory has been created successfully..."; } else { echo "Failed to create directory..."; } */ //Write to file $ourFileName = testDocs."/".page.$i1.".".html; $fh = fopen($ourFileName, 'w') or die("Can't open file"); //What to write $stringData = ' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>'; fwrite($fh, $stringData); if ($chapNum=="Cover" || $chapNum=="cover"){ $stringData = $mangaName.': Volume '.$volNum.' Cover - Page '.$i1; fwrite($fh, $stringData); }else{ $stringData = $mangaName.': Chapter '.$chapNum.' Page '.$i1; fwrite($fh, $stringData); } $stringData = ' </title> <body> <link rel="stylesheet" type="text/css" href="../../../Javascript+Others/CSS.css"/> </head> <script type="text/javascript" src="../../../Javascript+Others/javascript.js"></script> <body id="body"> <table id="navBarTable"> <tr> <td id="navBar"><span class="navBarHyperlink"> <a href="../../../MangaIndex.html">Home</a><span class="style3"> | </span><a href="../../../../Index.html">Back to Index Page</a></span></td> <td id="dropDownBar1" align="right"> <select name="mangaSelect" id="mangaSelect" onChange=window.location="../../../"+this.value> <option value="" selected="selected">Select Manga Series...</option> <option value="+Anima/Volume1/Cover/page01.html">+Anima</option> <option value="Digimon_D-Cyber/Volume1/Cover/page01.html">Digimon D-Cyber</option> <option value="Flame_of_Recca/Volume1/Chapter1/page01.html">Flame of Recca</option> <option value="Kashimashi/Volume1/Cover/cover.html">Kashimashi</option> </select> </td> </tr> </table> <br /> <div align="center"><span class="style1">'; fwrite($fh, $stringData); if ($chapNum=="Cover" || $chapNum=="cover"){ $stringData = 'Volume '.$volNum.' Cover - Page '.$i1; fwrite($fh, $stringData); }else{ $stringData = 'Chapter '.$chapNum.' - Page '.$i1; fwrite($fh, $stringData); } $stringData = '</span><br /> <strong>Skip to:</strong> <select name="chapterSelect" id="chapterSelect" onChange=window.location="../"+this.value+"/page01.html">'; fwrite($fh, $stringData); while ($i2 < $volVal){ $i2++; $stringData = ' <option value="Volume'.$i2.'Cover"'; fwrite($fh, $stringData); if ($chapNum=="Cover" || $chapNum=="cover"){ if ($i2==$volNum){ $stringData = ' selected'; fwrite($fh, $stringData); } } $stringData = '>Volume '.$i2.' Cover</option>'; fwrite($fh, $stringData); } while ($i3 < $chapVal){ $i3++; $stringData = ' <option value="Chapter'.$i3.'"'; fwrite($fh, $stringData); if (is_int($chapNum)){ if ($i3==$chapNum){ $stringData = ' selected '; fwrite($fh, $stringData); } } $stringData = '>Chapter '.$i3.'</option>'; fwrite($fh, $stringData); } $stringData = ' </select> <select name="pageSelect" id="pageSelect" onChange=window.location="page"+this.value+".html">'; fwrite($fh, $stringData); while($i4<$pageNum){ $i4++; $stringData = ' <option value="'.$i4.'"'; fwrite($fh, $stringData); if ($i4==$i1){ $stringData = ' selected'; fwrite($fh, $stringData); } $stringData = '>Page '.$i4.'</option>'; fwrite($fh, $stringData); } $stringData = ' </select> </div> <br /> <div align="center"> <img src="Images/'; fwrite($fh, $stringData); $stringData = $i1; fwrite($fh, $stringData); $stringData = '.png" /> </div><br /> <div align="center"> <input type="submit" name="buttonPrevious" id="buttonPrevious" value="Previous Page" onClick="previousPage('; fwrite($fh, $stringData); if (!$i1==1){ $stringData = $i1; fwrite($fh, $stringData); } $stringData = ');"/> <input type="submit" name="buttonNext" id="buttonNext" value="Next Page" onClick="nextPage('; fwrite($fh, $stringData); if (!$i1==$pageNum){ $stringData = $i1; fwrite($fh, $stringData); } $stringData = ' );"/></div> <div id="copyrights">All Manga, Character Designs and Logos are © to their respective copyright holders.</div> </body> </html>'; fwrite($fh, $stringData); fclose($fh); } ?> <a href="testDocs/page1.html"> Test </a> Here's the link to the first page the creator outputs: http://wishlist.digitalawakening.co.cc/PHPTest/testDocs/page1.html . Thank you for your time, and if you need me to re-explain anything, just ask. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/ Share on other sites More sharing options...
Nicholas_Roge Posted August 31, 2008 Author Share Posted August 31, 2008 Sorry, accidentaly hit quote instead of edit, and I can't seem to find the delete button. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630406 Share on other sites More sharing options...
Guest Xanza Posted August 31, 2008 Share Posted August 31, 2008 Look into pagination, and please please please please for gods sake think up more reasonable filenames for your scripts... NEVER use capital letters in script filenames, let alone make them so long. When you want to make a config script you name it: config.php, or inc.config.php; never include_configuration.php, or configuration.php... It just makes things more difficult. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630469 Share on other sites More sharing options...
cooldude832 Posted August 31, 2008 Share Posted August 31, 2008 Look into pagination, and please please please please for gods sake think up more reasonable filenames for your scripts... NEVER use capital letters in script filenames, let alone make them so long. When you want to make a config script you name it: config.php, or inc.config.php; never include_configuration.php, or configuration.php... It just makes things more difficult. Why if the file name gives a less ambiguous name to the file it isn't a problem? Some times you have multiple config files like config_mysql_db1.php config_mysql_db2.php config_postrql_db1.php constants.php arrays_states.php arrays_countries.php I rather have a very clear name than an unclear short one. include_configuration.php might mean it needs to be included where a file configuration.php might only be included in certain parts so they could be different. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630472 Share on other sites More sharing options...
Guest Xanza Posted August 31, 2008 Share Posted August 31, 2008 It's all a part of good conventions... In the long run every programmer is going to do what they please - despite ridicule from others; which is fine... But still. If you ever start to release your scripts for public usage you're going to have to change your tune - or no one is going to use your scripts. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630591 Share on other sites More sharing options...
Nicholas_Roge Posted August 31, 2008 Author Share Posted August 31, 2008 It's all a part of good conventions... In the long run every programmer is going to do what they please - despite ridicule from others; which is fine... But still. If you ever start to release your scripts for public usage you're going to have to change your tune - or no one is going to use your scripts. That's perfectly understandable. I've never been very creative in my naming conventions, but I do see what you're saying. But as cooldude832 said, I would rather have an easily understandable script that I have to do a little more work on, than one that every time I go into it I have to re-decipher it. I have a bad memory. Edit: I am confused though, as to why you wanted me to look into pagination. Doesn't that have to do with things like the number of threads in a forum board? Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630594 Share on other sites More sharing options...
cooldude832 Posted August 31, 2008 Share Posted August 31, 2008 It's all a part of good conventions... In the long run every programmer is going to do what they please - despite ridicule from others; which is fine... But still. If you ever start to release your scripts for public usage you're going to have to change your tune - or no one is going to use your scripts. If you bundle a scrip for public sale then the names of your configs and includes should be even more specific to it like mysweetscript_mysql_config.php that way it doesn't interfer with an ambiguous server script name. But we are deviating from the OP request which I don't know if its solved? Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630597 Share on other sites More sharing options...
Nicholas_Roge Posted August 31, 2008 Author Share Posted August 31, 2008 Unfortunately, no, it hasn't been solved. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630607 Share on other sites More sharing options...
cooldude832 Posted August 31, 2008 Share Posted August 31, 2008 The problem is your logic is making you work extremly hard when a database can achieve this very easier what you need to do is insert the data into mysql into 2 tables 1) Books 2) Pages Books has a strucutre like BookID Title Author etc. Pages has a structure of PageID BookID Pagenum (1,2,3 in the book) Content (the page's html content area) And then u have a single page to view all books/pages and you have urls like www.mysite.com/view_book.php?book=15&page=3 Then you query the Page's table for Page 3 of Book 15 and you have its content no need to make individual html documents. The pagination portion is how you shift between pages but it is minimal in this case. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630611 Share on other sites More sharing options...
Nicholas_Roge Posted August 31, 2008 Author Share Posted August 31, 2008 I see your point, but the problem is that I'm actually making this for use on the PSP's browser to make it a more efficient manga viewer. As you can imagine, having to go in a use the find and replace function in Dreamweaver can be very time consuming. Just in case you don't already know, a lot of PHP functions don't work with the PSP. Not only that, but the PSP doesn't have a MySQL database. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630614 Share on other sites More sharing options...
cooldude832 Posted August 31, 2008 Share Posted August 31, 2008 Didn't see your doing this on your psp. I bet you can find a mod to run WAMP on a psp some how. If u are using the psp in an area always online you can just load it on a server and access the server from your psp Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630622 Share on other sites More sharing options...
Nicholas_Roge Posted August 31, 2008 Author Share Posted August 31, 2008 There are to problems with that: 1. Porting WAMPP to the PSP would require downgrading to official firmware 1.5, and that would require me to buy a JigKick battery and as of now, I am broke. 2. The beauty of using the PSP to view the files offline is that it doesn't take ten minutes to load one page... Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630629 Share on other sites More sharing options...
cooldude832 Posted August 31, 2008 Share Posted August 31, 2008 I'd still go with the db and build everything on a WAMP and then download all the pages to your PSP and take em with you. Update the psp when ever u update the WAMP Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-630631 Share on other sites More sharing options...
Guest Xanza Posted September 3, 2008 Share Posted September 3, 2008 If you look at the botom of this page, even below the reply, notify, mark unread, ext. You'll see: "PHP Freaks Forums > PHP > PHP Help > Topic: Automatic HTML Creator Help" That's technically pagination. But it encompass everything dealing with indexing pages into links. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-632643 Share on other sites More sharing options...
cooldude832 Posted September 3, 2008 Share Posted September 3, 2008 If you look at the botom of this page, even below the reply, notify, mark unread, ext. You'll see: "PHP Freaks Forums > PHP > PHP Help > Topic: Automatic HTML Creator Help" That's technically pagination. But it encompass everything dealing with indexing pages into links. That is technically Not pagination. Pagination is the process of "paging" a result set across mulitple pages so the content length is reasonable for a user to view. A good example of this is google's search results come to you accross multiple pages and u can navigate up/down or to any "page" in the results you want. This is simply a forum there is pagination in the threads when they get over 14 post and they go to 2 pages. But this thread is at 13 so it is only 1 page Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-632728 Share on other sites More sharing options...
Guest Xanza Posted September 3, 2008 Share Posted September 3, 2008 Pagination is the system by which the information on a newspaper, bookpage, manuscript, or otherwise handwritten, printed or displayed document is laid out. In a strict sense of the word, it can mean the consecutive numbering to indicate the proper order of the pages, which was rarely found in documents pre-dating 1500, and only became common practice circa 1550, when it replaced foliation, which numbered only the front sides of folios. Read it, it can mean consecutive numbering, but is not limited to it... So technically it still is pagination. Link to comment https://forums.phpfreaks.com/topic/122098-automatic-html-creator-help/#findComment-632991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.