hye guys, i have a html code as below:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="graph/enhance.js" type="text/javascript"></script>
<script src="graph/excanvas.js" type="text/javascript"></script>
<script src="graph/jquery.min.js" type="text/javascript"></script>
<script src="graph/visualize.jQuery.js" type="text/javascript"></script>
<link href="graph/basic.css" rel="stylesheet" type="text/css" />
<link href="graph/visualize.css" rel="stylesheet" type="text/css" />
<link href="graph/visualize-light.css" rel="stylesheet" type="text/css" />
<style type="text/css">


.dwpeAd {
    color: #333;
    background-color: #F4F3Ea;
    position:fixed;
    right: 20px;
    top: 20px;
    padding: 5px;
}

.visualize { 
    margin: 20px 0 0 30px; 
}


</style>
<script type="text/xml">

<oa:widgets>
  <oa:widget wid="2281525" binding="#jQueryVisualizeChart" />
</oa:widgets>

</script>
</head>

<body>
<script type="text/javascript">

    $(function(){
         $('table').visualize({type: 'line', height: '300px', width: '420px', appendTitle : true, lineWeight : 8, colors : ['#b3c3f4','#39007a','#a4deab','#49a7c0','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744']}).appendTo('#jQueryVisualizeChart').trigger('visualizeRefresh');

        });

</script>

<table>
  <caption>
    Student Information
  </caption>
  <thead>
    <tr>
      <td></td>
      <th scope="col">Attd</th>
      <th scope="col">Quiz1</th>
      <th scope="col">Quiz2</th>
      <th scope="col">Quiz3</th>
      <th scope="col">Quiz4</th>
      <th scope="col">Test1</th>
      <th scope="col">Test2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Mary</th>
      <td>190</td>
      <td>160</td>
      <td>40</td>
      <td>120</td>
      <td>30</td>
      <td>70</td>
      <td>70</td>
    </tr>

  </tbody>
</table>
<br />
<div id="jQueryVisualizeChart"></div>


</body>
</html>

and i tried to echo it in php like this:

<script type="text/javascript">
    function success()
    {

    $(function(){
         $('table').visualize({type: 'line', height: '300px', width: '420px', appendTitle : true, lineWeight : 8, colors : ['#b3c3f4','#39007a','#a4deab','#49a7c0','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744']}).appendTo('#jQueryVisualizeChart').trigger('visualizeRefresh');

        });
}

</script>

<?php
echo '
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="graph/enhance.js" type="text/javascript"></script>
<script src="graph/excanvas.js" type="text/javascript"></script>
<script src="graph/jquery.min.js" type="text/javascript"></script>
<script src="graph/visualize.jQuery.js" type="text/javascript"></script>
<link href="graph/basic.css" rel="stylesheet" type="text/css" />
<link href="graph/visualize.css" rel="stylesheet" type="text/css" />
<link href="graph/visualize-light.css" rel="stylesheet" type="text/css" />
<style type="text/css">


.dwpeAd {
    color: #333;
    background-color: #F4F3Ea;
    position:fixed;
    right: 20px;
    top: 20px;
    padding: 5px;
}

.visualize { 
    margin: 20px 0 0 30px; 
}


</style>
<script type="text/xml">

<oa:widgets>
  <oa:widget wid="2281525" binding="#jQueryVisualizeChart" />
</oa:widgets>

</script>
</head>

<body>
<script type="text/javascript"> success(); </script>

<table>
  <caption>
    Student Information
  </caption>
  <thead>
    <tr>
      <td></td>
      <th scope="col">Attd</th>
      <th scope="col">Quiz1</th>
      <th scope="col">Quiz2</th>
      <th scope="col">Quiz3</th>
      <th scope="col">Quiz4</th>
      <th scope="col">Test1</th>
      <th scope="col">Test2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">Mary</th>
      <td>190</td>
      <td>160</td>
      <td>40</td>
      <td>120</td>
      <td>30</td>
      <td>70</td>
      <td>70</td>
    </tr>

  </tbody>
</table>
<br />
<div id="jQueryVisualizeChart"></div>


</body>
</html>';

?> 

BUT it's not working. Any suggestion? i only wanted to use echo if possible.

Recommended Answers

All 11 Replies

Worked for me when I changed the " for ' and the ' for "
It's the way I normally write it.

Just wondering why you want to echo :-)

Just wondering why you want to echo :-)

I agree. I dont see the value of having the PHP 'engine' have to convert PHP code into HTML in a case where there is no dymanic data being built from a data source.

Maybe but no sure, try to follow the rule of echo, where text to be echoed goes like this for example

<?php
echo "your text"
?>

I see your echo not in the correct format where is is like this

<?php
echo '
<html xmlns="http://www.w3.org/1999/xhtml">
<head>........

</body>
</html>';
?>
try to include text to be displayed in double codes, and not to forget to include an error tht you get if there is any

Just wondering why you want to echo :-)

For some purpose i need to echo it. =)

Worked for me when I changed the " for ' and the ' for "
It's the way I normally write it.

what do you mean??

Maybe but no sure, try to follow the rule of echo, where text to be echoed goes like this for example

<?php
echo "your text"
?>

I see your echo not in the correct format where is is like this

<?php
echo '
<html xmlns="http://www.w3.org/1999/xhtml">
<head>........

</body>
</html>';
?>
try to include text to be displayed in double codes, and not to forget to include an error tht you get if there is any

Maybe but no sure, try to follow the rule of echo, where text to be echoed goes like this for example

<?php
echo "your text"
?>

I see your echo not in the correct format where is is like this

<?php
echo '
<html xmlns="http://www.w3.org/1999/xhtml">
<head>........

</body>
</html>';
?>
try to include text to be displayed in double codes, and not to forget to include an error tht you get if there is any

Maybe but no sure, try to follow the rule of echo, where text to be echoed goes like this for example

<?php
echo "your text"
?>

I see your echo not in the correct format where is is like this

<?php
echo '
<html xmlns="http://www.w3.org/1999/xhtml">
<head>........

</body>
</html>';
?>
try to include text to be displayed in double codes, and not to forget to include an error tht you get if there is any

Maybe but no sure, try to follow the rule of echo, where text to be echoed goes like this for example

<?php
echo "your text"
?>

I see your echo not in the correct format where is is like this

<?php
echo '
<html xmlns="http://www.w3.org/1999/xhtml">
<head>........

</body>
</html>';
?>
try to include text to be displayed in double codes, and not to forget to include an error tht you get if there is any

that link can be removed. not a big deal i guess.

For some purpose i need to echo it. =)

Which is why I asked why?

If you simply output HTML without echo there is no need to worry about double quotes.

And for my explanation, if you really need to echo with php the syntax is:

echo"
    <html>
    <head>
    <title></title>
    </head>";

and

    <script src='graph/enhance.js' type='text/javascript"></script>
    <script src='graph/excanvas.js' type='text/javascript'></script>

do you see the difference with the single and double quotes from yours?

Expanding on what TonyG says... it's a matter of preference whether you use single or double but just like HTML tags they should be correctly wrapped.
I personally prefer single quotes and string concatenation. I try not to echo HTML by using the PHP alternative syntax, which keeps my editor's syntax highlighting happy also.

<?php 
$student = 'Mary';
echo '<p>Student: '.$student.' - Results</p>';
echo "<p>Student: $student - Results</p>";
echo "<p>Student: {$student} - Results</p>";
?>
<p>Student: <?php echo $student; ?> - Results</p>

Echoing HTML, simply follow what Tony G said... Although it is advisable to echo HTML, if the page is handling some dynamic data.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.