Results 1 to 5 of 5

Thread: PHP link to CSS page.

  1. #1
    Senior Member j1979's Avatar
    Join Date
    Apr 2007
    Location
    Mars
    Posts
    2,038
    Thanks
    339
    Thanked
    209 times in 143 posts

    PHP link to CSS page.

    Hi hopefully someone can help me with my script. I have a mysql database query in php script that outputs a html table. I want to use a style sheet that works on the same page below. The bottom part of the sript is HTML with php variables inside, and this works very well. But the top example is the other way around....Php script with html inside... I have tried putting the link to the stylesheet with <link rel="stylesheet" type="text/css" href="http://localhost/stylesheet.css" /> the same as the example at the bottom but get the following error "syntax error, unexpected T_STRING "

    does anyone know how to link to the style sheet so that it works like the bottom example but in the top (PHP) example?

    PHP EXAMPLE NOT WORKING (works but not with CSS link)

    for($i=0;$i<count($_SESSION['somevar']);$i++)

    {
    if($_SESSION['somevar'][$i]!=NULL)

    echo("<table>
    <tr>
    <td>Train № ".$_SESSION['somevar'][$i]."&nbsp;"."</td>
    <td>on ".$_SESSION['somevar'][$i]."&nbsp;"."</td>
    <td>from ".$_SESSION['somevar'][$i]."&nbsp;"."</td>
    <td>to ".$_SESSION['somevar'][$i]."&nbsp;"."</td>
    <td>to ".$_SESSION['somevar'][$i]."&nbsp;"."</td>
    <td>№ of ".$_SESSION['somevar'][$i]."&nbsp;"." tickets ".$_SESSION['somevar'][$i]."&nbsp;"."</td>
    <td>at ".$_SESSION['somevar'][$i]." each"."</td>
    </tr>
    </table>");

    }

    ?>



    HTML EXAMPLE WORKING

    <link rel="stylesheet" type="text/css" href="http://localhost/stylesheet.css" />
    <form id="bookform<?php echo($i) ?>" method="post" action="">
    <input type="hidden" name="somevar" value="<?php echo($row['somevar'])?>" />

    </form>
    <table class="special-tablestyle-b">
    <td>
    <th>some text <?php echo($row['somevar'])?></th>
    <th>some text <?php echo($row['somevar'])?></th>
    <th>some text </th>
    <th>some text <?php echo($row['somevar'])?></th>
    <th>some text <?php echo ($_REQUEST['somevar'])?></th>
    <th>(Duration)</th>
    </td>
    </table>

  2. #2
    HEXUS.social member Agent's Avatar
    Join Date
    Jul 2003
    Location
    Internet
    Posts
    19,185
    Thanks
    739
    Thanked
    1,614 times in 1,050 posts

    Re: PHP link to CSS page.

    You can echo the content out you want without a problem, just make sure you escape the string : http://php.net/manual/en/language.types.string.php

    echo "This is an example of a \"quotes\" in a string";

    Will display:
    This is an example of a "quotes" in a string
    You can use the same method to embed your HTML

    How have you got onto server variables and loops without learning string functions?
    Quote Originally Posted by Saracen View Post
    And by trying to force me to like small pants, they've alienated me.

  3. #3
    Senior Member j1979's Avatar
    Join Date
    Apr 2007
    Location
    Mars
    Posts
    2,038
    Thanks
    339
    Thanked
    209 times in 143 posts

    Re: PHP link to CSS page.

    Quote Originally Posted by Agent View Post
    You can echo the content out you want without a problem, just make sure you escape the string : http://php.net/manual/en/language.types.string.php

    echo "This is an example of a \"quotes\" in a string";

    Will display:

    You can use the same method to embed your HTML

    How have you got onto server variables and loops without learning string functions?
    Thanks....for the suggestion

    I learn as I go, and borrow from other scripts, and a lot of trail and error. I built a few sites a while back and then forget everything.

    For my latest project, I have the scripts functioning correctly and now im trying to make it look pretty,

  4. #4
    Registered+
    Join Date
    Nov 2012
    Posts
    28
    Thanks
    0
    Thanked
    1 time in 1 post

    Re: PHP link to CSS page.

    Have you seen jquery UI themeroller?

    I almost never bother spending time prettifying a site nowadays - chances are, jquery UI already has something to do the job that is customisable, and looks great

  5. #5
    Registered+
    Join Date
    Jan 2013
    Posts
    20
    Thanks
    0
    Thanked
    2 times in 2 posts

    Re: PHP link to CSS page.

    To tidy things up somewhat and as part of your development in learning PHP you may want to consider taking a look at "Smarty". This is a fairly well known Template engine for PHP and has an easy to use syntax for building your templates.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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