Jump to content

phorcon3

Members
  • Posts

    177
  • Joined

  • Last visited

    Never

Everything posted by phorcon3

  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!
  14. thanks, man! but for some reason IN(test,test1) didnt work ...but WHERE (`user` = 'test' OR `user` = 'test1') worked..?! dunno...
  15. ID USER1 USER2 1 test test1 2 test1 test2 3 test3 test1 5 test test3 6 test test2 7 test3 test4 i am test.. and im connected with test1.. and now i wanna check which users i have in common with test1 = test2,test3 how can i do that in one single query? to find out if im connected with test1, id have to do <?php $a=mysql_query("SELECT * FROM `table` WHERE `USER1` = 'test' AND `USER2` = 'test1' OR `USER2` = 'test' AND `USER1` = 'test1'"); ?> but how do i check which other ones (test2,test3) we have in common?...id have to use two queries again ..but maybe theres a sql func to do it with one single query.. does anyone know?
  16. ID ArticleID User 1 1 test 2 5 test1 3 28 test 4 28 test1 whats the query to find the articleID where both, test and test1, are included? = 28 <?php $a=mysql_query("SELECT `ArticleID` FROM `table` WHERE `User` = 'test' ORDER BY `ID` DESC"); while($b=mysql_fetch_assoc($a)) { $article_a=mysql_query("SELECT `ID` FROM `table` WHERE `User` = 'test1' AND `ArticleID` = '$b[ArticleID]'"); $article_b=mysql_fetch_assoc($article_a); if($article_b['ID']) { echo $b['ArticleID']; } } but that wouldnt be very efficient since im usin two queries ...can anyone help me with this please?
  17. $a=mysql_query("(SELECT Count(id) AS Count FROM `t1` WHERE `this` = '$_GET[text]') UNION (SELECT Count(id) AS Count FROM `t2` WHERE `this` = '$_GET[text]')"); $b=mysql_fetch_assoc($a); echo $b['Count']; that obviously only gives back the result from t1...but how can i make sure it adds both counts ..from t1 and t2?
  18. http://tool-man.org/examples/ is that what u were lookin for?
  19. <html> <head> <script language="JavaScript"> function Init(){iView.document.designMode = 'On';} </script> </head> <body onLoad="Init()"> <iframe id="iView" width="200" height="80"></iframe> </body> </html> does anyone know how to add css to the iframe field? because when i type in this field, the paragraphs are double spaced, so id like to change the line-height to 10px. and id also like to change the font size.
  20. html: <input type="text" name="email" onkeyup="check_email(this.value);" size="30" /> js: function check_email(value) { var list=new Array(); list[0]="yahoo"; list[1]="hotmail"; list[2]="gmail"; var count; for(count=0;count<list.length;count++) { //and here i wanna check if the email contains either one of those domains listed above if(this is that) { document.getElementById('status').innerHTML='worked';//ie: nickname@yahoo.com } else { document.getElementById('status').innerHTML='error';//ie: nickname@mail.com } } } any ideas how to do this?
  21. nah, unfortuantely i dont have it online ...the dothis function just takes the value and inserts it into a text field ..thats all ..but anyway, thanks for ur help. i appreciate it. but i guess ill just go with hidden fields.. it works ..buuuut ..well, it works, i guess thats all that matters for now lol thanks again;)
  22. <div id="test_1" onclick="dothis('value1');">Text1</div> <div id="test_2" onclick="dothis('value2');">Text2</div> <div id="test_3" onclick="dothis('value3');">Text3</div> so, lets say i have a list like this ...and i used javascript to be able to use the arrow keys on ur keyboard to select either test_1, test_2 or test_3... so when i use the arrow key to go from test_1 to test_2... and then i hit enter ...how do get the value from test_2 ..which in this case would be value2 ..cause i need that value to insert it into a text field... i hope that makes sense? so i have something like if(event.keyCode == 13){/*do the hit enter function->fetch value*/} it would be easy if i had the value i needed within the div tags ...so i could use just document.getElementById('test_2').innerHTML; ..but thats unfortunately not the case... i hope this makes sense lol
×
×
  • 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.