Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I Need Help In PHP Commands
#1
This is a piece of php code! I want to change it's font (alignment, color, weight). Please copy this code, apply the color, alignment and weight commands properly and post under the thread!

PHP Code:
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo 
"Views="$_SESSION['views']; 

Thanks In Advance Smile
[Image: green-banner.png]
Reply
#2
Seriously? How could you not know basic CSS, and decided to learn PHP?


Do something along the lines of:

PHP Code:
echo "<span style='color #ff0000'>Views=" $_SESSION['views'] ."</span>"
Reply
#3
From your post, I take that you want to style the output (i.e. echoing the total views) then you might want to place the code in a div (or echo out into a div) and give an id of 'views' then use CSS to style it.

Example:
PHP Code:
<style type="text/css">
#views {
    
border1px solid black//styles here

</
style>
<
div id="views">
<?
php
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo 
"Views="$_SESSION['views']; 
?>
</div> 

EDIT: Beaten to it :p
Reply
#4
(09-04-2010, 04:12 AM)ndee Wrote: Seriously? How could you not know basic CSS, and decided to learn PHP?


Do something along the lines of:

PHP Code:
echo "<span style='color #ff0000'>Views=" $_SESSION['views'] ."</span>"

see this page! www.dareknight.110mb.com
If i don't know the basic css then i cant make it!
i was just too lazy at that time and it made me a little confusing beacuse the Views= was getting fonted but the number was'nt! you can check the crack challenge on my site!
[Image: green-banner.png]
Reply
#5
I just quickly wrote this up in Dreamweaver for you:

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
meta name="description" content="Enter your description here." />
<
meta name="keywords" content="Enter,some,tags,here" />
<
meta name="author" content="Your Name Here" />
<
title>Title Here</title>
<
style type="text/css">
body {
    
colorred;
text-aligncenter;
font-weightbold;
}
</
style>
</
head>

<
body>
<?
php
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo 
"Views="$_SESSION['views']; 
?>
</body>
</html> 
Reply
#6
BreSHie you've been learning PHP and you don't know how to use the increment operator yet?

PHP Code:
$_SESSION['views']++; 
Reply
#7
Also.... this line makes it even faster..

PHP Code:
$_SESSION['views'] = (isset($_SESSION['views'])) ? ($_SESSION['views'] + 1) : 1
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 941 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,667 10-10-2011, 01:00 PM
Last Post: Greyersting

Forum Jump:


Users browsing this thread: 1 Guest(s)