i have created a simple table with two rows and three columns and three variables.
i want to echo my three variables in the columns of first row.
but when i echo these variables in the columns it generates an error
that the syntax of table is incorrect
error is
Parse error: syntax error, unexpected '<' in C:\wamp\www\table.php on line 19
here the all coding of my page
<html>
<head>
<?php /* Start of HEAD Section */ ?>
<title>PHP Page<?php echo $page ?></title>
<meta name = "description" content= "This is my first own PHP scripted page"
<?php /*End of HEAD Section*/ ?>
</head>
<?php /*Start of Body Section */ ?>
<body>
<?php echo "Here is a method to echo the variables in table" ?>
<?php //Start of Table ?>
<?php
$First = "Tassadduq";
$Last = "Hussain";
$RollNo = 623;
?>
<?php
echo "<table width='80%' border='1'>";
<tr>
<td>echo "$First";</td>
<td>echo "$Last";</td>
<td>echo "RollNo";</td>
</tr>
<tr>
<td>Sample Text</td>
<td>Sample Text</td>
<td>Sample Textt</td>
</tr>
</table>
?>
<?php //End of Table ?>
</body>
<?php /*End of Body Section */ ?>
where is the mistake in table.
PHP Table problem
Moderator: General Moderators
Re: PHP Table problem
Maybe highlighting will help you see the problem?
Code: Select all
<?php
echo "<table width='80%' border='1'>";
<tr>
<td>echo "$First";</td>
<td>echo "$Last";</td>
<td>echo "RollNo";</td>
</tr>
<tr>
<td>Sample Text</td>
<td>Sample Text</td>
<td>Sample Textt</td>
</tr>
</table>
?>Re: PHP Table problem
i have changed the code to following but it generates the same error
<html>
<head>
<?php /* Start of HEAD Section */ ?>
<title>PHP Page<?php echo $page ?></title>
<meta name = "description" content= "This is my first own PHP scripted page"
<?php /*End of HEAD Section*/ ?>
</head>
<?php /*Start of Body Section */ ?>
<body>
<?php echo "Here is a method to echo the variables in table" ?>
<?php //Start of Table ?>
<?php
$First = "Tassadduq";
$Last = "Hussain";
$RollNo = 623;
?>
<?php
echo "<table width='80%' border='1'>";
<tr>
<td>echo "$First";</td>
<td>echo "$Last";</td>
<td>echo "$RollNo";</td>
</tr>
<tr>
<td>Sample Text</td>
<td>Sample Text</td>
<td>Sample Textt</td>
</tr>
</table>
?>
<?php while(1); ?>
<?php //End of Table ?>
</body>
<?php /*End of Body Section */ ?>
<html>
<head>
<?php /* Start of HEAD Section */ ?>
<title>PHP Page<?php echo $page ?></title>
<meta name = "description" content= "This is my first own PHP scripted page"
<?php /*End of HEAD Section*/ ?>
</head>
<?php /*Start of Body Section */ ?>
<body>
<?php echo "Here is a method to echo the variables in table" ?>
<?php //Start of Table ?>
<?php
$First = "Tassadduq";
$Last = "Hussain";
$RollNo = 623;
?>
<?php
echo "<table width='80%' border='1'>";
<tr>
<td>echo "$First";</td>
<td>echo "$Last";</td>
<td>echo "$RollNo";</td>
</tr>
<tr>
<td>Sample Text</td>
<td>Sample Text</td>
<td>Sample Textt</td>
</tr>
</table>
?>
<?php while(1); ?>
<?php //End of Table ?>
</body>
<?php /*End of Body Section */ ?>
- Frozenlight777
- Forum Commoner
- Posts: 75
- Joined: Wed May 28, 2008 12:59 pm
Re: PHP Table problem
you're trying to put html within the php which won't work unless you echo the html for example:
or you can just close the php brackets when you're going to insert html then re-open them like:
Code: Select all
echo "<td>" . $firstname . "</td>";Code: Select all
<?php
?>
<td><?php echo $firstname; ?> </td>
Re: PHP Table problem
thanks for reply but
there is still problem.
will anyone right the whole code to this one simple
suppose we work in notepad and want to make a table through php script
before creating table i want to make 3 variables
1 $first - "First Name";
2 $last = "Last Name";
3 $rollno = "623";
and then create table with single rows and three columns
i want to display the three variables values in the first columns
in first column value of $first
in second column value of $last
and in the third column value of $rollno
so what will be the code for this????
there is still problem.
will anyone right the whole code to this one simple
suppose we work in notepad and want to make a table through php script
before creating table i want to make 3 variables
1 $first - "First Name";
2 $last = "Last Name";
3 $rollno = "623";
and then create table with single rows and three columns
i want to display the three variables values in the first columns
in first column value of $first
in second column value of $last
and in the third column value of $rollno
so what will be the code for this????
Re: PHP Table problem
Paste this code exactly as it is. It should work
Code: Select all
<html>
<head>
<?php /* Start of HEAD Section */ ?>
<title>PHP Page<?php echo $page ?></title>
<meta name = "description" content= "This is my first own PHP scripted page"
<?php /*End of HEAD Section*/ ?>
</head>
<?php /*Start of Body Section */ ?>
<body>
<?php echo "Here is a method to echo the variables in table" ?>
<?php //Start of Table ?>
<?php
$First = "Tassadduq";
$Last = "Hussain";
$RollNo = 623;
?>
<table width='80%' border='1'>
<tr>
<td><?php echo "$First"; ?></td>
<td><?php echo "$Last"; ?></td>
<td><?php echo "RollNo"; ?></td>
</tr>
<tr>
<td>Sample Text</td>
<td>Sample Text</td>
<td>Sample Textt</td>
</tr>
</table>
<?php /* End of Table */ ?>
</body>
<?php /*End of Body Section */ ?>
Re: PHP Table problem
Bundle of Thanks dude81