PDA

Click to See Complete Forum and Search --> : align center in php


Pouncer
May 30th, 2006, 08:30 AM
echo "<align=center>Logged in successfully.<br>";

why doesnt that work?

and also:

echo "Click here";

how would i hyperlink the word 'here'

penagate
May 30th, 2006, 08:33 AM
1) Align is not an HTML tag, align=center is not valid SGML syntax, and you did not have a closing tag to boot.

<span style="text-align: center;">Logged in successfully</span><br>


2) The usual way - using an anchor tag. Also, read the Don't say Click Here link in my signature.

<a href="somewhere">Somewhere</a>

Pouncer
May 30th, 2006, 08:43 AM
thanks alot penegate, 1 more question, i wana make the font verdana, size 9, any idea mate?

penagate
May 30th, 2006, 08:46 AM
You should have a stylesheet, which is a .css file you attach using a <link> tag in your <head> section.

<head>
<link rel="stylesheet" type="text/css" href="mypage.css">
</head>


In the stylesheet you can put CSS rules such as font etc.
html {
font: 9pt Verdana, sans-serif;
}


sans-serif is a generic font class which is there as a fallback in case Verdana is not available on the user's system.

All presentational rules should be set in the CSS file. The only things you should have in the HTML document are classes and id's, which you can use in CSS selection rules. If you are not familiar with this I suggest you go through a CSS tutorial.

Pouncer
May 30th, 2006, 09:42 AM
oops sorry i meant just the text

<span style="text-align: center;">Logged in successfully</span><br>

just that to be verdana, not all 'fonts'

penagate
May 30th, 2006, 09:45 AM
Ah,

You should give that a class (if it will appear more than once on a page) or ID (if it will appear only once).

Then you can select it in your stylesheet like this:
/* For a class: */
.classname {
font: 9pt Verdana, sans-serif;
}

/* For an ID: */
#id {
font: 9pt Verdana, sans-serif;
}

Pouncer
May 30th, 2006, 12:02 PM
1) Align is not an HTML tag, align=center is not valid SGML syntax, and you did not have a closing tag to boot.

<span style="text-align: center;">Logged in successfully</span><br>


2) The usual way - using an anchor tag. Also, read the Don't say Click Here link in my signature.

<a href="somewhere">Somewhere</a>


that centre align is for html but how would it be done in php mate?

penagate
May 30th, 2006, 12:04 PM
PHP is a pre-processor. In most cases, and in this case, you're using it to output HTML code. So there's absolutely no difference. Whether you are using PHP or ASP or no server side language is completely transparent to the browser, which is what does the HTML and CSS parsing.

Pouncer
May 30th, 2006, 01:27 PM
but my code is like this


<?
if (empty($Username) || empty($Password)) {
echo "You didn't fully input login details. Please go back and try again";
}

else {
$res = $db->_LOGIN($Username, $Password);

if ($res == 1) {
echo "Logged in successfully.<br>";
echo "Test";
}

else echo "You specified invalid login details, please go back and try again.";
}

?>


and it throws errors when i put ur code in

The Hobo
May 30th, 2006, 04:59 PM
You probably have to escape the additional quotes, for example:

echo "<span class=\"classNameHere\">Logged in successfully.</span><br>";

If you do not escape the additional quotes in the text, PHP thinks it's the end of the string and thinks that everything after it is PHP code.

penagate
May 30th, 2006, 07:02 PM
Don't use double quotes for strings. Single quotes are more efficient and avoids having to escape most characters. Also, don't use echo to output HTML. Output is what PHP does when it's not doing anything, so just stop the PHP block.

<?php if ($res == 1): ?>
<span style="text-align: center; ">Logged in successfully.</span><br>
<?php endif; ?>

The Hobo
May 30th, 2006, 08:53 PM
Applying alignment to a span element will not do anything.

penagate
May 30th, 2006, 09:02 PM
Div then. My mistake, forgot it was inline.