1

First, I got a html file containing code like this:

<form action="Journey.php" method="POST">

<select name = "Startpoint">
<optgroup label = "Start point">
<option value = "GrimesDyke">GrimesDyke</option>
<option value = "SeacroftRingRoad">SeacroftRingRoad</option>
......

this part work fine, it calld the Journey.php file and pass the right data, i use these data to perform php calculations and want it to be displayed in table format like this

echo "<table id = 'Journey' border='1' style='border-collapse:
collapse;border-color: silver;'>";
echo "<tr style='font-weight: bold;'>";
echo "<td width='150' align='center'>Stops</td>";
echo "</tr>";

foreach ($StopRow as $row)
{
echo '<td width="150" align=center>' .$row. '</td>';
echo '</tr>';
}

in my eclipse-php IDE, this worked just fine, however, when it come to the browser... well, there is a table on display.....along with half of my php code.....like the picture belowthe result of running my code on a browser

the thing is, before i put my php code in the html body tag, it works well....please show me how can i make it right...thank you

A.Y
  • 137
  • 1
  • 9
  • is your file extension for sure `.php` (dumb question, but very common mistake)? – Rasclatt Apr 27 '16 at 03:15
  • Also, do other pages parse the php? – Rasclatt Apr 27 '16 at 03:17
  • It's not uncommon for only portions of your code to show. Usually the browser is just malforming what it thinks is html. Is this localhost or hosted somewhere? – Rasclatt Apr 27 '16 at 03:19
  • well, it is a local host generated by XAMPP, and the file is indeed .php, the only page calls that .php file is my html file mentioned above..... – A.Y Apr 27 '16 at 03:24
  • Do any other php files work? If you don't have any others, just make one that has ``. See if it's parsed. If not, your xampp is likely to blame – Rasclatt Apr 27 '16 at 03:27
  • there is a > larger than operator there..... is stop displaying code when i removed it, how can i avoid problems like this? i really need that operator... – A.Y Apr 27 '16 at 03:31
  • No, that is not the problem. Look in your browser source, you will probably see all your code. It's treating your php as html – Rasclatt Apr 27 '16 at 03:34
  • the php works great before i put it in to the html body tag..... – A.Y Apr 27 '16 at 04:59
  • So the header portion is php ("Leeds Super Tram etc...")? – Rasclatt Apr 27 '16 at 05:01
  • Have you viewed the source of your webpage to see if it's show all the php code? It could in theory appear like it's working if you have html mixed in with php. – Rasclatt Apr 27 '16 at 05:04

1 Answers1

0

If PHP is enabled & working then :

It is possible that you have a ?> at that point in code. Just search for it, you should find it. Remove it.

It may also be cause if you are accessing the file directly(by file path on the browser),

Use : http://localhost/index.php

Otherwise it may be a config problem and hence the question a duplicate : this answer

Community
  • 1
  • 1
Ani Menon
  • 27,209
  • 16
  • 105
  • 126
  • there is a > larger than operator there..... is stop displaying code when i removed it, how can i avoid problems like this? i really need that operator... – A.Y Apr 27 '16 at 03:31
  • Could you post your code? That can't be the problem. It has to be a `?>` for a php close and the rest of the php comes on the screen. – Ani Menon Apr 27 '16 at 03:40
  • Thank you very much, the url works, but file path not – A.Y Apr 29 '16 at 05:09