tagwall

Tags:    php

halløjsa...

Hvis man nu skal lave en tagwall, og man vil have at det ser ud som her:

<table width="200" border="1">
<tr>
<td width="200" colspan="2">$dato</td>
</tr>
<tr>
<td width="100">$kunstner</td>
<td width="100">$titel</td>
</tr>
</table>

.... Hvordan skal det så skrives i php/mysql ?

echo "<li><table width="200" border="1">"
echo "<tr>"
echo "<td width="200" colspan="2">$dato</td>"
echo "</tr>"
echo "<tr>"
echo "<td width="100">$kunstner</td>"
echo "<td width="100">$titel</td>"
echo "</tr>"
echo "</table>";
}
echo "</ol></font>";
?>

... sådan prøvede jeg, men virker ik ... er lidt ny inden for php :P

Det er fra den artikel kasper har skrevet



4 svar postet i denne tråd vises herunder
1 indlæg har modtaget i alt 3 karma
Sorter efter stemmer Sorter efter dato
Prøv med
echo "<td width=\\"???\\">";
altså, de " som php skal udskrive skal du erstatte med \\"

Thomas Nielsen



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

<html>
<head>
<title>Mine MP3 numre</title>
</head>

<body>
<h3 align="center">Mine mp3 numre</h3><br>
<br>
<?
mysql_connect("localhost","","");
mysql_select_db("");
$query = mysql_query("SELECT * FROM mp3numre ORDER BY id");
echo "<font color=\\"red\\"><ol>";
while($r = mysql_fetch_array($query)) {
$kunstner = $r["kunstner"];
$titel = $r["titel"];
$dato = $r["dato"];
echo "<li><table width="200" border="1">
echo "<tr>
echo "<td width="200" colspan="2">\\"$dato\\"</td>
echo "</tr>
echo "<tr>
echo "<td width="100">\\"$kunstner\\"</td>
echo "<td width="100">\\"$titel\\"</td>
echo "</tr>
echo "</table>;

}
echo "</ol></font>";
?>

</body>
</html>

sådan du mener?

det virker ik, den siger: Parse error: parse error, expecting `','' or `';'' in /usr/disk1/mortenj/mp3er.php on line 20






Du skal stadig have " til sidst. Grunden til, at man bruge backslash før er, at PHP så skal "escape" det efterfølgende tegn...

/*
Mikl
mikl@mikl.dk
www.mikl.dk

"Livet er for kort til ASP"

ICQ:
Stationære: 133439986
Bærbare: 159096501
*/



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

<html>
<head>
<title>Mine MP3 numre</title>
</head>

<body>
<h3 align="center">Mine mp3 numre</h3>

<?
mysql_connect("localhost","","");
mysql_select_db("");
$query = mysql_query("SELECT * FROM mp3numre ORDER BY id");
echo "<font color=\\"red\\"><ol>";
while($r = mysql_fetch_array($query)) {
$kunstner = $r["kunstner"];
$titel = $r["titel"];
$dato = $r["dato"];
echo "<li><table width="200" border="1">
echo "<tr>
echo "<td width="200" colspan="2">\\"$dato\\"</td>
echo "</tr>
echo "<tr>
echo "<td width="100">\\"$kunstner\\"</td>
echo "<td width="100">\\"$titel\\"</td>
echo "</tr>
echo "</table>;

}
echo "</ol></font>";
?>

</body>
</html>

sådan du mener?

det virker ik, den siger: Parse error: parse error, expecting `','' or `';'' in /usr/disk1/mortenj/mp3er.php on line 20



Koden skal se sådan her ud:

<pre>
<html>
<head>
<title>Mine MP3 numre</title>
</head>

<body>
<h3 align="center">Mine mp3 numre</h3>

<?
mysql_connect("localhost","","");
mysql_select_db("");
$query = mysql_query("SELECT * FROM mp3numre ORDER BY id");
echo "<font color=\\"red\\"><ol>";
while($r = mysql_fetch_array($query)) {
$kunstner = $r["kunstner"];
$titel = $r["titel"];
$dato = $r["dato"];
echo "<li><table width=\\"200" border=\\"1\\">";
echo "<tr>";
echo "<td width=\\"200\\" colspan=\\"2\\">$dato</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\\"100">$kunstner</td>";
echo "<td width=\\"100\\">$titel</td>";
echo "</tr>";
echo "</table>";

}
echo "</ol></font>";
?>

</body>
</html>
</pre>

prøv det...



t