Jump to content

jmahdi

Members
  • Posts

    69
  • Joined

  • Last visited

    Never

Everything posted by jmahdi

  1. Hi there: what i'm trying to do is i want to get the contents of heading and text_details and merge them together before adding them as one entry into database: <div class="heading"><p> Second quote: </div><div class=text_details> <p> Satan's substitute for repentance is the man's rationalization of evil. <p></b></div> my code looks s/thing like this: foreach( $dom->getElementsByTagName('div') as $div ) { foreach( $div->attributes as $attributes ) { if( strtolower($attributes->name) == 'class' ) { if( strtolower($attributes->value) == 'heading' || strtolower($attributes->value) == 'text_details') { $quote = $div->textContent; $clean_quote = mysql_real_escape_string($quote); echo "the quote is: " . $clean_quote . "<br />"; mysql_query("INSERT INTO quotes (quote) VALUES ('$clean_quote')")or die(mysql_error()); } } } } when i do this obviously i get: Second quote of the day entered into a field by itself and Satan's substitute for repentance is the man's rationalization of evil. into another field...how to make them one!?? thanks in advance
  2. thanks everyone.. your help is appreciated
  3. actually it gets the red but not the green, but now i want a regex that excludes rather than restrict to if you know what i mean!!
  4. ya true...but all the fonts i'm using have a color
  5. yes....i solved it /<font.*?(?:color="800080"|color="red"|color="maroon")>(.*?)<\/font>/ ....thanks all for the help
  6. thanks..but can't i use something like [^color|other colar] ? regex
  7. hi i just need to grab all font tags (with innerhtml) excluding tags certain colors, green and red for example or in code 0000DD for example.... thanks in advance
  8. hi there i'm trying to get the number only when in this place: رقم الحديث: 62 the number following an arabic word and a colon, i'm pulling only these numbers from a database and they allways come after this specific arabic word (some times there might be a space between the colon and the digit), i had allready tried this /(\d+) :\p{Arabic}/ but to no avail!! what can i do? thanks
  9. remove the end > you mean $pattern = '~<a.*?href=".+?\?N_ID=(\d+)"~'; !?
  10. thanks, but what about the attributes after href : style="text-decoration: none;"> as the regex does not include it as a possibility...
  11. Hi Im trying to pull N_ID=value in: <a rel="gb_page_center[626, 267]" title="narrator" href="N_Details.php?N_ID=3280" style="text-decoration: none;"> i got regex like: <a[^>]+href=\".*?\\(?:RawyID)=+(.*?)\"> but dont see it working i need a regex that will: pull N_ID and disregard the existence/inexistence of the other attributes, such as : style , rel or whatever.. thanks in advance
  12. I think i found the problem, i was using double quoutes in : $str = "<i><font color="800080"> man </font></i><p><font color="9898989"> hi </font></p><p><font color="1111111"> cheers </font></p>"; while it should be: $str = '<i><font color="800080"> man </font></i><p><font color="9898989"> hi </font></p><p><font color="1111111"> cheers </font></p>'; thanks anyways...
  13. Hi there i have this code: $str = "<i><font color="800080"> man </font></i><p><font color="9898989"> hi </font></p><p><font color="1111111"> cheers </font></p>"; $pattern = '/<font .*?>(.*?)<\/font>/'; if(preg_match_all($pattern, addslashes($str), $posts)){ $i=0; for($i; $i < count($posts[0]); $i++){ echo "content: " . $posts[0][$i] . "<br/>"; echo "colour: " . $posts[1][$i] . "<br/>"; echo "<br />"; } } and it doesn't work apparently because of the addslashes but its really needed as double quotes needs to be escaped, consider that i'm applying this code to a larger html file with hundreds of double quotes to be escaped.... error msg i get is Parse error: syntax error, unexpected T_LNUMBER in thanks in advance..
  14. what if its more than one font tag like: <b><font color=green>Get me out please </font></b><a><font color=green>Get me out please </font></a> how to utilise forforeach or for loops and can i still stick to the same regular expression....thanks thanks
  15. i need to use php as the html codes are kept in database fields and i need to go through them and pull wanted data...
  16. what is the best way yo do this? <b><font color=green>Get me out please </font> . </b> thanks in advance
  17. Hi, I'm trying to get a number of different keywords from many table fields, and i want to count them according to the occurrence of each keyword, so it should be like (keyword1 occurred 10 times for example ). the problem is when i use count in for loop: $tags = explode("|", $row[0]); $i=1; $count = 0; for($i; $i<count($tags); $i++){ print "$count {$tags[$i]}<br />"; $count++; } it counts the occurrence of key words in each field separately from the rest (i.e. 0 day 1 night 0sun 1 moon 0 clouds 1 rain ) 2 keywords in each field (some other fields got more). I want the count to be more like: 1 day 2 night 3 sun 4 moon 5 clouds 6 rain thanks
  18. Hi, I'm trying to find a way to get the difference between two times in my form, the problem arises because I'm using a 12 hour format with AM/PM to define day time. what is the best way to do this?? thanks
  19. i tried issuing an alert box onclclick before and it works fine with calculations, but when using on keypress I don't know why its giving wrong output???
  20. thanks gizmola, onkeypress doesnt seem to work either, actually i had tried using w3schools try it yourself displaying an alert box based on inputs and it alerts the correct time, so i'm not sure why isn't the in focus work...
  21. hi guys, below is a form to enter timesheet details into a database: <form name="entries_form" method="post" action="index.php"> <table> <tr> <th><label>Date</label></th> <th><label>From</label></th> <th><label>To</label></th> <th><label>Break</label></th> <th><label>Hours</label></th> <th><label>Required Hours</label></th> <th><label>Notes</label></th> </tr> <tr> <td> <input name="Date" type="text id="Date" value="<?php echo strftime("%d/%m/%Y", time()); ?>" /> </td> <td> <input name="From" type="text" id="From" /> </td> <td> <input name="To" type="text" id="To" /> </td> <td> <input name="Break" type="text" id="Break" /> </td> <td> <input name="Hours" type="text" id="Hours" onfocus="return calc_time();" /> </td> <td> <input name="Rqrd_hrs" type="text" id="Rqrd_hrs" value="8" /> </td> <td> <input name="Notes" type="text" id="Notes" /> </td> <td> <input type="submit" name="submit" value="Save" id="Save" style="background-color:#7A70A4;" /> </td> </tr> </table> </form> the onfocus event is pointing to this method: function calc_time(){ var time_start = document.entries_form.From.value; var time_end = document.entries_form.To.value; var t_break = document.entries_form.Break.value; var hours = document.entries_form.Hours.value; var t_time; s = time_start.split(':'); e = time_end.split(':'); b = t_break.split(':'); min = e[1]-s[1]-b[1]; hour_carry = 0; if(min < 0){ min += 60; hour_carry += 1; } if(e[0] < s[0]){//if end hour is less than start hour //convert to 24hr format twnty4Form = parseInt(e[0]) + 12; hour = twnty4Form-s[0]-b[0]-hour_carry; }else{ hour = e[0]-s[0]-b[0]-hour_carry; } return t_time = hour + ":" + min; } the problem is that when i -focus- on the field with id (Hours), i dont get the output of t_time which is supposed to be the total time after all calculations in the field, as i am intending to....what am i doing wrong any help or suggestions. thanks in advance
×
×
  • 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.