how would I end the php script , but not the html. for example, when this line exits; it ignore anything below including the rest of the html lines.
example:
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
<td>
copyright 2002</td>
ignores:
it doesnt print out the word "copyright 2002" .
exit a php script but not the html
Moderator: General Moderators
Re: exit a php script but not the html
Code: Select all
<?php
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
}
?>
<table>
<td>copyright 2002</td>
</table>i trying removing the exit; before, but there was a problem and it just display a bunch if stuff from my db.
to be more define. here are lines.
if (!$searchtype || !$searchterm)
{
echo "You have not entered search details. Please go back and try again.";
}
echo "whatever";
echo "";
..
it starts to list everything i got in my database if i dont use exit;
to be more define. here are lines.
if (!$searchtype || !$searchterm)
{
echo "You have not entered search details. Please go back and try again.";
}
echo "whatever";
echo "";
..
it starts to list everything i got in my database if i dont use exit;
what i usually do is refresh the page with a <meta> tag.
for example
so in the body of the html you would have
you would have you html tables here
you would have your html footer here
this way you only change things in the body of your html.
hope this helps. the only disadvatage of this is that when you view it in dreamweaver you will see both the html for the error msg and the else.
for example
Code: Select all
<?php
if ($num_rows == 0) {
?>
<meta http-equiv="refresh" content="0; url=forgotten_password.php?error=1">
<?php
exit;
} else {
do my query
}
?>you would have you html tables here
Code: Select all
<?php
if (isset($error)) {
echo "my error msg";
} else {
echo "my html";
}
?>this way you only change things in the body of your html.
hope this helps. the only disadvatage of this is that when you view it in dreamweaver you will see both the html for the error msg and the else.