Posted: Sat Aug 04, 2007 10:06 am
The "bother" was that you were asking without trying.akimm wrote:Sorry. I didn't realize I was being a bother. I will try and write it now.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
The "bother" was that you were asking without trying.akimm wrote:Sorry. I didn't realize I was being a bother. I will try and write it now.
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
read_journal.xml
<CATALOG>
−
<journal>
<content><?php
error_reporting (E_ALL);
$path = "journal/";
foreach(glob($path . "*.txt") as $file) {
$fh = fopen($file, 'r');
$theData = fread($fh, filesize($file));
echo $theData;
fclose($fh);
}
?>
</content>
</journal>
−Code: Select all
<html>
<head>
<script type="text/javascript">
function movenext()
{
x=xmldso.recordset
if (x.absoluteposition < x.recordcount)
{
x.movenext()
}
}
function moveprevious()
{
x=xmldso.recordset
if (x.absoluteposition > 1)
{
x.moveprevious()
}
}
</script>
</head>
<body>
<xml src="journal_read.xml" id="xmldso" async="false"></xml>
<p>
Title:
<span datasrc="#xmldso" datafld="CONTENT"></span>
<br />
</p>
<p>
<input type="button" value="previous entry"
onclick="moveprevious()" />
<input type="button" value="Next entry"
onclick="movenext()" />
</p>
</body>
</html>
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
here is the formCode: Select all
<form action="journalbox.php" method="POST"><p><b>Date</b><input type="text" value="<b><?php echo date('F j, Y, g:i a');?></b>" name="date" size="30"></p><p><b>Mood</b>
<select name="mood"><option value="apathetic">apathetic<option value="overjoyed">overjoyed<option value="inquisitive">inquisitive<option value="outlandish">outlandish<option value="appreciative">appreciative<option value="confused">confused<option value="displeased">displeased<option value="disgruntled">disgruntled<option value="sick">sick<option value="terrified">terrified<option value="mental">mental<option value="eruditic">eruditic<option value="forlorn">forlorn<option value="convuluted">convuluted<option value="ingenious">ingenious<option value="arrogant">arrogant<option value="free">free<option value="stupid">stupid<option value="moronic">moronic<option value="pointless">pointless</select><br /><br />
<select name="smile">
<?php
$files = glob("smile/*.gif");
##Display $files
foreach ($files as $key => $value)
{
echo '<option value="' . $value. '">' . $value . '</option>';
}
?>
</select>
<p><b>entry</b><TEXTAREA NAME="entry" COLS="80" ROWS="5" WRAP="virtual"></TEXTAREA></P><p><input type="submit" name="submit" value="send your entry!"></p></form>Code: Select all
<?php
##this journal, mood, smile, body, & entry are an effort to write to files in XML format
$write_string = "<journal>";
$write_string .= "<date>";
$write_string .= "<b>" . "<font color=#006699>" . "Date posted: " .
"</font>" . "</b>" . $_POST['date'];
$write_string .= "</date>";
$write_string .= "<mood>";
$write_string .= "<font family=arial>"; $write_string .= "<BR>" .
"<BR>";
$write_string .= "<b>" . "<font color=#006699>" . "Current mood: " .
"</font>" . "</b>" . $_POST['mood'];
$write_string .= "</mood>";
$write_string .= "<smile>";
$write_string .= "<font family=arial>";
$write_string .= "<img src=" . $_POST['smile'] . ">" . "<br>" .
"<br>" . "<br>";
$write_string .= "</smile>";
$write_string .= "<entry>";
$write_string .= stripslashes($_POST['entry']) . "<font family=arial>"
. "<BR>" . "<BR>";
$write_string .= "</entry>";
$write_string .= "<HR NOSHADE SIZE=4 COLOR=BLUE>";
$write_string .= "</journal>";
$fp = fopen( 'journal/' . $_POST['mood'] . rand(1, 1000) . '.xml',
'w');
if($fp) {
fwrite($fp, $write_string);
fclose($fp);
}
?>
<h1>Sucessfully posted</h1>
<br><br>
<?php
echo "<b>" . "<font color=#006699>" . "Date posted: " . "</font>" .
"</b>" . $_POST['date'] . "<br>";
echo "<b>" . "<font color=#006699>" . "Current mood: " . "</font>" .
"Current Mood: " . "</b>" . $_POST['mood'] . "<br>";
echo "<img src=" . $_POST['smile'] . ">". "<br>" . "<br>" . "<br>";
echo stripslashes($_POST['entry']) . "<br>";
?>
<br><br>
<a href="http://www.akimm.com/journal06/journal.php">Go To Journal
Sean!</a>Code: Select all
<?php
error_reporting (E_ALL);
$path = "journal/";
foreach(glob($path . "*.xml") as $file) {
$fh = fopen($file, 'r');
$theData = fread($fh, filesize($file));
echo $theData;
fclose($fh);
}
?>Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
$write_string = "<?xml version='1.0' encoding='iso-8859-1' ?>";
$write_string .= "<journal>";
$write_string .= "<date>";
$write_string .= $_POST['date'] . "</date>";
$write_string .= "<mood>" . $_POST['mood'] . "</mood>";
$write_string .= "<smile>" . "<img src=" . $_POST['smile'] . ">" .
"</smile>";
$write_string .= "<entry>" . stripslashes($_POST['entry']) .
"</entry>" . "</journal>";
$fp = fopen( $_POST['mood'] . rand(1, 1000) . '.xml', 'w');
if($fp) {
fwrite($fp, $write_string);
fclose($fp);
}
?>
<h1>Sucessfully posted</h1>
<br><br>
<?php
echo "<b>" . "<font color=#006699>" . "Date posted: " . "</font>" .
"</b>" . $_POST['date'] . "<br>";
echo "<b>" . "<font color=#006699>" . "Current mood: " . "</font>" .
"Current Mood: " . "</b>" . $_POST['mood'] . "<br>";
echo "<img src=" . $_POST['smile'] . ">". "<br>" . "<br>" . "<br>";
echo stripslashes($_POST['entry']) . "<br>";
?>
<br><br>
<a href="http://www.akimm.com/journal06/journal.php">Go To Journal
Sean!</a>Code: Select all
<?php
##variables
$path = "journal/";
foreach(glob($path . "*.xml") as $file) {
$fh = fopen($file, 'r');
$parser = xml_parser_create;
xml_parse($parser, $file);
?>
<html>
<body>
<?php
?>
</body>
</html>
<?php
/* load the xml file and stylesheet as domdocuments */
$xsl = new DomDocument();
$xsl->load("journal.xsl");
$inputdom = new DomDocument();
$inputdom->load($file);
/* create the processor and import the stylesheet */
$proc = new XsltProcessor();
$xsl = $proc->importStylesheet($xsl);
$proc->setParameter(null, "titles", "Titles");
/* transform and output the xml document */
$newdom = $proc->transformToDoc($inputdom);
print $newdom->saveXML();
}
// close after printing
fclose($fh);
xml_parser_free($parser);
?>Code: Select all
<?xml version=”1.0”?>
<xsl:stylesheet version=”1.0” xmlns:xsl=http://www.w3.org/1999/XSL/Transform>
<xsl:template match=”/”>
<html>
<head><title>Sean's Journal</title></head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match=”/journal”>
<xsl:for-each select=”journal”>
date: <b><xsl:value-of select=”date” /></b><br />
current mood: <b><xsl:value-of select=”mood” /></b> <br />
<xsl:value-of select=”smile” /><br />
<xsl:value-of select=”entry” />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>