Jump to content

CSS/formatting problem when using an include


dazzathedrummer

Recommended Posts

Hi,

 

I've constructed a table that gets data from a database, I've formatted the .php how I want it to show, but when I 'include' it in another page the formatting goes wrong, i'm sure its some kind of CSS prority problem. can anyone tell me how preserve the format in the php file - basically I want each row to be as high as the image in the first cell.

 

giglist.php -> www.the-guards.org.uk/private/giglist.php

 

Included in -> www.the-guards.org.uk/private/guard_admin2.php

 

 

Link to comment
Share on other sites

Yes, which is likely because it can't find the CSS/JS (or any other files it relies on). If guard_admin2.php and giglist.php are not in the same directory, the links in giglist.php will need to be relative to the file they are included in, not to where it is located.

Link to comment
Share on other sites

Yes, which is likely because it can't find the CSS/JS (or any other files it relies on). If guard_admin2.php and giglist.php are not in the same directory, the links in giglist.php will need to be relative to the file they are included in, not to where it is located.

 

ok, guard_admin.php and giglist.php are in the same directory, the CSS for guard_admin.php is not in the same directory but it is referenced correctly.

 

I think my problem is that giglist.php contains embeded CSS and that is not being executed when it is used as an include.

The CSS for guard_admin.php does not contain any references to giglist.php

Link to comment
Share on other sites

Ahh if they are in the same directory then that won't be the problem. In that case it is probably likely because you don't have a DOCTYPE on the file where it's on it's own, so the browser doesn't follow a set of rules to display it. Whereas when included the rules are being applied. I suggest you look at fixing the validation errors as they are the number 1 cause of layout headaches.

 

http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.the-guards.org.uk%2Fprivate%2Fguard_admin2.php

Link to comment
Share on other sites

excellent thanks for the link, i've managed to clean everything up but I think now i've broken the IMG tags in the php.

 

I cant spot where it might be going wrong and my server doesn't give me errors (and I cant figure out why apache wont run on my laptop).

 

can anyone spot why this wont run: -

<?php
// Connects to your Database 
mysql_connect("database.lcn.com", "LCN_7792", "theguards9402") or die(mysql_error()); 
mysql_select_db("the_guards_org_uk_users") or die(mysql_error()); 

$query  = "SELECT (left(LCASE(monthname(gl_date)),3)) as 'month', day(gl_date) as 'day',gl_date, gl_venue, gl_venue, gl_city, gl_postcode, gl_phone, gl_contact, gl_net, gl_comments FROM tg_gig_list order by gl_date desc";
$result = mysql_query($query);

echo'

<h1>Gigs</h1>
<table border="0"><tr>
<th>Image</th>
<th>Month</th>
<th>day</th>
<th>Venue</th>
<th>City</th>
<th>Postcode</th>
<th>Phone</th>
<th>Contact</th>
<th>Net</th>
<th>Comments</th>
</tr>';
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo 
"
<tr>
<td style=\"height:80; width:80;\">
<img height=\"79\" width=\"79\" alt=\"calendarpic\" style=\"position:absolute;display:block;z-index:1;\" src=\"calpics/background.png\">
<img height=\"79\" width=\"79\" alt=\"calendarpic1\" style=\"position:absolute;z-index:2;\" src=\"calpics/{$row['day']}.png\">
<img height=\"79\" width=\"79\" alt=\"calendarpic2\" style=\"position:absolute;z-index:3;\" src=\"calpics/{$row['month']}.png\"></td>".
"<td>{$row['month']}</td>".
"<td>{$row['day']}</td>".
"<td>{$row['gl_venue']}</td>".
"<td>{$row['gl_city']}</td>".
"<td>{$row['gl_postcode']}</td>".
"<td>{$row['gl_phone']}</td>".
"<td>{$row['gl_contact']}</td>".
"<td>{$row['gl_net']}</td>".
"<td>{$row['gl_comments']}</td></tr>";

}
</tr>
</table>';
echo $row;
mysql_close();
?>

 

thanks

 

Link to comment
Share on other sites

All sizes used in your code should probably have a unit type. For example '80' should be '80px'. The IMG tags aren't valid XHTML because they don't 'self close'. For any tag that doesn't include a closing tag it should have a forward slash just before the '>'.

 

Example:

 

<img src="something.gif" />

Link to comment
Share on other sites

On that one I can't really help, CSS is really not my forte, it might be aswell to mark this topic as solved and start a new one in the HTML/CSS board regarding image alignment. My best suggestion would be setting valign="top" on the <td> that the images are in.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.