Posted: Mon Apr 21, 2003 7:17 pm
sorry, I meant it the other way round. Only keep the static part.
The next step is to format the html-code. really take care of it, there are some ..hmm... mistakes in your current output, e.g. there must not be more than one <body>-element in a an HTML-document.

So this is about stripping the php-code down to the wires, reassemble it and then finally re-code it in perl. This might take quite a while (esp. because I don't know how often I'm online in the next few days)
And yes, this is going to be (a bit) pedantic
It's the best I can offer.
The next step is to format the html-code. really take care of it, there are some ..hmm... mistakes in your current output, e.g. there must not be more than one <body>-element in a an HTML-document.
- no offense but this is how your php-script looks like now
Code: Select all
<?php echo "<script type="text/javascript">"; mysql_connect("myhost", "user", "pass") or die("db failed"); ?> function doNothing() { return true; } </script><body><p> <?php $result = mysql_query("SELECT * FROM tbln"); echo '<form action="test.php" method="POST">'; while($row = mysql_fetch_array($result)) echo "<input type=text name=".$result[name]." value=".$result[val].">"; ?> <input type="button" value="click me" onClick="javascript:doNothing();" > </form> </html> - removing everything that is not output-related (for now)
Code: Select all
<?php echo "<script type="text/javascript">"; ?> function doNothing() { return true; } </script><body><p> <?php echo '<form action="test.php" method="POST">'; while($row = mysql_fetch_array($result)) echo "<input type=text name=".$result[name]." value=".$result[val].">"; ?> <input type="button" value="click me" onClick="javascript:doNothing();" > </form> </html> - moving all static echos
Code: Select all
<script type="text/javascript"> function doNothing() { return true; } </script><body><p> <form action="test.php" method="POST"> <?php while($row = mysql_fetch_array($result)) echo "<input type=text name=".$result[name]." value=".$result[val].">"; ?> <input type="button" value="click me" onClick="javascript:doNothing();" > </form> </html> - replacing all remaining php-blocks by an html-comment, describing the result (output)
Code: Select all
<script type="text/javascript"> function doNothing() { return true; } </script><body><p> <form action="test.php" method="POST"> <!-- a while-loop adding an _input text_ element for each record fetched from database --> <input type="button" value="click me" onClick="javascript:doNothing();" > </form> </html> - re-formatting (step 1).
for each opening tag I use one more tab, after each closing tag I use one tab less.Code: Select all
<script type="text/javascript"> function doNothing() { return true; } </script> <body> <p> <form action="test.php" method="POST"> <!-- a while-loop adding an _input text_ element for each record fetched from database --> <input type="button" value="click me" onClick="javascript:doNothing();" > </form> </html> - that doesn't look right, does it?
Code: Select all
<html><!-- there was a closing html-tag, but it was never opened --> <script type="text/javascript"> function doNothing() { return true; } </script> <body> <p> <form action="test.php" method="POST"> <!-- a while-loop adding an _input text_ element for each record fetched from database --> <input type="button" value="click me" onClick="javascript:doNothing();" /><!-- immediate close --> </form> </p><!-- p-element had not closing tag --> </body><!-- body-element had not closing tag --> </html> - there are still some elements missing; common browser do not require all of them, but...
Code: Select all
<html> <head> <title>test</title> <script type="text/javascript"> function doNothing() { return true; } </script> </head> <body> <p> <!-- use html comments to describe php-blocks you have to remove here --> <!-- something like: --> <form action="test.php" method="POST"> <!-- a while-loop adding an _input text_ element for each record fetched from database --> <input type="button" value="click me" onClick="javascript:doNothing();" /> </form> </p> </body> </html>
So this is about stripping the php-code down to the wires, reassemble it and then finally re-code it in perl. This might take quite a while (esp. because I don't know how often I'm online in the next few days)
And yes, this is going to be (a bit) pedantic
It's the best I can offer.