how to append different text
Posted: Wed Nov 08, 2006 2:13 am
this is the section of the code, which should add to a htm file piece of <html> code, based on the fact, if it's the first line or the second line, third line, etc.
and the names.txt looks like this
the html outcome should end up looking like this:
but the html outcome does not come like this.
either it comes with ID="first-XML-item" on all the items or it does not come with ID="..." whatsoever (ID is bolded).
what should I change in order to get the desired html outcome?

Code: Select all
$fp = fopen('names.txt','r');
$id = "ID=\"first-XML-item\"";
$nf = fopen("c://apache//htdocs//names//start.htm", "a");
while (!feof($fp))
{
$line = fgets($fp, 1024);
list ($name, $namefile) = split ('\;', $line);
echo '
<table>
<tr>
<td>'.$name.'</td>
<td>'.$namefile.'</td>
</tr>
</table>';
if ($line[0] == true)
{
$content2=
"
<DIV CLASS=\"button\" ".$id."
onMouseOver=\"over(this)\"
onMouseOut=\"out(this)\"
onClick='changeXML(\"".$namefile."\"); select(\"xml\",this)'>
".$name."<SPAN CLASS=\"arrow\">4</SPAN>
</DIV>";
}
else
{
$content2=
"
<DIV CLASS=\"button\"
onMouseOver=\"over(this)\"
onMouseOut=\"out(this)\"
onClick='changeXML(\"".$namefile."\"); select(\"xml\",this)'>
".$name."<SPAN CLASS=\"arrow\">4</SPAN>
</DIV>";
}
$fp++;
fwrite ($nf, $content2);
}
fclose($nf);
fclose($fp);Code: Select all
name1;name1.xml
name2;name2.xml
name3;name3.xmlCode: Select all
<DIV CLASS="button" ID="first-XML-item"
onMouseOver="over(this)"
onMouseOut="out(this)"
onClick='changeXML("name1.xml"); select("xml",this)'>
name1<SPAN CLASS="arrow">4</SPAN>
</DIV>
<DIV CLASS="button"
onMouseOver="over(this)"
onMouseOut="out(this)"
onClick='changeXML("name2.xml"); select("xml",this)'>
name2<SPAN CLASS="arrow">4</SPAN>
</DIV>
<DIV CLASS="button"
onMouseOver="over(this)"
onMouseOut="out(this)"
onClick='changeXML("name3.xml"); select("xml",this)'>
name3<SPAN CLASS="arrow">4</SPAN>
</DIV>
but the html outcome does not come like this.
either it comes with ID="first-XML-item" on all the items or it does not come with ID="..." whatsoever (ID is bolded).
what should I change in order to get the desired html outcome?