karenn1 Posted July 24, 2007 Share Posted July 24, 2007 Hey everyone! Please have a look at this site: http://www.yellowpages.co.za On the right there are business sections you can click on. Once in a section, there is details for all the relevant companies. Have a look at the link for "Phone". When you click on it, the link completely disappears and is replaced with the company telephone number. How can I use PHP to do this? I want to use this primarily on my site to keep track of how many times someone clicked on that link. Would I be able to do that as well? Thanks, Karen Quote Link to comment Share on other sites More sharing options...
eric1235711 Posted July 24, 2007 Share Posted July 24, 2007 Hello. That thing in yp may be done with JS. About doing that with PHP isn't that hard... Quote Link to comment Share on other sites More sharing options...
karenn1 Posted July 24, 2007 Author Share Posted July 24, 2007 I don't actually want to use JS. I'm not quite familiar with it. I have some basic knowledge in PHP so it's easier for me to implement things in PHP. How do you suggest I go about it? Does anybody else have an idea? Thanks, Karen Quote Link to comment Share on other sites More sharing options...
nicangeli Posted July 24, 2007 Share Posted July 24, 2007 Ok, i a m a noob, so this may not work. For each of the phone links i would submit them to the page using PHP_SELF. Then apply an id and a display variable to the url so each link looks like this, <a href="link.php?id=1&display=num">Phone</a> So then you can use php to either show the actual text phone or the phone number with an if statement, as shown below, <?php if ($_GET[display] = "num") { echo "080989779"; } else { echo '<a href="link.php?id=1&display=num">Phone</a> } ?> then to make it dynamic have a database set up with a phone numbers table with the fields id and phone. Then you can pull the correct number from the database using the id field. Hope this helps. Quote Link to comment Share on other sites More sharing options...
karenn1 Posted July 26, 2007 Author Share Posted July 26, 2007 Hey nicangeli, This makes sense. I'll give a try and let you know how it works. Thanks, Karen Quote Link to comment Share on other sites More sharing options...
karenn1 Posted July 26, 2007 Author Share Posted July 26, 2007 Okay, so i've tried the code given above and I managed to reference info from the database but clicking on the link doesn't do anything. The link looks as follows: <a href="phone_link.php?id=<?= $rs_prop["id"]; ?>&display=<?= $rs_prop['home_no']; ?>">Phone</a> $rs_prop is the variable where all the info of the database is stored. This gets called via a SQL statement. The above code returns the following: phone_link.php?id=1&display=9135756 The principle works fine. I have a list of clients and for each one when rolling over the above link it displays the correct ID and phone number. I'm still struggling though. Can can I get it, when you click on the above link, the link itself gets replaced with the phone number? I don't want the page to go anywhere. The if statement supplied by nicangeli gives me errors. Can anyone else help? Any help would be appreciated. Thanks! Karen Quote Link to comment Share on other sites More sharing options...
karenn1 Posted July 27, 2007 Author Share Posted July 27, 2007 Is there nobody who can help me with this? Please!! Karen 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.