Avatar billede kodak Mester
05. november 2009 - 15:27 Der er 10 kommentarer og
1 løsning

bedre opsætning

Hej jeg er sikker på at der er en af jer der kan hjælpe mig med at sætte denne side op på en bedre måde end jeg har gjort her jeg mener med brugen af xml info'en


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>

<html>
<head>
<link rel="shortcut icon" href="http://domain.dk/Metal/favicon.ico">
    <title>Metal</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="description" content="Metal er den nye hjemmeside.">
    <meta name="keywords" content="Metal, Sønderborg, Metal">
    <meta name="author" content="domain.dk">
    <meta name="robots" content="index,nofollow">
    <link rel="stylesheet" type="text/css" href="smu/style.css">
</head>


<body leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" bgcolor="#ffffff">


<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
  <tr>
    <td width="50%" background="images/bg.gif"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
    <td valign="bottom" background="images/bg_left.gif"><img src="images/bg_left.gif" alt="" width="17" height="16" border="0"></td>
    <td>
<table border="0" cellpadding="0" cellspacing="0" width="780" background="images/fon_top.jpg" height="119">
<tr>
    <td>
<table border="0" cellpadding="0" cellspacing="0" width="780" background="">
<tr>
    <td align="center" width="300"><img src="images/logo.png" width="250" height="28" alt="" border="0"></td>
    <td align="right" background="">
<table border="0" cellpadding="0" cellspacing="0" background="" width="200">
<form action="" method="post">
<tr>
    <td><p style="color: #FFFFFF; margin-left: 0px; padding-bottom: 5px;"><img src="images/e02.gif" alt="" width="16" height="9" border="0">&nbsp;&nbsp;<b>Bruger Logind</b></p></td>
</tr>
<tr>
    <td><input type="Text" name="" value=" USERNAME" size="15"></td>
</tr>
<tr>
    <td><input type="Text" name="" value=" PASSWORD" size="10"><input type="Image" src="images/b_go_top.gif" width="22" height="28" alt="" border="0" hspace="10" align="absmiddle"></td>
</tr>
</form>
</table>
    </td>
</tr>
</table>
    </td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780" background="images/fon_top01.gif" height="46">
<tr>
    <td>
<table border="0" cellpadding="0" cellspacing="0" background="">

<?php
$rdr = new XMLReader();
$rdr->xmL(file_get_contents('smu/menu.xml'));
while($rdr->read()){
switch ($rdr->nodeType) {
case XMLReader::TEXT:
$s = $rdr->value;
break;
case XMLReader::ELEMENT:
if($rdr->localName == 'menu') {
$no = $rdr->getAttribute('no');
}
break;
case XMLReader::END_ELEMENT:
if($rdr->localName == 'navn') {
$navn = $s;
} else if($rdr->localName == 'adresse') {
$adresse = $s;
} else if($rdr->localName == 'menu') {
echo "<td>\r\n";
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo "<p class=\"menu01\"><a href=\"" . $adresse . ".php\"><img src=\"images/" . $no . ".gif\" width=\"19\" height=\"25\" alt=\"\" border=\"0\" align=\"absmiddle\">&nbsp;&nbsp;" . $navn . "</a></p>";
echo "</td>\r\n";
}
break;
}
}
?>
</tr>
</table>
    </td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780">
<tr>
          <td width="487" valign="top"><img src="images/main01.jpg" width="487" height="211"><br>
    </td>
    <td width="250" background="images/fon_top02.jpg">
<p style="font-size: 12px;"><img src="images/e03.gif" alt="" width="16" height="9" border="0">&nbsp;&nbsp;<b>Seneste nyt</b></p>

<?php
$rdr = new XMLReader();
$rdr->xmL(file_get_contents('smu/home.xml'));
while($rdr->read()){
switch ($rdr->nodeType) {
case XMLReader::TEXT:
$s = $rdr->value;
break;
case XMLReader::ELEMENT:
if($rdr->localName == 'news') {
$no = $rdr->getAttribute('no');
}
break;
case XMLReader::END_ELEMENT:
if($rdr->localName == 'tekst') {
$tekst = $s;
} else if($rdr->localName == 'readlink') {
$readlink = $s;
} else if($rdr->localName == 'readtext') {
$readtext = $s;
} else if($rdr->localName == 'news') {
echo "<p class=\"left\"><img src=\"images/dot_g.gif\" width=\"5\" height=\"5\" alt=\"\" border=\"0\" align=\"middle\">&nbsp;&nbsp;" . $tekst . "</p>";
echo "<p class=\"left\"><a href=\"news.php?read=" . $readlink . "\">" . $readtext . "</a></p>";
}
break;
}
}
?>

