Designing layouts in conjunction with PHP

I'm stuck with CSS, tables and PHP <<combination of.

Page 1 of 1

5 Replies - 1067 Views - Last Post: 24 June 2008 - 04:09 AM Rate Topic: -----

#1 livelonger87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 27-May 08

Designing layouts in conjunction with PHP

Posted 22 June 2008 - 06:08 AM

Theres a video on youtube based on a tutorial that describes how to create a web forum, whilst demonstrating the neccessary skills required: http://www.youtube.c...oLPKTxzw&fmt=18

Problem is - I don't understand how to create layouts like he done. I understand a bit of CSS:
 body. {
  background-color: gray;
  border: 2px solid orange;
  font-family: verdana;
  }
 

I can use it in conjunction with <div> tags, but I don't understand how to create full alignments. Take this site for an example, the way it displays all the user generated information in a table like form, printing towards the bottom of the page. After, if it reaches a certain length, it uses pagenition to prevent a stretched page.

I don't understand how I manually create layouts such as the ones you see on this site and other sites.

I also have another annoyance that's bugging me; how can I get php to display certain layouts if a user is logged in for instance, or to not display that layout and to display another if the user isn't logged in.

I tried this...
 if($a == 2)
 {
 echo "
 <div id="test'> Sorry, you must be logged in to do that.  Please login: <a href="login.php"> login </a></div>
";
}
else
 {
 echo "
 <div id="logged_in"> Thank you for logging in '$user' </div>
 ";
}



I need some help on designing layouts in conjunction with PHP :(

This post has been edited by livelonger87: 22 June 2008 - 07:13 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Designing layouts in conjunction with PHP

#2 didgy58  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 246
  • Joined: 23-October 07

Re: Designing layouts in conjunction with PHP

Posted 22 June 2008 - 06:59 AM

well with the code ur trying it is amost correct, but you are saying $a is equal to 2, you need to say if it equal to 2 then do this so it would look like this


if ($a == 2) {
do this code 
} else {
do the other 
}



a single = sets the variable to the value after it, but to compare a variable to a value you need to use a double ==, so this would be the same for not equal to which looks like !=, not sure if i have explained that well. if you take a look on google for php comparison operators it will be explained a little better or go to the following link on php.net

http://uk2.php.net/m....comparison.php

this might help explain a little more about the problem with your different displaying for logged in and not. i hope this helps you out a little
Was This Post Helpful? 0
  • +
  • -

#3 livelonger87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 27-May 08

Re: Designing layouts in conjunction with PHP

Posted 22 June 2008 - 07:14 AM

View Postdidgy58, on 22 Jun, 2008 - 06:59 AM, said:

well with the code ur trying it is amost correct, but you are saying $a is equal to 2, you need to say if it equal to 2 then do this so it would look like this


if ($a == 2) {
do this code 
} else {
do the other 
}



a single = sets the variable to the value after it, but to compare a variable to a value you need to use a double ==, so this would be the same for not equal to which looks like !=, not sure if i have explained that well. if you take a look on google for php comparison operators it will be explained a little better or go to the following link on php.net

http://uk2.php.net/m....comparison.php

this might help explain a little more about the problem with your different displaying for logged in and not. i hope this helps you out a little

I'm not talking about small errors we tend to make when writting something up. A little = sign being missing is not the issue. The issue is layouts. I'm trying to design layouts in conjunction with PHP. Thanks anyway.
Was This Post Helpful? 0
  • +
  • -

#4 Dancia  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 60
  • Joined: 15-June 08

Re: Designing layouts in conjunction with PHP

Posted 22 June 2008 - 07:28 AM

View Postlivelonger87, on 22 Jun, 2008 - 07:14 AM, said:

View Postdidgy58, on 22 Jun, 2008 - 06:59 AM, said:

well with the code ur trying it is amost correct, but you are saying $a is equal to 2, you need to say if it equal to 2 then do this so it would look like this


if ($a == 2) {
do this code 
} else {
do the other 
}



a single = sets the variable to the value after it, but to compare a variable to a value you need to use a double ==, so this would be the same for not equal to which looks like !=, not sure if i have explained that well. if you take a look on google for php comparison operators it will be explained a little better or go to the following link on php.net

http://uk2.php.net/m....comparison.php

this might help explain a little more about the problem with your different displaying for logged in and not. i hope this helps you out a little

I'm not talking about small errors we tend to make when writting something up. A little = sign being missing is not the issue. The issue is layouts. I'm trying to design layouts in conjunction with PHP. Thanks anyway.


To write a full layout is a lot of job. I always write everything in (x)html/css and after finish ,b>ALL HTML and CSS codes which will be needed in the future</b> I start interpreting PHP.
Was This Post Helpful? 0
  • +
  • -

#5 JBrace1990  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 110
  • View blog
  • Posts: 760
  • Joined: 09-March 08

Re: Designing layouts in conjunction with PHP

Posted 22 June 2008 - 02:40 PM

for my CSS, I use Dreamweaver, since that's the easier way to go... i don't actually understand CSS at all, really =/

but to display different CSS styles, just set them all up... like this:
<?php
if($a == '1'){
//display CSS Style 1
}elseif($a == '2'){
//display CSS Style 2
}else{
//display CSS Style 3
}


or, if you're going for whether or not someone is logged in, check their sessions using isset or empty...
Was This Post Helpful? 0
  • +
  • -

#6 livelonger87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 27-May 08

Re: Designing layouts in conjunction with PHP

Posted 24 June 2008 - 04:09 AM

Alright, sortof getting the hang of writting CSS for layouts. Here's an instance of how I'd write a webpage currently...
[code]
<html>
<head>
<style type="text/css">
#login
{
position: relative;
top: 250px;
left: 250px;
width: 250px;
height: 250px;
background-color: #CCCCCC;
border: 2px solid black;
font-family: verdana;
font-size: 10pt;
padding: 10px;
}
</style>
<body>
<?php
$a = 1;
if($a = 1)
{
echo "
<div id='login'>
<form action='test.php' method='post' id='login'>
Username:
<input type='text' name='username' id='username'>
Password:
<input type='text' name='password' id='password'>
<center><input type='submit' value='login' id='submit'></center>
</div>
";
else
{
print "Welcome $a";
}
?>
</body>
</html>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1