Jump to content

oz11

Members
  • Posts

    67
  • Joined

  • Last visited

Everything posted by oz11

  1. Just tried that. Changed the id names around. Unlucky though it cannot be that simple, for me even, as when i do nothing shows. function getLinkTree($pdo, $url, $index) { $res = str_replace(array('https://www.', 'http://www.', 'https://','http://'), '', $url); $stmt = $pdo->prepare("SELECT url, reference FROM links WHERE url LIKE ?"); $stmt->execute(["%$res%"]); echo "<br><div id='tom' class='mydiv'>"; while ($row = $stmt->fetch()) { //<a href='out.php?ref=" . $row['reference'] . "' target='_blank'> echo "<a style='color: black;' target='_blank' href='out.php?ref=". $row['reference'] ."'>".$row['url']."</a><br />"; } echo "</div>"; } function getLinkSimilar($pdo, $url, $index) { $res = str_replace(array('https://www.', 'http://www.', 'https://','http://','.com', '.com/', '.co.uk', 'co.uk/', '.is', '.is/', 'news.', 'shopping.'), '', $url); $stmt = $pdo->prepare("SELECT url, reference FROM links WHERE url LIKE ?"); $stmt->execute(["%$res%"]); echo "<br><div id='jerry' class='mydiv'>"; while ($row = $stmt->fetch()) { //<a href='out.php?ref=" . $row['reference'] . "' target='_blank'> echo "<a style='color: black;' target='_blank' href='out.php?ref=". $row['reference'] ."'>".$row['url']."</a><br>"; } echo "</div>"; } Strangely it only works with $index, well half of it anyway. Atm. It's not even as if there is a class/id block of code to attach. just works kinda. Edit: There is definitely a bug here but dont know what.
  2. hmm.. not sure why that's there. Might need to test the option here.. Though some testing: When I remove both of the id ($index), then the boxes stop appearing. However, and this is cool,.. wait for it... when I remove the one from getLinkTree and keep the one in getLinkSimilar then suddenly the second box starts working (!), but not the first one (getLinkTree). Suggestions? Just need to manage both to work here. Right? Sorry my grammer is bad. But the good thing is that we seem to be getting there.
  3. is this ok then?.. echo "<br><a href='#' onclick='showDiv($index)' style='float: right; margin-top: -6px; margin-right: 8px;'>Show domain linkage</a>"; echo getLinkTree($pdo, $row['url'], $index); echo "<br><a href='#' onclick='showDiv($index)' style='float: right; margin-top: -6px; margin-right: 8px;'>Show similar linkage</a>"; echo getLinkSimilar($pdo, $row['url'], $index);
  4. Was thinking that doing something like this would work,.. echo "<br><a href='#' onclick=\"showDiv(".$index.")\" style='float: right; margin-top: -6px; margin-right: 8px;'>Show domain linkage</a>"; echo getLinkTree($pdo, $row['url'], $index); echo "<br><a href='#' onclick=\"showDiv(".$index.")\" style='float: right; margin-top: -6px; margin-right: 8px;'>Show similar linkage</a>"; echo getLinkSimilar($pdo, $row['url'], $index); to echo "<br><a href='#' onclick=\"showDiv(".$index.")\" style='float: right; margin-top: -6px; margin-right: 8px;'>Show domain linkage</a>"; echo getLinkTree($pdo, $row['url'], $index); echo "<br><a href='#' onclick=\"showDiv2(".$index.")\" style='float: right; margin-top: -6px; margin-right: 8px;'>Show similar linkage</a>"; echo getLinkSimilar($pdo, $row['url'], $index); But to no avail Edit: see "showDiv2": separation between code
  5. Just thought it would be simple like the one i did before., which worked independently but causes conflict with the other. it seems.
  6. i will go your simpler way without concatenation then. Still just displaying content from the first link though after edit.. :S
  7. I changed the code to as you suggested (well, a little different. See bellow. However when i click either of the links I'm getting the "Show domain linkage" results, though they should be different. "Show domain linkage "vs. "Show similar linkage"
  8. Ok. I made the following changes: removal of redundant id ("tree") relocated css in to class -- background colour etc change css background repetition added double quotes. Changed to: echo "<br><div id=\"".$index."\" class='mydiv'>"; Still the second link "Show similar linkage" is not responding. It only brings up the link above it (Show domain linkage) Help. I've tried simply adding another section of JS to be showDiv() and showDiv2(), but did not work
  9. Hey. This is how it shows atm when enabling "display: block;" on the second drop down box for "show similar linkage". The "show domain linkage" button/link works fine and shows its content.. though I connot get "Show simiar linakge" to work on click to show its content, and only shows when enabling block in the code. Here are some of the sections of code: JS: <script type='text/javascript'> function showDiv(id) { let thediv = document.getElementById(id) if (thediv.style.display == "block") { thediv.style.display = "none" } else { thediv.style.display = "block" } } </script> Style: <style type='text/css'> .mydiv { display: none; } .mydiv2 { display: block; } </style> Functions: function getLinkTree($pdo, $url, $index) { $res = str_replace(array('https://www.', 'http://www.', 'https://','http://'), '', $url); $stmt = $pdo->prepare("SELECT url, reference FROM links WHERE url LIKE ?"); $stmt->execute(["%$res%"]); echo "<br><div id='".$index."' class='mydiv' style='float: right; background-color: white; background-color:rgba(255,255,255, 0.5); border: 1px solid grey; padding: 6px;' id='tree'>"; while ($row = $stmt->fetch()) { //<a href='out.php?ref=" . $row['reference'] . "' target='_blank'> echo "<a style='color: black;' href='out.php?ref=". $row['reference'] ."'>".$row['url']."</a><br />"; } echo "</div>"; } function getLinkSimilar($pdo, $url, $index) { $res = str_replace(array('https://www.', 'http://www.', 'https://','http://','.com', '.com/', '.co.uk', 'co.uk/', '.is', '.is/', 'news.', 'shopping.'), '', $url); $stmt = $pdo->prepare("SELECT url, reference FROM links WHERE url LIKE ?"); $stmt->execute(["%$res%"]); echo "<div id='".$index."' class='mydiv2' style='float: right; background-color: white; background-color:rgba(255,255,255, 0.5); border: 1px solid grey; padding: 6px;' id='tree'>"; while ($row = $stmt->fetch()) { //<a href='out.php?ref=" . $row['reference'] . "' target='_blank'> echo "<a style='color: black;' href='out.php?ref=". $row['reference'] ."'>".$row['url']."</a><br>"; } echo "</div>"; } And displaying (section).... echo "<br><a href='#' onclick=\"showDiv(".$index.")\" style='float: right; margin-top: -6px; margin-right: 8px;'>Show domain linkage</a>"; echo getLinkTree($pdo, $row['url'], $index); echo "<br><a href='#' onclick=\"showDiv(".$index.")\" style='float: right; margin-top: -6px; margin-right: 8px;'>Show similar linkage</a>"; echo getLinkSimilar($pdo, $row['url'], $index); echo "</span></small></li>"; .. as you can see. the functions are very similar but work independently so need two drop-down boxes. Atm, the second div stays open, because its set as "block" though when i set it as "none" it does not open on click. Not sure how to approach this one..
  10. Edited the code so that its ... and.. <script type='text/javascript'> function showDiv(id) { let thediv = document.getElementById(id) if (thediv.style.display == "block") { thediv.style.display = "none" } else { thediv.style.display = "block" } } </script> and realised now when i click on the onclick'd "Show linked" link twice that the boxes disappear. Weird. Seems i'm going in the right direction, just doint understand why they are open to begin with and disappear on a double click. Obviously, it needs to be hidden to begin with and apear on a single click. Edit: Also, I just edited the stylesheet so that the id's start with a letter rather than number... function getLinkTree($pdo, $url, $index) { $res = str_replace(array('https://www.', 'http://www.', 'https://','http://'), '', $url); $stmt = $pdo->prepare("SELECT url FROM links WHERE url LIKE ?"); $stmt->execute(["%$res%"]); echo "<br><div id='s".$index."' style='float: right; background-color: white; border: 1px solid grey;'>"; while ($row = $stmt->fetch()) { echo $row['url']."<br />"; } echo "</div>"; } #mydiv { display: none; } #s0 { display: none; } #s1 { display: none; } #s2 { display: none; }
  11. Edited like this: And now displays like this,,.. Does this look OK to you:
  12. echo "<br><a href='#' onclick='showDiv(\"".$index."\")' style='float: right; margin-top: -6px;'>Show linked</a>"; echo getLinkTree($pdo, $row['url'], $index); points to ... function getLinkTree($pdo, $url, $index) { $res = str_replace(array('https://www.', 'http://www.', 'https://','http://'), '', $url); $stmt = $pdo->prepare("SELECT url FROM links WHERE url LIKE ?"); $stmt->execute(["%$res%"]); echo "<br><div id='mydiv' style='float: right; background-color: white; border: 1px solid grey;'>"; while ($row = $stmt->fetch()) { echo $row['url']."<br />"; } echo "</div>"; } Is that ok/ what you needed? Sorry I was confused.
  13. Not sure at all how to handle the css display :S
  14. Started to use an $index increment instead now. But principles should remain the same. See:
  15. Sorry. Row is just a value from my database query. I'm using it as a unique identifier for the function parameter. But it could be anything with an incrementing value i believe. The website I'm applying the example to uses it. But the basis should still stay the same as I'm working on the example and the website together for this issue in synergy.
  16. So i edited.. <script type='text/javascript'> function showDiv() { let thediv = document.getElementById("mydiv") if (thediv.style.display == "block") { thediv.style.display = "none" } else { thediv.style.display = "block" } } </script> to... <script type='text/javascript'> function showDiv(id) { let thediv = document.getElementById(id) if (thediv.style.display == "block") { thediv.style.display = "none" } else { thediv.style.display = "block" } } </script> AND.. <br><a href='#' onclick='showDiv()'>Show linked</a> to.. <a href='#' onclick='showDiv('".$row['link_id']."')'>Show linked</a> What am I doing wrong now? :S
  17. My code is abit different .. for example.. <!DOCTYPE html> <html lang="en"> <head> <title>Sessions &amp; Terms</title> <meta charset="utf-8"> <style type='text/css'> #mydiv { display: none; } </style> </head> <body> <a href='#' onclick='showDiv()'>Show Div</a> <br> <div id='mydiv'> <h1>Hello, world</h1> </div> <a href='#' onclick='showDiv()'>Show Div</a><br> <div id='mydiv'> <h1>Hello, world</h1> </div> <a href='#' onclick='showDiv()'>Show Div</a><br> <div id='mydiv'> <h1>Hello, world</h1> </div> </body> </html> Do you know how i can make it so that the second and third open as well? This is more similar to how mine is laid out on my site. Obvs with differences in content etc.
  18. Problem is I have used it over once on the page (three to be exact) and it only works on the first one (opens), the other two just open the first one.. Help again plz.
  19. Hey. I'm writing some code which would look a lot cooler if it had a bit of JavaScript. It needs to be a link and when pressed a div or span is shown. Hidden to begin with and shown onclick. Problem is I suck at JS. Nothing fancy just dead basic. Any help please? Edit: I hve this working solution (bellow), but how do i change it so that it's not shown to begin with and then "show" when clicked... function show() { var divide = document.getElementById("info"); if (divide.style.display === "block") { divide.style.display = "block"; } else { divide.style.display = "none"; } } <div id="info">Testy</div> <button onclick="show()">Show/Hide</button> Thanks.
  20. Changed to and seems to work now. Thanks guys for being here.
  21. Been working on this part of my site,... <?php function getLinkTree($pdo, $url) { $res = str_replace(array('https://www.', 'http://www.', 'https://','http://'), '', $url); $stmt = $pdo->prepare("SELECT url FROM links WHERE url LIKE ?"); $stmt->execute(['%$res%']); while ($row = $stmt->fetch()) { echo $row['url']."<br />\n"; } } getLinkTree($pdo, "https://bbc.co.uk"); ?> Instead of it coming back with all the other urls which contain "bbc.co.uk" it doesnt do anything. However in phpmyadmin, when I run the query .. .. it brings back the correct results. What am I doing wrong guys and gals?
  22. Even though I was puzzled before, i think i found a solution.. $stmt = $pdo->prepare("SELECT expired FROM `users` WHERE user_id = ?"); $stmt->execute([$_SESSION['userID']]); $expire_check = $stmt->fetch(); echo $date = date('Y-m-d H:i:s'); echo "<br>"; ///echo $expire_check['expired']; // echo "<br>"; //echo $date1 = date($expire_check['expired'], strtotime('+ 3 minutes')); echo $newDate = date('Y-m-d H:i:s', strtotime($expire_check['expired']. ' +3 minutes')); if ($newDate > $date){ echo "<br>Too soon!"; } else { //echo "<br>spot on"; } thanks.
×
×
  • 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.