Jump to content

[SOLVED] table in table autocreated


DEVILofDARKNESS

Recommended Posts

Hi I try to make a table inside the html page where $type==info

but I get an error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/uuuq.com/4/a/d/4ade/htdocs/gedichten/test/testgedicht.php on line 25

 

This is line 24 - 30

$text = "<table border = '0'><tr><td colspan='2'><center>Info over dit gedicht: </center></td></tr>
							 <tr><td>Naam Gedicht</td><td><?php echo $row['poem_name']; ?></td></tr>
							 <tr><td>Naam Auteur</td><td><?php echo $row['author_name']; ?></td></tr>
							 <tr><td>Naam Poster</td><td><?php echo $row['user_name']; ?></td></tr>
							 <tr><td>Categorie</td><td><?php echo $row['category_name']; ?></td></tr>
							 <tr><td>Naam Bundel</td><td><?php echo $row['book_name']; ?></td></tr>
		 </table>";

 

This is my whole script:

 

<?php
/* DATABASE SETTINGS */

$test = (int)$_GET["poem_id"];
$type = $_GET["type"];

if(isset($test)) {
	$query= "SELECT p.*, u.*, c.*
  FROM poems p
  INNER JOIN users u ON u.user_id = p.user_id
  INNER JOIN categories c ON c.category_id = p.category_id
  WHERE p.poem_id = '$test'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) :

if($type == "poem") {
$title = $row['poem_name'];
$text = $row['poem_text'];
}elseif($type == "info") {
$title = "INFO";
$text = "<table border = '0'><tr><td colspan='2'><center>Info over dit gedicht: </center></td></tr>
							 <tr><td>Naam Gedicht</td><td><?php echo $row['poem_name']; ?></td></tr>
							 <tr><td>Naam Auteur</td><td><?php echo $row['author_name']; ?></td></tr>
							 <tr><td>Naam Poster</td><td><?php echo $row['user_name']; ?></td></tr>
							 <tr><td>Categorie</td><td><?php echo $row['category_name']; ?></td></tr>
							 <tr><td>Naam Bundel</td><td><?php echo $row['book_name']; ?></td></tr>
		 </table>";
}elseif($type == "media") {
$title = "MEDIA"
$text = "Hier komt het beeld- en geluidsmateriaal"
} else {
echo "<script type='text/Javascript'>
	alert('De pagina bestaat niet of is onder constructie, u wordt nu naar de homepagina geleid');
</script>";
header('location:../../index.html');
};
?>
<html dir="ltr">
    <head>
        <title><?php echo $title; ?></title>
        <link href="../../standard.css" type="text/css" rel="stylesheet" />
<link href='liefde.css' type='text/css' rel="stylesheet" />
    </head>
    <body>
        <table class="look" height="100%" width="100%" border="1">
            <tbody>
                <tr>
                    <td width="10%" height="100%"><iframe class="frames" src="../../functieknoppen/functieknoppengedicht.php?poem_id=<?php echo $_GET['poem_id']; ?>" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
                    </td>
                    <td><center>
<?php
echo $text;
?>
</center></td>
                </tr>
            </tbody>
        </table>
    </body>
</html>
<?php
endwhile;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/146703-solved-table-in-table-autocreated/
Share on other sites

$text = "<table border = '0'><tr><td colspan='2'><center>Info over dit gedicht: </center></td></tr>
                         <tr><td>Naam Gedicht</td><td>".$row['poem_name']."</td></tr>
                         <tr><td>Naam Auteur</td><td>".$row['author_name']."</td></tr>
                         <tr><td>Naam Poster</td><td>".$row['user_name']."</td></tr>
                         <tr><td>Categorie</td><td>".$row['category_name']."</td></tr>
                         <tr><td>Naam Bundel</td><td>".$row['book_name']."</td></tr>
          </table>";

 

You're assigning a variable so there's no need to jump in and out of php.

Also if you get more than one result your loop will create more than one html page within a single page;

 

<html>
<head>
</head>
<body>
your table
</body>
</html>
<html>
<head>
</head>
<body>
your table
</body>
</html>

 

And so on for more results

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.