Jump to content

mapleleaf

Members
  • Posts

    250
  • Joined

  • Last visited

    Never

Everything posted by mapleleaf

  1. And how do you get it from the db into $tread['info']?
  2. And how are you displaying it on the page with php?
  3. Thanks both. I have also seen some strange things with strtotime but it is still the best option here I suppose.
  4. <?php function get_weekly($start, $end) { $dates = array(); while($start < $end) { array_push($dates,date("D m y",$start)); $start = $start + (86400 * 7); // perhaps erroneous concept of the number of seconds in a week } return $dates; } $start = strtotime("Tue 10th Jul 2012"); $end = strtotime("Tue 10th Jul 2013"); echo "<pre>"; print_r(get_weekly($start, $end)); echo "</pre"; ?> And the results which I think amount to a bug in PHP: Array ( [0] => Tue 07 12 [1] => Tue 07 12 [2] => Tue 07 12 [3] => Tue 07 12 [4] => Tue 08 12 [5] => Tue 08 12 [6] => Tue 08 12 [7] => Tue 08 12 [8] => Tue 09 12 [9] => Tue 09 12 [10] => Tue 09 12 [11] => Tue 09 12 [12] => Tue 10 12 [13] => Tue 10 12 [14] => Tue 10 12 [15] => Tue 10 12 [16] => Tue 10 12 [17] => Mon 11 12 [18] => Mon 11 12 [19] => Mon 11 12 [20] => Mon 11 12 [21] => Mon 12 12 [22] => Mon 12 12 [23] => Mon 12 12 [24] => Mon 12 12 [25] => Mon 12 12 [26] => Mon 01 13 [27] => Mon 01 13 [28] => Mon 01 13 [29] => Mon 01 13 [30] => Mon 02 13 [31] => Mon 02 13 [32] => Mon 02 13 [33] => Mon 02 13 [34] => Mon 03 13 [35] => Tue 03 13 [36] => Tue 03 13 [37] => Tue 03 13 [38] => Tue 04 13 [39] => Tue 04 13 [40] => Tue 04 13 [41] => Tue 04 13 [42] => Tue 04 13 [43] => Tue 05 13 [44] => Tue 05 13 [45] => Tue 05 13 [46] => Tue 05 13 [47] => Tue 06 13 [48] => Tue 06 13 [49] => Tue 06 13 [50] => Tue 06 13 [51] => Tue 07 13 [52] => Tue 07 13 ) How did Monday get in there??
  5. Not sure where those question marks came from Anyway this does work: update articles set text = replace(text, '<p class="p1">QUESTION:</p>', '<p class="p1 question">QUESTION:</p>'); So marking as solved
  6. I have a string that is causing an error using replace: update articles set text = replace(text, ?<p class="p1">QUESTION:</p>?, ?<p class="p1 question">QUESTION:</p>?); What is my syntax issue? Thanks
  7. Perfect. Exactly what I needed. Thanks a lot!!
  8. What type of field are you using in Mysql and can you do a print_r of your post array before inserting to see what values it is holding?
  9. If I have a string like this: Anne Somebody <anne@email.com>, John Smith <john@hotmail.co.uk>, bob Someoneelse <bob@email.it> is there a simple way of extracting the emails? I can do the explode and trim so I am really asking how to handle the John Smith <john@hotmail.co.uk> in a reliable way. To be left with john@hotmail.co.uk Thanks,
  10. Select list_name, count(email) as EmailCount from email_lists, emails where email_lists.list_owner_id = $user_id AND emails.list_id = email_lists.id group by email_lists.id Figured it out
  11. I think the update option's time expired. MYSQL 5.1.37 Just to clarify I get the list name back and a count of 6 for the email count which is all the emails in the emails table. I am trying to get the count of emails with each list id associated. Emails Field Type Null Key Default Extra id int(12) NO PRI NULL auto_increment email varchar(100) NO NULL list_id int(10) NO NULL added_by int(12) NO NULL date_added int(10) NO NULL Email_lists id int(11) NO PRI NULL auto_increment list_owner_id int(11) YES MUL NULL list_name varchar(45) YES NULL create_date int(10) NO NULL last_update int(10) NO NULL creator_id int(10) NO NULL event_ids varchar(255) NO NULL
  12. I have 2 tables. One of emails Second email lists Every email in the first table has a list id. Every list has a user_id What would the sql be to get all the lists of a user with the count of the emails in the email table with the list_id? Something like: Select list_name, (SELECT count(email) from emails) as EmailCount from email_lists, emails where email_lists.list_owner_id = $user_id AND emails.list_id = email_lists.id This returns all the emails without checking the count correctly. I am missing something. a subquery I think
  13. I'd like to be able to get each paragraph and its id as I will need to connect them up to the original source ids. So yes I'd like each id and its paragraphs available without pulling apart the string. I am happy to have another table if it helps. Starting to think a table with the the unique ids having another relationship id as the primary field. so : relationship_id : auto increment primary extract_id:(pulled from last insert for the extract) source_id:1982 paras: 2,3 Does any one have a better solution?
  14. If you know what the field names are and how many you just skip the first row. Like this: $row = 0; if (($handle = fopen($path_to_csv, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) { $num = count($data); //echo "<p> $num fields in line $row: <br /></p>\n"; if($row > 1) { $sql = "INSERT INTO your_table VALUES ('','".mysql_real_escape_string($data[0])."','".mysql_real_escape_string($data[1])."','".mysql_real_escape_string($data[2])."','".mysql_real_escape_string($data[3])."','".mysql_real_escape_string($data[4])."','','".mysql_real_escape_string($data[5])."','".mysql_real_escape_string($data[6])."','".mysql_real_escape_string($data[7])."','".mysql_real_escape_string($data[8])."','')"; mysql_query($sql) or die(mysql_error()); } $row++; } fclose($handle); } Something like that. This is code which did do that for a site but I haven't checked it. Obviously the number of fields is up to you.
  15. I have a form where some users are compiling extracts from another part of my database. The source text has unique IDs. The users know these IDs and when they add the extracts. They need to be able to say which paragraph they are pulling from the the original text along with the ID. There can be multiple source texts. At the moment I am going to get them to send the source info like this: 1982,3,4|783,1|999,4,6,7 ID,p,p|ID,p|ID,p,p,p The first number is the source ID and then after each comma is the paragraph till you get to a pipe which marks the beginning of a new source. So in this case 3 sources. I can handle getting the info out of the string. My question is how best to store this in the database. It looks like I will need to store the string and pull it apart each time it is used but is there a better way?
  16. I need to check that some text fields are not close to the 64kb max. How do I do that?
  17. I need to set up a method for a user to be able to upload a pdf that should then be readable in the browser but I want to make it work a bit like Google Patents. Basically the rest of the users shouldn't be able to grab the content. It should be read only so as not to be passed around for free. It looks like Google is scanning each page and then running it through a reader to get the text. It then also seems to find the position of all the text so it can search the image for particular words and highlight them(cool js). Any way has anyone seen a php/ js version of this concept that I can get some hints from? Actually any language is ok if it works well. Tx
  18. I have just opened up Drupal and need to add a form that gets processed to one of the existing pages. All the form layout and processing are ready. I just need some help in how one fits this into Drupal. Custom theme? New page template? Seems too much php to add as a PHP snippet in the page editor. Any thoughts much appreciated.
  19. I am new to Drupal and need to add a Paypal pro payment page. Can I do this through Drupals cms adding PHP and HTML or will I need to go into the code itself? Thanks for any pointers.
  20. I think my own question was confused as I really need to be able to run a function on a body of text not just a word. I was starting small Any ideas for that most welcome and thanks for the help so far. Here is the format of the file: coloratura's colorimeter colorimeters colorimeter's colorimetric colorimetry colossal colossally Colosseum colossi colossus colossus's colostomies colostomy colostomy's colostrum colostrums colostrum's colour colourant colourants colourant's colouration colourations colouration's colour-blind colour-blindness colour-blindness's colour-code It was too big to upload
  21. Alex that is exactly the regex I needed thanks!!
  22. $file = file_get_contents("en-GB-oed-wlist.txt"); if(!strpos($file, $_GET['word'])) { echo "Word not found!"; }else{ echo $_GET['word'].' is ok'; } I need to create a basic spell checker for UK English so color should not show up when Colorado is in the word list file which it will with the above code. Any help much appreciated.
  23. I think I was not clear. I want to replace any words from a body of text that are in an array such as array("peach","apple") with lemon. So $text = "hahdahdakhda asdhasdasd apple jdahibbasd peach dlad ect"; 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.