iQ:: Posted January 23, 2008 Share Posted January 23, 2008 Hey guys new to this forum so first of all hello to all. I got a small problem not sure how to fix it, basically i've got 2 files, say file 1 and file 2. File 1 is the main file and a php file and is the one that has the html code to load up the css file, File 2 is the extra php code that is imported into file 1 via the required call. The problem is that in file 2 I use php to create some html tags, mainly tables and the contents inside but the css rules aren't being applied to these tables and it's content, however the CSS rules still work on all the html tags on file 1. I'm guessing it's because file 2 it's being imported inside file 1? The CSS rules as usual is loaded up in the <head> tag in file 1 and file 2 is imported later on in the <body> tag. Anyone care to help me out please? thank you. Quote Link to comment https://forums.phpfreaks.com/topic/87364-solved-cant-get-css-working-with-imported-php/ Share on other sites More sharing options...
adam291086 Posted January 23, 2008 Share Posted January 23, 2008 Show use how in your script how you are calling on the css properties within your php. For the main file. We can't help without seeing code. Don't forget to place the code inbetween Quote Link to comment https://forums.phpfreaks.com/topic/87364-solved-cant-get-css-working-with-imported-php/#findComment-446867 Share on other sites More sharing options...
iQ:: Posted January 23, 2008 Author Share Posted January 23, 2008 This is the code to load up my CSS file. <link rel="stylesheet" href="/css_files/nbstyle.css" /> Quote Link to comment https://forums.phpfreaks.com/topic/87364-solved-cant-get-css-working-with-imported-php/#findComment-446869 Share on other sites More sharing options...
rajivgonsalves Posted January 23, 2008 Share Posted January 23, 2008 the php code which is not working! Quote Link to comment https://forums.phpfreaks.com/topic/87364-solved-cant-get-css-working-with-imported-php/#findComment-446870 Share on other sites More sharing options...
iQ:: Posted January 23, 2008 Author Share Posted January 23, 2008 oh right sorry, this is it: function getRecords($query, $table, $no_of_records, $pos) { //apply the given query on the given table with the limit clause, if unsuccessful generate an error message $result = mysql_query($query . $table . " LIMIT " . $pos . "," . $no_of_records) or die(errorMessage('Error Encountered, the following error was recieved:')); if(@mysql_num_fields($result)>0 && mysql_num_rows($result)>0) { echo '<table border="1" width="100%" cellpadding="5" cellspacing="5">'; //create the column headers and have it formatted echo '<thead> <tr><th>Record No</th>'; for($i=0; $i<mysql_num_fields($result); $i++) { echo '<th>' . mysql_field_name($result, $i) . '</th>'; } echo '</tr></thead>'; echo '<tbody>'; //create the table body and seperate from table headers for($i=1; $i<=mysql_num_rows($result); $i++) //loop through each field of the recordset { $row = mysql_fetch_row($result); //retrieve a row from the resultset echo '<tr>'; $counter = $pos+$i; //keeps a track of the record number in the result //put the record number besides the actual record echo '<td class="recordNo">' . $counter . '</td>'; foreach($row as $cell) { echo '<td>' . $cell . '</td>'; } echo '</tr>'; } echo '</tbody>'; echo '</table>'; mysql_free_result($result); } } and the actual css code is this: body { font-family: arial; font-size: small; } table { border-width: 0px; padding: 5px; width: 100% } table.navbar { margin: 0px 0px 50px 0px; padding: 0px 0px 0px 0px; border-width: 0px; } td { text-align: center; padding: 5px; margin: 5px } td.recordNo { font-family: Arial; color: Navy; font-weight: bold } th { text-align: center; padding: 5px; margin: 5px; font-family: arial; color: yellow; font-size: large; font-weight: bold; background-color: black } a { text-decoration: none } a:link { color: Blue } a:visited { color: Blue } a:hover { color: Red } a:active { color: Cyan } Quote Link to comment https://forums.phpfreaks.com/topic/87364-solved-cant-get-css-working-with-imported-php/#findComment-446875 Share on other sites More sharing options...
adam291086 Posted January 23, 2008 Share Posted January 23, 2008 try function getRecords($query, $table, $no_of_records, $pos) { //apply the given query on the given table with the limit clause, if unsuccessful generate an error message $result = mysql_query($query . $table . " LIMIT " . $pos . "," . $no_of_records) or die(errorMessage('Error Encountered, the following error was recieved:')); if(@mysql_num_fields($result)>0 && mysql_num_rows($result)>0) { echo "<table border=\"1\" width=\"100%\" cellpadding=\"5\" cellspacing=\"5\">"; //create the column headers and have it formatted echo "<thead><tr><th>Record No</th>"; for($i=0; $i<mysql_num_fields($result); $i++) { echo "<th>.mysql_field_name($result, $i) .</th>"; } echo "</tr></thead>"; echo "<tbody>"; //create the table body and seperate from table headers for($i=1; $i<=mysql_num_rows($result); $i++) //loop through each field of the recordset { $row = mysql_fetch_row($result); //retrieve a row from the resultset echo "<tr>"; $counter = $pos+$i; //keeps a track of the record number in the result //put the record number besides the actual record echo "<td class=\"recordNo\">' . $counter . "</td>"; foreach($row as $cell) { echo "<td>.$cell.</td>"; } echo "</tr>"; } echo "</tbody>"; echo "</table>"; mysql_free_result($result); } } Quote Link to comment https://forums.phpfreaks.com/topic/87364-solved-cant-get-css-working-with-imported-php/#findComment-446883 Share on other sites More sharing options...
iQ:: Posted January 23, 2008 Author Share Posted January 23, 2008 wow thanks a lot, that worked. So it was because I was using single quotes instead of double quotes? i'm still quite new to php, it's been about a month i've started learning, guess there are many little details I need to catch. the main reason I used single quotes was because I thought it would be quicker instead of having to escaping each double quote in the html tag. So could you guys tell me an explanation on how single quotes cancelled out the css rules? will help me in the future before I use single quotes on anything and after this will be the end of my query. thanks Quote Link to comment https://forums.phpfreaks.com/topic/87364-solved-cant-get-css-working-with-imported-php/#findComment-446919 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.