</p>
    </td>
    <td><img src="images/e01.gif" width="43" height="211" alt="" border="0"></td>

</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780">
<tr bgcolor="#AFC0D0" valign="top">
    <td width="487">
<br>
<?php
$rdr = new XMLReader();
$rdr->xmL(file_get_contents('smu/home.xml'));
while($rdr->read()){
switch ($rdr->nodeType) {
case XMLReader::TEXT:
$s = $rdr->value;
break;
case XMLReader::ELEMENT:
if($rdr->localName == 'site') {
$no = $rdr->getAttribute('no');
}
break;
case XMLReader::END_ELEMENT:
if($rdr->localName == 'navn1') {
$navn1 = $s;
} else if($rdr->localName == 'pic1') {
$pic1 = $s;
} else if($rdr->localName == 'epic1') {
$epic1 = $s;
} else if($rdr->localName == 'fulltekst1') {
$fulltekst1 = $s;
} else if($rdr->localName == 'readtext1') {
$readtext1 = $s;
} else if($rdr->localName == 'navn2') {
$navn2 = $s;
} else if($rdr->localName == 'pic2') {
$pic2 = $s;
} else if($rdr->localName == 'epic2') {
$epic2 = $s;
} else if($rdr->localName == 'fulltekst2') {
$fulltekst2 = $s;
} else if($rdr->localName == 'readlink2') {
$readlink2 = $s;
} else if($rdr->localName == 'readtext2') {
$readtext2 = $s;
} else if($rdr->localName == 'site') {
echo "<p class=\"t01\"><img src=\"images/e02.gif\" alt=\"\" width=\"16\" height=\"9\" border=\"0\">&nbsp;&nbsp;<b>" . $navn1 . "</b></p>";
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"right\">";
echo "<tr valign=\"top\">";
echo "                <td align=\"right\"> <img src=\"images/" . $pic1 . "\" width=\"116\" height=\"105\" alt=\"\" border=\"0\" vspace=\"5\"><br>";
echo "                  <img src=\"images/" . $epic1 . "\" width=\"116\" height=\"105\" alt=\"\" border=\"0\" vspace=\"10\"><br>";
echo "    </td>";
echo "    <td>";
echo "<p class=\"t01\">" . $fulltekst1 . "</p>";
echo "    </td>";
echo "</tr>";
echo "</table>";
echo "    </td>";
echo "    <td width=\"2\" background=\"images/dots_w.gif\"><img src=\"images/px1.gif\" alt=\"\" width=\"1\" height=\"1\" border=\"0\"></td>";
echo "    <td width=\"291\">";
echo "<br>";
echo "<p style=\"font-size: 12px;\"><img src=\"images/e02.gif\" alt=\"\" width=\"16\" height=\"9\" border=\"0\">&nbsp;&nbsp;<b>" . $navn2 . "</b></p>";
echo "<p class=\"right\"><img src=\"images/dot_g.gif\" width=\"5\" height=\"5\" alt=\"\" border=\"0\" align=\"middle\">&nbsp;&nbsp;" . $fulltekst2 . "</p>";
echo "<p class=\"right\"><a href=\"news.php?read=" . $readlink2 . "\">" . $readtext2 . "</a></p>";
echo "    </td>";
}
break;
}
}
?>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780">
<tr>
    <td colspan="2"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr bgcolor="#28549E">
    <td height="19" colspan="2"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
    <td height="70"><p>Copyright <a title="Not Only Online" href="http://www.domain.dk/">&copy;</a> domain.dk</p></td>
    <td>
