7 Replies - 920 Views - Last Post: 28 May 2010 - 07:36 PM Rate Topic: -----

#1 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

PHP + CSS

Posted 27 May 2010 - 05:15 PM

I'm wondering if it's possible to position an "echo "blah blah blah";" with CSS.
Is This A Good Question/Topic? 0
  • +

Replies To: PHP + CSS

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10469
  • View blog
  • Posts: 38,802
  • Joined: 27-December 08

Re: PHP + CSS

Posted 27 May 2010 - 05:20 PM

Position how? Are you talking about the layout of the HTML code? If so, you can use the standard escape sequences to format the HTML. If not, you can dynamically include classes, IDs, and styles (inline) for HTML tags, which you can use to work with the CSS.
Was This Post Helpful? 0
  • +
  • -

#3 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: PHP + CSS

Posted 27 May 2010 - 05:41 PM

View Postmacosxnerd101, on 27 May 2010 - 06:20 PM, said:

Position how? Are you talking about the layout of the HTML code? If so, you can use the standard escape sequences to format the HTML. If not, you can dynamically include classes, IDs, and styles (inline) for HTML tags, which you can use to work with the CSS.

With CSS. I tried something like this:
echo "Here is the text" class"Here_is_the_class";
I think I know what I did wrong. Do I have to declare an external CSS document in the php file? If so how? Thanks in advance.
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10469
  • View blog
  • Posts: 38,802
  • Joined: 27-December 08

Re: PHP + CSS

Posted 27 May 2010 - 05:44 PM

You will need to use HTML tags still. If you do not, then you cannot use CSS.
<html>
<head>
<style>
   .helloWorld{
         color:rgb(55, 82, 154);
   }
</style>
</head>

<body>
<?php
   echo "<p class=\"helloWorld\">Hello, World!</p>";
?>
<p class="helloWorld"><?php echo "Hello, two"; ?></p>
</body>
</html>


Was This Post Helpful? 2
  • +
  • -

#5 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: PHP + CSS

Posted 27 May 2010 - 06:01 PM

View Postmacosxnerd101, on 27 May 2010 - 06:44 PM, said:

You will need to use HTML tags still. If you do not, then you cannot use CSS.
<html>
<head>
<style>
   .helloWorld{
         color:rgb(55, 82, 154);
   }
</style>
</head>

<body>
<?php
   echo "<p class=\"helloWorld\">Hello, World!</p>";
?>
<p class="helloWorld"><?php echo "Hello, two"; ?></p>
</body>
</html>


Thanks. Your one of the best people I've met on Dream.In.Code.
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10469
  • View blog
  • Posts: 38,802
  • Joined: 27-December 08

Re: PHP + CSS

Posted 27 May 2010 - 06:30 PM

Glad I could help! :)
Was This Post Helpful? 0
  • +
  • -

#7 EnvXOwner  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 357
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: PHP + CSS

Posted 28 May 2010 - 03:54 PM

Do I need to do both paragraph tags. I'm using an external CSS document and don't know if I need to declare it in the PHP. The exact code for the whole page:
<?php

$button = $_POST['button'];

if ($button)
{
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$dob = $_POST['dob'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];

if ($username && $password && $email && $dob && $first_name && $lastname)
{
echo "<p class="echo">You are now registered.</p>";
}
else
echo "You didn't fill in all of your details.";
}
else
{
echo "
<form action='register.php' method='POST'>
<table width='500' class='register'>
<tr>
<td align='right'>
Username:
</td>
<td align='left'>
<input type='text' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Password:
</td>
<td align='left'>
<input type='password' name='password'>
</td>
</tr>
<tr>
<td align='right'>
Email:
</td>
<td align='left'>
<input type='text' name='email'>
</td>
<input type='text' name='username'>
</tr>
<tr>
<td align='right'>
Date of Birth (mm/dd/yyyy):
</td>
<td align='left'>
<input type='text' name='dob'>
</td>
</tr>
<tr>
<td align='right'>
First Name:
</td>
<td align='left'>
<input type='text' name='first_name'>
</td>
</tr>
<tr>
<td align='right'>
Last Name:
</td>
<td align='left'>
<input type='text' name='last_name'>
</td>
</tr>
<tr>
<td align='right'>
<input type='submit' name='button' value='Register'>
</td>
</tr>
</table>
</form>";
}

?>
<html>
<body>
<title>Env X Software | Register</title>
<link rel="shortcut icon" type="image/x-icon" href="Images/favicon.ico">
<link rel="stylesheet" type="text/css" href="CSS.css" />
</head>
<body>
<p class="echo"><?php echo "You are now registered.";?></p>
<div class="Home_01">
<a href="http://www.envxsoftware.com/">
<img src="Images/env_x_home_02.gif" border="0"/>
</a>
</div>
<div class="Sliver">
<img src="Images/Sliver.gif" border="0"/>
</div>
<div class="Products">
<a href="http://www.envxsoftware.com/products.html">
<img src="Images/Products_Light.gif"/>
</a>
</div>
<div class="Google_Groups"> 
<a href="http://groups.google.com/group/env-x/"><img src="Images/Google_Groups.png" border="0"/></a>
</div>
<div class="Twitter"> 
<a href="http://twitter.com/EnvXSoftware"><img src="Images/Twitter.png" border="0"/></a>
</div>
<div class="Facebook">
<a href="http://www.facebook.com/#!/pages/Env-X/195634834349?ref=ts"><img src="Images/Facebook.png" border="0"/></a>
</div>
<p class="Copyright">Env X &copy 2010</p>
</body>
</html>

It don't work and I don't know why.
Was This Post Helpful? 0
  • +
  • -

#8 atik97  Icon User is offline

  • ???
  • member icon

Reputation: 144
  • View blog
  • Posts: 715
  • Joined: 16-September 08

Re: PHP + CSS

Posted 28 May 2010 - 07:36 PM

The line which is generating error is -
echo "<p class="echo">You are now registered.</p>";



The problem is its a double quoted string and hence you need to escape other double quotation marks.
echo "<p class=\"echo\">You are now registered.</p>";



You don't need to declare css for php code separately, once the whole document is linked to the css file, it will be available through the whole page.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1