andy_b_1502 Posted June 14, 2012 Share Posted June 14, 2012 Hi everyone, <?PHP session_start(); include('php only scripts/db.php'); $id = $_GET['id']; $query ="SELECT * FROM companies WHERE id = '$id'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); ?> <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] . "<br>email: " . $row['email'] . "<br>website: " . $row['website'] ; ?> The above code, is displayed after a search.... The website section: ""<br>website: " . $row['website'] ; " is where i'd like to know how to link to the users website, how do i do this as the websites are going to be different everytime, is it something like this: <a href="$website?id=<?PHP echo $row['id']; ?>">"<br>website: " . $row['website'] ; </a> so when clicked the user is sent to the specific website? Quote Link to comment Share on other sites More sharing options...
gristoi Posted June 14, 2012 Share Posted June 14, 2012 <?php session_start(); include('php only scripts/db.php'); $id = $_GET['id']; $query ="SELECT * FROM companies WHERE id = '$id'"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $websiteUrl = $row['website'].'?id='.$row['id']; echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] . "<br>email: " . $row['email'] . "<br>website: <a href='$websiteUrl'>" . $row['website'].'</a>' ; } ?> Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 Thanks gristoi, How do i make that clickable to go to the url? Quote Link to comment Share on other sites More sharing options...
gristoi Posted June 14, 2012 Share Posted June 14, 2012 its an anchor, it should be clickable by default Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 sorry, thats my fault, i meant; how can i get the (now clickable) link to actually visit the websites, as it's sending back to self at the minute. Quote Link to comment Share on other sites More sharing options...
gristoi Posted June 14, 2012 Share Posted June 14, 2012 if you mean open up in a new tab then add: target="_blank" into the anchor: "<br>website: <a href='$websiteUrl' target='_blank'>" . $row['website'].'</a>' ; Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 where do i add target="_blank" Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 sorry, ignore me! duh! you meant add target="_blank" to the code Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 Thanks so far, it's clickable, but when clicked it still redirects to self? not the url in the link? ex: www.example.com Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 the link is this: <a href="view00.php?id=<?PHP echo $row['id']; not the specific website link? Quote Link to comment Share on other sites More sharing options...
gristoi Posted June 14, 2012 Share Posted June 14, 2012 then the website value is not a url Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 the fields in the mySQL table under "website" will be though wont they? how do i get it to direct to the url in the table field? Quote Link to comment Share on other sites More sharing options...
gristoi Posted June 14, 2012 Share Posted June 14, 2012 where did view00.php come from? Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 i dont know? view00.php is the view page (passing the id to create a specific company view page) it is what the website url's are on... The newly created link for those url's has that path to it? where it should have the users website url instead Quote Link to comment Share on other sites More sharing options...
Jessica Posted June 14, 2012 Share Posted June 14, 2012 If $row contains the url, just echo that URL instead of adding it to the end of your view00.php page. Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 If it is echo'd will that be clickable/usable though? Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted June 14, 2012 Share Posted June 14, 2012 If you view the browser source, what does it show? Post here, please. (just the <a> reference, and not a million lines of code) Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 <!DOCTYPE html> <head> <title>Removalspace.com</title> <style type="text/css"> <!-- body { background-image: url(styles/downloaded%20styles/todo/todo/images/bg.png); } --> </style> <link href="styles/downloaded styles/todo/todo/css/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/style9.css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/demo.css" /> <link href='http://fonts.googleapis.com/css?family=Terminal+Dosis' rel='stylesheet' type='text/css' /> <style type="text/css"> <!-- .Stile1 {color: #333333} --> </style> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-31656176-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body> <!--start container --> <div id="container"> <header> <nav> <div id="logo"><a href="index.php"><img src="images/header2.png" alt="Logo here" width="219" height="161" /></a> </div> <div id="search-top"><img src="styles/downloaded styles/todo/todo/images/quote-right.png" alt="images" /><span class="cursive">Enter your postcode here</span><img src="styles/downloaded styles/todo/todo/images/quote-left.png" alt="images" /> <form method="post" action="search.php"> <input type="text" name="strSearch" onFocus="if(this.value=='Search Area')this.value='';" onBlur="if(this.value=='')this.value='Search Area';" value="Search Area" id="search-field"/> <input type="submit" value="" id="search-btn"/> </form> </div> <div id="nav_social"><a href="http://www.facebook.com/pages/Removalspace/181434181939226"><img src="styles/downloaded styles/todo/todo/images/facebook_32.png" alt="Become a fan" width="32" height="32" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/twitter_32.png" alt="Follows on Twitter" /></a><a href="id=183427956&trk=tab_pro"><img src="styles/downloaded styles/todo/todo/images/linkedin_32.png" alt="Linked in" /></a><a href="contact.php"><img src="styles/downloaded styles/todo/todo/images/email_32.png" alt="Contact" width="32" height="32" /></a><!-- Place this tag where you want the +1 button to render --> <g:plusone size="small" annotation="inline"></g:plusone> <!-- Place this render call where appropriate --> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> </div> </nav> </header> <p><figure><a href="removals.php">Search Removals</a></figure> |</p> <p><figure><a href="storage.php">Search Storage</a></figure> |</p> <p><figure><a href="register00.php">Add Listing</a></figure> |</p> <p><figure><a href="about.php">About</a></figure> |</p> <p><figure><a href="contact.php">Contact</a></figure> |</p> <p><figure><a href="login00.php">Login</a></figure></p> <div class="content"> <!--star main --> <main></main> <!--end main --> <!--start middle --> <middle> <div class="section_slogan"><table> <tr> <td valign="top"><div class="abox"> <figure> <fcapion> <h1><img src="images/thumbs/logo_1.jpg" alt="logo"/></h1> </fcaption></figure></div></td> <td valign="top"> <div class="abox"> <figure> <fcapion> <h1>Tennyson Lodge,<br>12 Tennyson Road,<br>Worthing,,BN11 4BY<br>phone: 01903201111<br>email: info@domesticremoval.co.uk<br>website: <a href='' target='_blank'>www.a1worthingmoves.com</a></h1> </fcaption></figure> </div> </td> </tr> <tr> <td><div class="abox"> <figure> <fcapion> <h1>Company description: <hr>no description set - please log in to edit.</h1> </fcaption></figure> </div></td> </tr></table></div> </middle> </div> <!--end middle --> <!--start footer --> <footer> <div id="footer"></div> </footer> <!--end footer --> </div> <!--end container --> <!-- Free template distributed by http://freehtml5templates.com --> </body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> </html> Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted June 14, 2012 Share Posted June 14, 2012 just the <a> reference' date=' and not a million lines of code[/quote'] ^ Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 dont tut but tell me how to view the browser source for just the <a> reference lol Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 hold the phone iv'e found it sorry it's: <a href="" target="_blank">www.a1worthingmoves.com</a> so it seems like its working but it doesn't got to that particular site? Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted June 14, 2012 Share Posted June 14, 2012 Wowza's. I wasn't expecting that reply. I just meant for you point post the single line that has the anchor tag on it so I don't have to go sifting through a bunch of lines of completely irrelevant code. I just want to see what's being outputted to the page to see what the issue might be. In fear of this going back and forth for 20 minutes, I believe this is the line in question: <h1>Tennyson Lodge,<br>12 Tennyson Road,<br>Worthing,,BN11 4BY<br>phone: 01903201111<br>email: info@domesticremoval.co.uk<br>website: <a href='' target='_blank'>www.a1worthingmoves.com</a></h1> And even more specifically: <a href='' target='_blank'>www.a1worthingmoves.com</a> As you can see, the website is not being included within the href='' attribute. That's why when you click the link it just takes you back to the same page... 'cause leaving that blank makes a reference to the current page. Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 lol okay... <?PHP echo $row['street1'] . "<br>" . $row['street2'] . "<br>" . $row['city'] . "," . $row['postcode'] . "<br>phone: " . $row['phone'] . "<br>email: " . $row['email'] . "<br>website: <a href='$website' target='_blank'>" . $row['website'].'</a>' ; ?> maybe you could tell me why it's blank as i dont have a clue! Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted June 14, 2012 Share Posted June 14, 2012 Change: "<br>website: <a href='$website' target='_blank'>" . $row['website'].'</a>' ; to: "<br>website: <a href='http://". $row['website'] ."' target='_blank'>" . $row['website'].'</a>'; Quote Link to comment Share on other sites More sharing options...
andy_b_1502 Posted June 14, 2012 Author Share Posted June 14, 2012 interesting 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.