Jump to content

Automatic HTML Creator Help


Nicholas_Roge

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.