dazzathedrummer Posted March 26, 2010 Share Posted March 26, 2010 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 Quote Link to comment Share on other sites More sharing options...
cags Posted March 26, 2010 Share Posted March 26, 2010 Use full/static URLs rather than relative or change any URLs to be relative to the file that is doing the 'include'. Not the location the included file is in. Quote Link to comment Share on other sites More sharing options...
dazzathedrummer Posted March 26, 2010 Author Share Posted March 26, 2010 Use full/static URLs rather than relative or change any URLs to be relative to the file that is doing the 'include'. Not the location the included file is in. Sorry - I'm not following, guard_admin2.php is finding giglist.php through the include - its just not displaying as i expect it too. Quote Link to comment Share on other sites More sharing options...
cags Posted March 26, 2010 Share Posted March 26, 2010 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. Quote Link to comment Share on other sites More sharing options...
dazzathedrummer Posted March 26, 2010 Author Share Posted March 26, 2010 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 Quote Link to comment Share on other sites More sharing options...
dazzathedrummer Posted March 26, 2010 Author Share Posted March 26, 2010 Correction - sorry. giglist.php does not contain embeded CSS - it has a specifically formatted table. The row and cell heights are not being recognised when used as an include. Quote Link to comment Share on other sites More sharing options...
cags Posted March 26, 2010 Share Posted March 26, 2010 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 Quote Link to comment Share on other sites More sharing options...
dazzathedrummer Posted March 26, 2010 Author Share Posted March 26, 2010 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 Quote Link to comment Share on other sites More sharing options...
cags Posted March 26, 2010 Share Posted March 26, 2010 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" /> Quote Link to comment Share on other sites More sharing options...
dazzathedrummer Posted March 26, 2010 Author Share Posted March 26, 2010 almost there now!! i'd deleted the closing table tag! I cant seem to get the images to 'align="top"' they seem to default to bottom (valign doesnt work either). I read about using css float, but that only seems to do left and right?? Quote Link to comment Share on other sites More sharing options...
cags Posted March 26, 2010 Share Posted March 26, 2010 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. Quote Link to comment Share on other sites More sharing options...
dazzathedrummer Posted March 26, 2010 Author Share Posted March 26, 2010 i'll try that - thanks for all your help!! darren Quote Link to comment 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.