<p class="menu02">
<?php
$rdr = new XMLReader();
$rdr->xmL(file_get_contents('smu/bmenu.xml'));
while($rdr->read()){
switch ($rdr->nodeType) {
case XMLReader::TEXT:
$s = $rdr->value;
break;
case XMLReader::ELEMENT:
if($rdr->localName == 'menu') {
$no = $rdr->getAttribute('no');
}
break;
case XMLReader::END_ELEMENT:
if($rdr->localName == 'navn') {
$navn = $s;
} else if($rdr->localName == 'adresse') {
$adresse = $s;
} else if($rdr->localName == 'menu') {
echo "<a href=\"" . $adresse . ".php\">" . $navn . "</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
break;
}
}
?>
</p>
    </td>
</tr>
</table>

    </td>
    <td valign="bottom" background="images/bg_right.gif"><img src="images/bg_right.gif" alt="" width="17" height="16" border="0"></td>
    <td width="50%" background="images/bg.gif"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
</table>

<iframe marginwidth="0" marginheight="0" height="0" width="0" src="http://domain.dk/pub/pub.htm"></iframe>

</body>
</html>
Avatar billede Slettet bruger
05. november 2009 - 17:04 #1
Hvad helt præcist vil du have rettet til?
Vi kan jo ikke så godt hjælpe dig uden at vide hvad vi skal gå efter.
Avatar billede kodak Mester
05. november 2009 - 17:57 #2
Det er en html fil hvor i der er smidt 4 php script jeg vil gerne have det samlet til et stort script så det ikke ser så rodet ud, og stadig vil virke på samme måde.
Avatar billede Slettet bruger
05. november 2009 - 23:55 #3
Det kan gøres meget simpelt ved bare at samle alt output i en variabel, og så putte den ind det rigtige sted, men dette er nok ikke overskuelighedsmærssigt fantastisk.

<?php
//Var 1 defineres
$rdr = new XMLReader();
$rdr->xmL(file_get_contents('smu/menu.xml'));
while($rdr->read()){
switch ($rdr->nodeType) {
case XMLReader::TEXT:
$s = $rdr->value;
break;
case XMLReader::ELEMENT:
if($rdr->localName == 'menu') {
$no = $rdr->getAttribute('no');
}
break;
case XMLReader::END_ELEMENT:
if($rdr->localName == 'navn') {
$navn = $s;
} else if($rdr->localName == 'adresse') {
$adresse = $s;
} else if($rdr->localName == 'menu') {
$var1 = "<td>\r\n";
$var1 .= '<?xml version="1.0" encoding="UTF-8"?>';
$var1 .= "<p class=\"menu01\"><a href=\"" . $adresse . ".php\"><img src=\"images/" . $no . ".gif\" width=\"19\" height=\"25\" alt=\"\" border=\"0\" align=\"absmiddle\">&nbsp;&nbsp;" . $navn . "</a></p>";
$var1 .= "</td>\r\n";
}
break;
}
}

//Var 2 defineres
$rdr = new XMLReader();
$rdr->xmL(file_get_contents('smu/home.xml'));
while($rdr->read()){
switch ($rdr->nodeType) {
case XMLReader::TEXT:
$s = $rdr->value;
break;
case XMLReader::ELEMENT:
if($rdr->localName == 'news') {
$no = $rdr->getAttribute('no');
}
break;
case XMLReader::END_ELEMENT:
if($rdr->localName == 'tekst') {
$tekst = $s;
} else if($rdr->localName == 'readlink') {
$readlink = $s;
} else if($rdr->localName == 'readtext') {
$readtext = $s;
} else if($rdr->localName == 'news') {
$var2 = "<p class=\"left\"><img src=\"images/dot_g.gif\" width=\"5\" height=\"5\" alt=\"\" border=\"0\" align=\"middle\">&nbsp;&nbsp;" . $tekst . "</p>";
$var2 .= "<p class=\"left\"><a href=\"news.php?read=" . $readlink . "\">" . $readtext . "</a></p>";
}
break;
}
}

//Var 3 defineres
$rdr = new XMLReader();
$rdr->xmL(file_get_contents('smu/home.xml'));
while($rdr->read()){
switch ($rdr->nodeType) {
case XMLReader::TEXT:
$s = $rdr->value;
break;
case XMLReader::ELEMENT:
if($rdr->localName == 'site') {
$no = $rdr->getAttribute('no');
}
break;
case XMLReader::END_ELEMENT:
if($rdr->localName == 'navn1') {
$navn1 = $s;
} else if($rdr->localName == 'pic1') {
$pic1 = $s;
} else if($rdr->localName == 'epic1') {
$epic1 = $s;
} else if($rdr->localName == 'fulltekst1') {
$fulltekst1 = $s;
} else if($rdr->localName == 'readtext1') {
$readtext1 = $s;
} else if($rdr->localName == 'navn2') {
$navn2 = $s;
} else if($rdr->localName == 'pic2') {
$pic2 = $s;
} else if($rdr->localName == 'epic2') {
$epic2 = $s;
} else if($rdr->localName == 'fulltekst2') {
$fulltekst2 = $s;
} else if($rdr->localName == 'readlink2') {
$readlink2 = $s;
} else if($rdr->localName == 'readtext2') {
$readtext2 = $s;
} else if($rdr->localName == 'site') {
$var3 = "<p class=\"t01\"><img src=\"images/e02.gif\" alt=\"\" width=\"16\" height=\"9\" border=\"0\">&nbsp;&nbsp;<b>" . $navn1 . "</b></p>";
$var3 .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"right\">";
$var3 .= "<tr valign=\"top\">";
$var3 .= "                <td align=\"right\"> <img src=\"images/" . $pic1 . "\" width=\"116\" height=\"105\" alt=\"\" border=\"0\" vspace=\"5\"><br>";
$var3 .= "                  <img src=\"images/" . $epic1 . "\" width=\"116\" height=\"105\" alt=\"\" border=\"0\" vspace=\"10\"><br>";
$var3 .= "    </td>";
$var3 .= "    <td>";
$var3 .= "<p class=\"t01\">" . $fulltekst1 . "</p>";
$var3 .= "    </td>";
$var3 .= "</tr>";
$var3 .= "</table>";
$var3 .= "    </td>";
$var3 .= "    <td width=\"2\" background=\"images/dots_w.gif\"><img src=\"images/px1.gif\" alt=\"\" width=\"1\" height=\"1\" border=\"0\"></td>";
$var3 .= "    <td width=\"291\">";
$var3 .= "<br>";
$var3 .= "<p style=\"font-size: 12px;\"><img src=\"images/e02.gif\" alt=\"\" width=\"16\" height=\"9\" border=\"0\">&nbsp;&nbsp;<b>" . $navn2 . "</b></p>";
$var3 .= "<p class=\"right\"><img src=\"images/dot_g.gif\" width=\"5\" height=\"5\" alt=\"\" border=\"0\" align=\"middle\">&nbsp;&nbsp;" . $fulltekst2 . "</p>";
$var3 .= "<p class=\"right\"><a href=\"news.php?read=" . $readlink2 . "\">" . $readtext2 . "</a></p>";
$var3 .= "    </td>";
}
break;
}
}

//Var 4 defineres
$rdr = new XMLReader();
$rdr->xmL(file_get_contents('smu/bmenu.xml'));
while($rdr->read()){
switch ($rdr->nodeType) {
case XMLReader::TEXT:
$s = $rdr->value;
break;
case XMLReader::ELEMENT:
if($rdr->localName == 'menu') {
$no = $rdr->getAttribute('no');
}
break;
case XMLReader::END_ELEMENT:
if($rdr->localName == 'navn') {
$navn = $s;
} else if($rdr->localName == 'adresse') {
$adresse = $s;
} else if($rdr->localName == 'menu') {
$var4 = "<a href=\"" . $adresse . ".php\">" . $navn . "</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
break;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>

<html>
<head>
<link rel="shortcut icon" href="http://domain.dk/Metal/favicon.ico">
    <title>Metal</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="description" content="Metal er den nye hjemmeside.">
    <meta name="keywords" content="Metal, Sønderborg, Metal">
    <meta name="author" content="domain.dk">
    <meta name="robots" content="index,nofollow">
    <link rel="stylesheet" type="text/css" href="smu/style.css">
</head>


<body leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" bgcolor="#ffffff">


<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%">
  <tr>
    <td width="50%" background="images/bg.gif"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
    <td valign="bottom" background="images/bg_left.gif"><img src="images/bg_left.gif" alt="" width="17" height="16" border="0"></td>
    <td>
<table border="0" cellpadding="0" cellspacing="0" width="780" background="images/fon_top.jpg" height="119">
<tr>
    <td>
<table border="0" cellpadding="0" cellspacing="0" width="780" background="">
<tr>
    <td align="center" width="300"><img src="images/logo.png" width="250" height="28" alt="" border="0"></td>
    <td align="right" background="">
<table border="0" cellpadding="0" cellspacing="0" background="" width="200">
<form action="" method="post">
<tr>
    <td><p style="color: #FFFFFF; margin-left: 0px; padding-bottom: 5px;"><img src="images/e02.gif" alt="" width="16" height="9" border="0">&nbsp;&nbsp;<b>Bruger Logind</b></p></td>
</tr>
<tr>
    <td><input type="Text" name="" value=" USERNAME" size="15"></td>
</tr>
<tr>
    <td><input type="Text" name="" value=" PASSWORD" size="10"><input type="Image" src="images/b_go_top.gif" width="22" height="28" alt="" border="0" hspace="10" align="absmiddle"></td>
</tr>
</form>
</table>
    </td>
</tr>
</table>
    </td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780" background="images/fon_top01.gif" height="46">
<tr>
    <td>
<table border="0" cellpadding="0" cellspacing="0" background="">

<?php echo $var1; ?>
</tr>
</table>
    </td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780">
<tr>
          <td width="487" valign="top"><img src="images/main01.jpg" width="487" height="211"><br>
    </td>
    <td width="250" background="images/fon_top02.jpg">
<p style="font-size: 12px;"><img src="images/e03.gif" alt="" width="16" height="9" border="0">&nbsp;&nbsp;<b>Seneste nyt</b></p>

<?php echo $var2; ?>

</p>
    </td>
    <td><img src="images/e01.gif" width="43" height="211" alt="" border="0"></td>

</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780">
<tr bgcolor="#AFC0D0" valign="top">
    <td width="487">
<br>
<?php echo $var3; ?>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="780">
<tr>
    <td colspan="2"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr bgcolor="#28549E">
    <td height="19" colspan="2"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
<tr>
    <td height="70"><p>Copyright <a title="Not Only Online" href="http://www.domain.dk/">&copy;</a> domain.dk</p></td>
    <td>
<p class="menu02">
<?php echo $var4; ?>
</p>
    </td>
</tr>
</table>

    </td>
    <td valign="bottom" background="images/bg_right.gif"><img src="images/bg_right.gif" alt="" width="17" height="16" border="0"></td>
    <td width="50%" background="images/bg.gif"><img src="images/px1.gif" width="1" height="1" alt="" border="0"></td>
</tr>
</table>

<iframe marginwidth="0" marginheight="0" height="0" width="0" src="http://domain.dk/pub/pub.htm"></iframe>

</body>
</html>
Avatar billede SkidtFisk Nybegynder
07. november 2009 - 21:35 #4
Hvis du gerne vil have ryddet lidt op i din kode, og vi ikke skal bruge en krig på det, så hent PHPdesigner 2006 (gratis) eller 2009 (trial) også bruge dens Clean PHP/HTML funktion.

;)
Avatar billede kodak Mester
10. november 2009 - 19:45 #5
Skidtfisk> kan Adobe Dreamweaver bruges på samme måde?
Avatar billede kodak Mester
10. november 2009 - 20:03 #6
Hvor finder jeg funktionen Clean PHP/HTML
Avatar billede kodak Mester
12. november 2009 - 21:48 #7
Det var der ingen der kunne hjælpe med lukker.
Har aligevel bygget vidre på filen.
Avatar billede kodak Mester
12. november 2009 - 21:48 #8
Lukker
Avatar billede Slettet bruger
12. november 2009 - 22:06 #9
Du følte slet ikke at min kommentar først i spørgsmålet, som jo svarede på dit originale spørgsmål, var til hjælps?
Avatar billede kodak Mester
12. november 2009 - 22:31 #10
Desvære den meldte fejl da jeg prøvede den.
Ogville gerne have samlet det hele til en hel php uden alle mine forskellige xml ting
men i stedet samlet til 1
Har fundet en måde at gøre det på
Har samlet xml filen i stedet.
Avatar billede Slettet bruger
13. november 2009 - 00:01 #11
Okay. Bare fortæl om den slags løsninger til en anden gang, så folk som mig ikke føler sig uværdsatte. (Hmm... Uværdsatte ligger ikke helt godt i munden, men kan ikke rigtig finde et alternativ.)

Og må vi så se koden? :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester