Page 1 of 1

[solved] stupid css and php question

Posted: Thu Sep 15, 2005 6:11 am
by tom.cull
hey - very new to this all, am slowly getting my head around it all!

one quick question - hopefulyl you can point me in the right direction.

I use an external css to format all the text on my site however it does not format text from a php echo - is there something extra i need to do?

thanks

Posted: Thu Sep 15, 2005 7:40 am
by raghavan20

Code: Select all

<style>
.bold{
font-weight:bolder;
}
</style>
<span class = 'bold'>I should be bold</span>

Code: Select all

<?php
echo "<span class = 'bold'>I should be bold as well</span>";
?>
both of them work in the same way

Posted: Thu Sep 15, 2005 3:17 pm
by mendingo
The browser sees the HTML and CSS coming from the server. It has no idea if the code was straight HTML or created by PHP.

In other words, it doesn't matter whether you've echoed the code from php or not.

Use your web browser to view the resultant HTML code and see if you can tell why it is ignoring the css style.

Failing that, post your PHP here.

Posted: Fri Sep 16, 2005 5:17 am
by tom.cull
hmm - ok here is the code.

When looking at the results the page is formatted OK APART from everything outputting from an echo:



Code: Select all

<?php

if ($submit) {

$username="xxxx";
$password="xxxx";
$database="xxxx_xxxx";

$location_area=$_POST['location_area'];
$car_pbracket=$_POST['car_pbracket'];

mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

if ($location_area == '*') $location_area = "location_area"; 
else $location_area = "'$location_area'"; // notice the single quotes inside the double quotes 

if ($car_pbracket == '*') $car_pbracket = "car_pbracket"; 
else $car_pbracket = "'$car_pbracket'"; // notice the single quotes inside the double quotes



// retrieve all the rows from the database
   $query = "SELECT * FROM xxx_xxxWHERE (location_area LIKE $location_area) AND (car_pbracket LIKE $car_pbracket) AND (list_status='active')";
   
   $results = mysql_query( $query );

   // print out the results
   if( $results )
   {
      while( $contact = mysql_fetch_object( $results ) )
      {
         // print out the info
         $id = $contact -> id;
         $contact_nlast = $contact -> contact_nlast;
         $contact_nfirst = $contact -> contact_nfirst;
		 $car_make = $contact -> car_make;
		 $car_model = $contact -> car_model;
         echo( "<a href=\"showdetails.php?id={$id}\">{$id} . {$contact_nfirst}, {$contact_nlast} - {$car_make}, {$car_model}</a><br />" ); 
      }
   }
   else
   {
      die( "Trouble getting contacts from database: " . mysql_error() );
   }
}

?>


</body>
</html>
The html that is out put is :

Code: Select all

....
<p>&nbsp;</p>

<a href="showdetails.php?id=1">1 . Tom, Cull - Fiat, Punto</a><br /><a href="showdetails.php?id=8">8 . Steve, Wood - , </a><br /><a href="showdetails.php?id=3">3 . Curt, ockleford - Renault, Clio</a><br /><a href="showdetails.php?id=6">6 . Test234, Tets234 - , </a><br /><a href="showdetails.php?id=7">7 . Richard, Bevan - ford, mondeo</a><br /><a href="showdetails.php?id=9">9 . Steve, Wood - Rover, 18</a><br /><a href="showdetails.php?id=10">10 . Emily, Cull - Rover, </a><br />

</body>
</html>
ideas? thanks

Posted: Fri Sep 16, 2005 5:32 am
by raghavan20

Code: Select all

echo( "<a href=\"showdetails.php?id={$id}\">{$id} . {$contact_nfirst}, {$contact_nlast} - {$car_make}, {$car_model}</a><br />" );
I dont think you dont need curly braces around each variable. remove all of them. lets see how it comes

else try like

Code: Select all

<a href="showdetails.php?id=<?php echo $id; ?>"><?php echo $contact_nfirst.",".$contact_nlast."-".$car_make.",".$car_model?></a><br />

Posted: Fri Sep 16, 2005 5:48 am
by tom.cull
strange. I removed the curly brakets - not chahnge.

i did notice however that some of the css is working ie when I roll over the link it is displaying as specified - its just the type face that is not correct!

html is out put as :

Code: Select all

<a href="showdetails.php?id=1">1 . Tom, Cull - Fiat, Punto</a><br>

Posted: Fri Sep 16, 2005 5:53 am
by tom.cull
its ok - solved it - the echo wasnt outputting the HTML with <P> tags, meaning that the css didnt apply. I inserted <P> tags in to the echo and it works like a treat.