piedpiper Posted March 19, 2009 Share Posted March 19, 2009 Hi Guys I am new to PHP and the forum. I'm wondering if anyone can help me out with a css/php related issue. I have some php code that pulls its info from Mysql database and displays as a link. What I want to do is style the 'a href' links in the red text below with an 'a class' property from an external css style sheet. I just can't seem to get it. I've tried the standard <a class id="contact" href='mailto:$getlist3'>$getlist3</a> , which would work in HTML, but because it's in php it doesn't. I've also tried adding a <div id="property"> around the <?php brackets but that doesn't work either. Also I can't seem to add a <div id="property"> class from the css style sheet to style the normal text in the 'Print' statment. This is what I have so far. Any help would be much appreciated! <?php include "../connect.php"; $getlist="SELECT * from mailing_list order by email ASC"; //select e-mails in ABC order $getlist2=mysql_query($getlist) or die("Could not get list"); ?> <table border="0"><tr id="heading"><td>Email...</td><td>Date Joined...</td><td>Validated...</td><td>Delete...</td></tr> <?php while($getlist3=mysql_fetch_array($getlist2)) { print "<tr><td><a href='mailto:$getlist3'>$getlist3</a></td><td>$getlist3[datejoined]</td><td>$getlist3[validated]</td><td><a href='deluser.php?ID=$getlist3[userID]'>Delete</a></td></tr>"; } ?> </table> Quote Link to comment Share on other sites More sharing options...
dropfaith Posted March 19, 2009 Share Posted March 19, 2009 <a class id="contact" href='mailto:$getlist3'>$getlist3</a> isnt corrent you can use a class or an id <a class="contact" href='mailto:$getlist3'>$getlist3</a> <a id="contact" href='mailto:$getlist3'>$getlist3</a> your css differs based on your choice .contact{would be your css for classes} #contact {would be your css for ids} other then that it should work okay make sure its printing out the proper html to verify that its how you expect it Quote Link to comment Share on other sites More sharing options...
piedpiper Posted March 19, 2009 Author Share Posted March 19, 2009 Sorry dropfaith. That '<a class id' was a typo I didn't catch. Actually boths classes and id's work fine in html, but for some reason when its in the Print statement nested in the php tags, neither the id nor class works. The browser just shows a blank page. Quote Link to comment Share on other sites More sharing options...
dropfaith Posted March 19, 2009 Share Posted March 19, 2009 if its a blank page then its a php error more then likely as its not printing anything // Report all PHP errors error_reporting(E_ALL); add thast to the top of the nscript and see what happens Quote Link to comment Share on other sites More sharing options...
piedpiper Posted March 23, 2009 Author Share Posted March 23, 2009 Ok, managed to nut it out using php within html, rather than the other way around. This then lets the CSS properties apply to the layout. Thought I'd post it up in case anyone wants to know. And Dropfaith, thanks for the error_reporting tip I didn't know you could do that. Will help me lots in the future! <?php include "../connect.php"; $getlist = mysql_query("SELECT * from mailing_list order by email ASC") or die("Could not get list"); //select e-mails in ABC order ?> <table border="0"><tr id="heading"> <td>Email...</td><td>Date Joined...</td><td>Validated...</td><td>Delete...</td></tr> <?php while($result=mysql_fetch_array($getlist)){ ?> <tr><td><a class="contact" href="mailto:<?php echo $result['email'];?>"><?php echo $result['email'];?></a></td> <td><?php echo $result['datejoined'];?></td> <td><center><?php echo $result['validated'];?></center></td> <td><a class="contact" href="deluser.php?ID=<?php echo $result['userID'];?>">Delete</a></td></tr> <?php } ?> </table> 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.