Jump to content

phorcon3

Members
  • Posts

    177
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male
  • Location
    Austria

phorcon3's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. $str = preg_replace('/('.$word.')/i', '<em>\1</em>', $str); how come this doesn't work when $word = 'http://www.google.com', or any other URL?
  2. MySQL "table" id1 | id2 1 | 2 1 | 3 2 | 4 2 | 3 3 | 4 3 | 5 WHERE id1 = 1, this id is connected to 2 and 3 1->2 1->3 and what i want to do is output the ids of 2 and 3 which are NOT connected to 1, which in this particular case would be 4 and 5. 2->4 (1 is NOT connected to 4 = OK) 2->3 (1 is connected to 3 = NOT OK) 3->4 (1 is NOT connected to 4 = OK) ...but it should NOT be displayed twice, only because 2 and 3 are connected to 4!! 3->5 (1 is NOT connected to 5 = OK) the only thing i could come up with, would look similar to the php code below. but id want to do all this within just one, simple MySQL query, if its possible (i.e. JOIN?). $a = mysql_query("SELECT id2 FROM table WHERE id1 = 1"); while($b = mysql_fetch_assoc($a)) { $c = mysql_query("SELECT id2 FROM table WHERE id1 = $b[id2]"); while($d = mysql_fetch_assoc($a)) { $e = mysql_query("SELECT id2 FROM table WHERE id1 = 1 AND id2 = $d[id2]"); $f = mysql_fetch_assoc($e); if(!$f['id2']) { echo $f['id2']; } } } id appreciate any help with this. thank you!
  3. phorcon3

    REGEX

    var string = ' word word. '; so, all words which don't have a period as the last character should be replaced with invalid string.replace(/[a-zA-Z]{1,}[^\.]/gi, 'invalid'); but [^\.] doesnt work, does anyone else know what to put in instead?
  4. i need the regex to validate urls, such as 1) www.google.com 2) http://www.google.com 3) https://www.gogle.com 4) htt|ps://www.google.com/index.php?q=blah & www.google.com/index.php?q=blah 5) as well as .../index.php?q=blah&q2=blah2&q3=blah3... 6) http://google.com /(https?:\/\/)?(\w{0,3})?(\w)*?/ would that work?
  5. yah, i know, but i wanna extract both urls first and then replace each i just dont get why it only outputs http://www.example.com and not http://www.example.com http://www.example2.com
  6. how come this script below <script type="text/javascript"> var text = 'url 1 http://www.example.com url 2 http://www.example2.com haha'; var matches = text.match(/http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/); for(var i = 0; i < matches.length; i++) { document.write(matches[i]); } </script> only outputs: http://www.example.com
  7. var text = 'this is the first url http://www.example.com and this is the second url http://www.example2.com'; how do i match each of these urls and replace them with the word url?
  8. i need this one function which should be written in php and javascript php: $text = $_POST['text']; javascript: var text = document.getElementById('text').value; so, "text": 1) may contain a-zA-Z0-9 as well as a period "." 2) first letter must be alphanumeric, so ".text" would result in an error 3) there should be no consecutive periods allowed, so "text..text" would result in an error 4) last letter must be alphanumeric as well, so "text." would also result in an error does anyone know how to do this with just on line of code (regex) in both, php and javascript? thanks in advance
  9. jquery: $(function() { $('.thumb').hover(function() { for (var i=1; i <= 4; i++) { setTimeout(function(){$(this).attr('src', '/thumbnail/1_' + i + '.jpg');}, i*100); } }, function() { $(this).attr('src', '/thumbnail/1_1.jpg'); }); }); html: <img src="/thumbnail/1_1.jpg" border="0" class="thumb" /> folder: /thumbnail/ 1_1.jpg 1_2.jpg 1_3.jpg 1_4.jpg does anyone have any idea why this isn't working? it should go from 1_1.jpg to 1_2.jpg to 1_3.jpg ... but currently it isn't doing anything.
  10. geesh, thanks a lot;) appreciate your help
  11. mysql_table (friends) id friend1 friend2 1 test1 test2 2 test2 test1 3 test2 test3 4 test3 test2 5 test2 test4 6 test4 test2 now i want test1's friends' friends, which in this case would output, test3 and test4 i can only think of doing it this way: $a=mysql_query("SELECT friends2 FROM friends WHERE friend1 = test1); while($b=mysql_fetch_assoc($a)) { $c=mysql_query("SELECT friends2 FROM friends WHERE friend1 = $b[friend2]"); while($d=mysql_fetch_assoc($c)) { $d.=['friend2'];//outputs test3 and test4 } } but i wanna do all that within just one single query ...i dont know if thats possible or not.. i hope it makes more sense now :/
  12. mysql table table: friends rows: friend1, friend2 i want to get the friends of friend1's friends ...so when friend1 = 'test' how do i get test's friends' friends? god i hope that makes sense lol.. i do know that i could first fetch test's friends ..and then loop those through another query ..but i wanna do that all within just ONE single query ...any ideas? select friend2 from friends where friend1 = test blahblah (blahblah)
  13. thanks! it works perfectly!
×
×
  • 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.