Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Apply CSS on PHP output?

    How can I apply css on my output like tables and colors, bold ,align, etc...
    like I want to apply style to the colored section:

    here is the code:


    Code:
    <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
    
    <head>
    <style type="text/css">
    .direccion {
    	text-align: center;
    }
    .direccion {
    	font-family: Arial;
    }
    </style>
    </head>
    
    <img src="loguito.jpg" /><div style="float:right;width:400px"><a href="#" onclick="java script:window.print(); return false">Imprimir</a></div> <br /> <br />
    <div style="width:600px;text-align:center;border-color:black;text-indent:5px;">
    <?php
    
    if($_GET['continue'] != 1)
    {
    	 $name = $_GET['class']; 
    
        // form items you wish to exclude from the info list. you can just make this blank if you dont want to exclude anything
        $exclude = array('submit','hiddenvalue');
    	
        foreach($_POST as $class => $val){
        
        	 
            // if its in the exclude array, skip it
            if(in_array($val, $exclude))
                continue;
    
    
            // print out the info
            echo $class.":\t\t ".$val."<br />\n";
        }
    
        ?>
        
        </div>
        
        <br /><br /><br />
        <div style="width:600px;text-align:center;border-color:black;text-indent:5px;>
       <br /><br /><br /><br /><br />
        <li class="direccion"><a href="<?=$_SERVER['PHP_SELF']?>?continue=1">Si su informacion esta correcta click aqui.</a></li>
        <br />
        <li class="direccion"> <a href="javascript:history.go(-1);">Si quiere hacer algun cambio click aqui. (Volver)</a></li>
    
    <br /><br />
    
     <p class="direccion"><strong><em><span class="style2">Ave. 14 de Julio contiguo a 
    	Ferreteria Casa Siryi.<br>
    	PO Box: (504) 440-3555</span></em></strong></p>
    <p class="direccion"><br>
    <a target="_blank" href="http://www.technosdesign.com">www.technosdesign.com</a></p>
    </div>
    
     <?
    }
    
    else
    {
        // do your "its confirmed code"
        // for example, forward the user to a page (uncomment the line):
        // header("Location: http://url.com");
    }
    
    ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I don't understand the problem you are having, this is the correct idea (haven't gone through the code line by line though...).
    You have php that is populating html elements and applying the stylesheet to the elements. I see you are using your class in an list element, so it is applied (though the style can be combined into only one declaration). Watch your spelling as well, there is a 'java script:' in one of your calls which will not work. Also, your php calls from the inside of the code:
    <?=$_SERVER['PHP_SELF']?>
    I would not recommend. This may not work on all servers for starters, and _SERVER['PHP_SELF'] superglobal is also susceptible to XSS injections. A better option would be:
    <?php echo $_SERVER['SCRIPT_NAME'];?>
    where the two changes are the short tags are removed (<?= to <?php echo) and the semi-colon added at the end (which I believe is required regardless of the method of call).
    My final words are: don't develop using MS Office, it is not worth the headache. Although you have pulled it into xml/html code which is good, it will cause you headaches in the long run - especially since it tends to add garbage at the top of all your generated pages, and will kill a php script.

    Oh, and I made this assumption which I should not have. I assume that your file has been saved with a .php extension and that you are running it on a host with php capabilities. This won't actually change the stylesheet usage on the page, but obviously it won't parse as php if you don't have these.
    Hope that helps!

    EDIT
    Hmm, maybe I've completely mistook what you are looking for. I didn't notice that you had no linked stylesheet before.
    Assuming you have your stylesheet created (which I will not teach here, but the CSS forum will gladly help), you just link it into your HTML code's <head> tag like so:
    <link rel="stylesheet" type="stylesheet" href="path/to/my/stylesheet.css" />
    Where stylesheets generally have a .css extension.
    Last edited by Fou-Lu; 01-15-2008 at 01:40 AM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •