Jump to content

cindreta

Members
  • Posts

    36
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

cindreta's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey requinix, thank you for your answer. I tried to include your verion which i really find more better looking and shorte than mine but it didn't work, it didnt mark anything. I once again reverted to mine just to check if all is good and for now mine works: $string = preg_replace("/(\<strong\>)?\(([son])(\d+)\)(\<\/strong\>)?/i", '<a href="ajax/load-content.php?type=$2&marker=$3&category='.$category_id.'" data-target="#read-modal" data-toggle="modal"><span class="rule-annotation">$2</span></a>', $string); I am very interested in getting your thing to work though, so if you could check why it wouldn't be.
  2. UPDATE 1: I have somehow managed to get the following to work: preg_replace("/(\<strong\>)?\(([son])([0-9])\)(\<\/strong\>)?/i", '<a href="ajax/load-content.php?type=$2&marker=$3&category='.$category_id.'" data-target="#read-modal" data-toggle="modal"><span class="rule-annotation">$2</span></a>', $string); But this is not completly what i need. For instance it doesnt recognize above the number 9, so if somwhere there would be S12 or N34 it wouldn't replace it. Plus i readlly don't know if i did the strong tag part right, sometimes it might be there and somethimes not. Anyone?
  3. Hi guys, i am very new to Regex so i would need some guidance here. I am trying to save myself of going trough each article and replacing a bunch of similar tags with something else - to be exact i need to replace all markers marked (S1) with let's say <a href="#" class="modal" data-type="tip" data-number="1"><span class="tip">S</tip></a>. The problem of course is matching what i need. Example would be: <p><Lorem Ipsum <strong>(S1)</strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. <strong>(O2)</strong> It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like <strong>(S3)</strong> Aldus PageMaker including versions of Lorem Ipsum./p> As you can see in the example, i will get some HTML content that has keywords like S1...Sx or O1...Ox and i need to find them and replace them with some other HTML content. The pattern can go something like this: starts with letter "S" or "O" or "N" - the letters can be upper or lowecase after the 3 possible letters above there should be a number from 0-9 the combination is mostly emebeded inside a HTML strong tag, but it doesn't have to be. If it is in the strong tag then i need to remove that strong tag completly. i need to know the number after the letter so i can use it later to do a database request I am pretty sure that the patterns S1,O1,N1 will only occur in the cases i need to replace them. I won't have meaningfull text that will have the same pattern. So if someone can help me target this so i can replace it with some anchor tags. Thank you so much.
  4. i am working on this search engine. and in the advanced section you can turn on/off some of the options. So it you turn on an option it will search another table and so on. Instead of building a massive query and left joining lots of stuff. I tried a different approach. There is always a basic query and it returns the results to an array like this $sql = mysql_query("SELECT SQL_CACHE id FROM table WHERE field LIKE '$getquery' ORDER BY field"); while ($row = mysql_fetch_array($sql)) { $idArray[] = $row['id']; } mysql_free_result($sql); and if something is turned on then it adds something like this: if($_POST['value'] == "1") { $sql = mysql_query("SELECT SQL_CACHE table1_relation_id FROM table2 WHERE field2 LIKE '$getquery' ORDER BY field2"); while ($row = mysql_fetch_array($sql)) { $idArray[] .= $row['table1_relation_id']; } mysql_free_result($sql); } //end if so basicy i just continue the array and it keeps pumping ids into a big aray. after that i run array_unique and remove all duplicate results and then i foreach and get the whole item info ased on every id. it runs pretty fast. now i would like to make the second one a function. but when i do that it does not work. function sample($query, $table, $field) { $sql = mysql_query("SELECT SQL_CACHE naziv_id FROM ".$table." WHERE ".$field." LIKE '$query'"); while ($row = mysql_fetch_array($sql)) { $return[] .= $row['naziv_id']; } mysql_free_result($sql); return $return; } before i put it into a function $idArray vas a single continuous array. And if i try to do it like this: $arr[] = sample($query, "table1", "filed_id"); $arr[] .= sample($query, "table2", "filed_id"); it returns the result of the first array ok but if there are more then one results in other arrays it returns and arary inside of the array. like this: array(4) { [0]=> array(2) { [0]=> string(4) "9057" [1]=> string(5) "14186" } [1]=> string(5) "Array" [2]=> string(5) "Array" [3]=> string(0) "" } and all i wanna have is a single id variable that has all the id's in it. like $array = 1,2,3,4,5 but from different sources/functions can you help? thank you so much.
  5. Hi i have this ajax table that displays resutls from the database and you can search it live. if you type anything it returns the results and so on...everything normal untill i typed "pregled" - it's a croatian word and it wont find it, but phpMyAdmin finds it. Then i tried the part of that word just "preg" and all it did it returned all the results in the db, like he didnt eaven make the search. i check the firebug NET window and he does post the word "preg" to the server but the server just sends everyhing back. What could be the problem to this. Is "preg" somekind of a safe word or something and how can i fix this. thank you.
  6. yes maybe the best thing to do is your idea. get the time when a person opens the article edit, increment that time by let's say 5 minutes and store it to the database for that article. This way nobody can edit the article in the next 5 minutes, it sorta works like a queue, i can also tell the second user that he will be able to edit it in 5 mins or if the current user hits save before the 5 mins i can check with ajax if something changed. i guess this can work. its more of a hack than a solution ; ) i thought it's gonna be something extra complicated. thank you for ideas.
  7. Yes, i taught something similar. but it always comes back to what if the user just closes the window or a tab and doesnt eaven save anyhing. the database will still have a record that somebody is editing. i saw that wordpress has something similar but i couldn't figure out how exactly did it. they show you a message when you open up an article for editing saying that "username is editing the article...". you think it could work with sql only? thx for a fast replay btw
  8. So i have this CMS that is used by lots of users and generally they do have rights to edit each others article. So now i'm thinking how can i at least warn them that somebody else is already editing it. Just that. maybe with sessions? but what happens when a user just closes the windows, will it destroy it. i taught about storing the value to mySQL but again what if the user closes the windows and so on. i never did this and i could use a boost. thanks guys
×
×
  • 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.