Jump to content

drisate

Members
  • Posts

    805
  • Joined

  • Last visited

Everything posted by drisate

  1. Thx that solved the problem!
  2. Hey guys i have an array that looks like this Array ( [0] => Array ( [Marque] => AUDI [Famille] => A4 Avant N1 ) [1] => Array ( [Marque] => AUDI [Famille] => A3 ) [2] => Array ( [Marque] => AUDI [Famille] => A5 ) [3] => Array ( [Marque] => AUDI [Famille] => A4 ) ) i need an array that looks like this: so fare i got this going: if (isset($_GET['debug'])){ $stri=array(); $i=0; foreach($csv_array as $car){ if ( !in_array("$car[Marque]", $stri) ) { $stri[] = "$car[Marque]"; } if ( !in_array("$car[Famille]", $stri) ) { $stri[$i][$car[Marque]][] = "$car[Famille]"; } $i++; } echo "<pre>"; print_r($stri); echo "</pre>"; but that gives me Fatal error: Cannot use string offset as an array
  3. hey guys! i have an arrays that looks like this: Array ( [0] => Array ( [name] => backup_fghj.sql.gz [size] => 10056579 [perm] => -rw-r--r-- [type] => file [time] => 22 February 2012 18:53:16 [stamp] => 85745 ) [1] => Array ( [name] => backup_sdfg.sql.gz [size] => 13755947 [perm] => -rw-r--r-- [type] => file [time] => 16 November 2012 14:26:13 [stamp] => 25745 ) [2] => Array ( [name] => backup_dfgh.sql.gz [size] => 11936839 [perm] => -rw-r--r-- [type] => file [time] => 15 September 2012 22:18:55 [stamp] => 84574 ) [3] => Array ( [name] => backup_erty.sql.gz [size] => 11009205 [perm] => -rw-r--r-- [type] => file [time] => 22 July 2012 09:08:16 [stamp] => 34574 ) ) I need to sort it by stamp desc ... how can i do that? $file = dir_list("../forum/CPadmin/backups"); $f=0; foreach($file as $fichier){ if (strstr($file[$f]['name'], '.gz')){ $page_content .= '<a href="/forum/CPadmin/backups/'.$file[$f]['name'].'">'.$file[$f]['time'].'</a></br>'; } $f++;
  4. i was missing the the canada array containing all the provinces // Select pays $select_pays = mysql_query("SELECT * FROM pays order by nom_pays asc") or die(mysql_error()); while($pays = mysql_fetch_assoc($select_pays)){ $list_pays .= '"'.$pays['nom_pays'].'",'; echo 'categories["'.$pays['nom_pays'].'"] = ['; // Select Province $select_province = mysql_query("SELECT * FROM province where id_pays='$pays[id_pays]' order by nom_province asc") or die(mysql_error()); while($province = mysql_fetch_assoc($select_province)){ $province_list .= 'categories["'.$province['nom_province'].'"] = ['; $list_province .= '"'.$province['nom_province'].'",'; // Select ville $select_ville = mysql_query("SELECT * FROM ville WHERE id_province='$province[id_province]' order by nom_ville asc") or die(mysql_error()); while($ville = mysql_fetch_assoc($select_ville)){ $list_ville .= '"'.$ville['nom_ville'].'",'; } $province_list .= substr($list_ville, 0, -1).'];'."\n"; unset($list_ville); } echo substr($list_province, 0, -1).'];'."\n"; echo $province_list; } echo 'categories["startList"] = ['.substr($list_pays, 0, -1).'];'."\n"; If you know a cleaner way of doing the same thing let me know :-)
  5. Hey guys i did not sleep in 2 days and right now i am working on a triple combo box systeme and i am enable to concentrate my self to find an effective way of creating the javascript with my php loops ... This is the script i am using: http://www.javascriptkit.com/script/script2/triplecombo.shtml The part i am having a problem with is populating the array tree categories["startList"] = ["Wearing Apparel","Books"] categories["Wearing Apparel"] = ["Men","Women","Children"]; categories["Books"] = ["Biography","Fiction","Nonfiction"]; categories["Men"] = ["Shirts","Ties","Belts","Hats"]; categories["Women"] = ["Blouses","Skirts","Scarves", "Hats"]; categories["Children"] = ["Shorts", "Socks", "Coats", "Nightwear"]; categories["Biography"] = ["Contemporay","Historical","Other"]; categories["Fiction"] = ["Science Fiction","Romance", "Thrillers", "Crime"]; categories["Nonfiction"] = ["How-To","Travel","Cookbooks", "Old Churches"]; What i got so fare is: // Select pays $select_pays = mysql_query("SELECT * FROM pays order by nom_pays asc") or die(mysql_error()); while($pays = mysql_fetch_assoc($select_pays)){ $list_pays .= '"'.$pays['nom_pays'].'",'; // Select Province $select_province = mysql_query("SELECT * FROM province where id_pays='$pays[id_pays]' order by nom_province asc") or die(mysql_error()); while($province = mysql_fetch_assoc($select_province)){ echo 'categories["'.$province['nom_province'].'"] = ['; // Select ville $select_ville = mysql_query("SELECT * FROM ville WHERE id_province='$province[id_province]' order by nom_ville asc") or die(mysql_error()); while($ville = mysql_fetch_assoc($select_ville)){ $list_ville .= '"'.$ville['nom_ville'].'",'; } echo substr($list_ville, 0, -1).'];'."\n"; unset($list_ville); } } echo 'categories["startList"] = ['.substr($list_pays, 0, -1).'];'."\n"; Any help gething this back on tract would be appreciated. The above creates this output: categories["Alberta"] = ["Airdrie East","Airdrie West","Athabasca","Banff","Barrhead"]; categories["British Columbia"] = ["Abbotsford East","Abbotsford Southeast","Abbotsford Southwest","Abbotsford West","Atlin Region (Atlin)"]; categories["Manitoba"] = ["Brandon North","Brandon Region (Killarney)","Brandon Southeast","Brandon Southwest","Cartier"]; categories["New Brunswick"] = ["Allardville","Apohaqui","Baie-Sainte-Anne","Baker Brook","Balmoral"]; categories["Newfoundland and Labrador"] = ["Bonavista Peninsula (Bonavista)","Burin Peninsula (Marystown)","Carbonear","Central Labrador (Happy Valley-Goose Bay)","Central Newfoundland (Bishops Falls)"]; categories["Northwest Territory"] = ["Central Northwest Territories (Inuvik)","Southwestern Northwest Territories (Fort Liard)","Yellowknife"]; categories["Nova Scotia"] = ["Alder Point","Amherst","Antigonish","Bedford Northwest","Bedford Southeast"]; categories["Nunavut Territory"] = ["Central Nunavut (Cambridge Bay)","Inner Nunavut (Rankin Inlet)","Outer Nunavut (Iqaluit)"]; categories["Ontario"] = ["Acton","Ajax East","Ajax Northwest","Ajax Southwest","Algoma Southwest (Blind River)"]; categories["Prince Edward Island"] = ["Charlottetown North","Charlottetown Southeast Prince Edward Island Provincial Government","Charlottetown West","Kings and Queens counties (Elmira)","Montague"]; categories["Quebec"] = ["","Abitibi- T","Abitibi- T","Ahuntsic Central","Ahuntsic East"]; categories["Saskatchewan"] = ["Buena Vista","Central Saskatchewan (Humboldt)","Eastern Saskatchewan (Melfort)","Estevan","Lloydminster"]; categories["Yukon"] = ["Central Yukon (Dawson City)","Southeastern Yukon (Watson Lake)","Whitehorse"]; categories["startList"] = ["Canada"];
  6. Thanks for your help but adding lines did not solve the problem INSERT INTO `entreprises` (`eid`, `mid`, `nom`, `tel`, `site`, `categorie_p`, `categorie_s`, `adresse`, `cp`, `id_ville`, `id_province`, `id_pays`) VALUES (1, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1), (2, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1), (3, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1), (4, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1), (5, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1), (6, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1), (7, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1), (8, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1); My query is SELECT * , ( ( 1.3 * (MATCH (nom) AGAINST ('cc' IN BOOLEAN MODE) ) ) + ( 0.6 * (MATCH (site) AGAINST ('cc' IN BOOLEAN MODE) ) ) ) AS relevance FROM entreprises WHERE ( MATCH (nom, site) AGAINST ( 'cc' IN BOOLEAN MODE)) ORDER BY relevance DESC LIMIT 0 , 30 i also tryed with + arround the keyword but same result SELECT * , ( ( 1.3 * (MATCH (nom) AGAINST ('+cc+' IN BOOLEAN MODE) ) ) + ( 0.6 * (MATCH (site) AGAINST ('+cc+' IN BOOLEAN MODE) ) ) ) AS relevance FROM entreprises WHERE ( MATCH (nom, site) AGAINST ( '+cc+' IN BOOLEAN MODE)) ORDER BY relevance DESC LIMIT 0 , 30
  7. Hey guys i am trying to performe a search in PHP using MySQL. The search must be by relavancy and i am having a hard time understanding the fulltext way of doing it. The querry i put together does not return any SQL error so the syntaxe must be good ... The problem is that it's currently not returning any row. I made the querry with 'cc' as the keyword so normaly it should return the inserted row provided below 'cc' existe in 'ccmedia' and 'ccmedia.ca' SELECT * , ( ( 1.3 * ( MATCH ( nom) AGAINST ( '+cc+' IN BOOLEAN MODE ) ) ) + ( 0.6 * ( MATCH ( site) AGAINST ( '+cc+' IN BOOLEAN MODE ) ) ) ) AS relevance FROM entreprises WHERE ( MATCH ( nom, site) AGAINST ( '+cc+' IN BOOLEAN MODE ) ) ORDER BY relevance DESC LIMIT 0 , 30 CREATE TABLE IF NOT EXISTS `entreprises` ( `eid` int(9) NOT NULL AUTO_INCREMENT, `mid` int(9) NOT NULL, `nom` varchar(255) NOT NULL, `tel` varchar(255) NOT NULL, `site` varchar(255) NOT NULL, `categorie_p` int(9) NOT NULL, `categorie_s` varchar(255) NOT NULL, `adresse` varchar(255) NOT NULL, `cp` varchar(255) NOT NULL, `id_ville` int(9) NOT NULL, `id_province` int(9) NOT NULL, `id_pays` int(9) NOT NULL, PRIMARY KEY (`eid`), FULLTEXT KEY `nom` (`nom`), FULLTEXT KEY `tel` (`tel`), FULLTEXT KEY `site` (`site`), FULLTEXT KEY `adresse` (`adresse`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; INSERT INTO `entreprises` (`eid`, `mid`, `nom`, `tel`, `site`, `categorie_p`, `categorie_s`, `adresse`, `cp`, `id_ville`, `id_province`, `id_pays`) VALUES (1, 1, 'CCMédia', '450-654-3281', 'ccmedia.ca', 1, '-2-3-', '92a rue lamartine', 'T0A 5T7', 1, 1, 1);
  8. You can strip out HTML of your string using $string = strip_tags($myIntro); or you can str_replace one tag at the time $find = array('<p>', '</p>');
  9. Hey guys i am trying to retreive the HTML of a specefic div containing the class name "main" The code works but for some reason, it only returns the txt ... no HTML. All the text formating is striped out ... normaly there should be images as well. What did i miss? $page = file_get_contents($item_url); $doc = new DOMDocument(); $doc->loadHTML($page); $divs = $doc->getElementsByTagName('div'); foreach($divs as $div) { if ($div->getAttribute('class') === "main") { $divContent = html_decode($div->nodeValue); } } $divContent = preg_replace('#^\d+#', '', $divContent); $divContent = nl2br(trim(htmlentities($divContent, ENT_QUOTES, "UTF-8")));
  10. Hey guys i need a code that will find all images of a string and check the size. If the width is bigger then a certain value it changes to the max-width. Images can come in various formats and the attributes may be in different orders ... the width tag may or may not be in ... The ideal code would come in a function format like this: $output = resize_img ("$html", "$max_img_width", "$max_img_height");
  11. Hey guys ;-) just wanted to update this post. I finished the script i wanted to do and now i just wana share it in case somebody else needs something like it ... So what the script does is that it gets a list of all the playlist of a given youtube username then you can click on that playlist to see the videos in them. I used it in combination with prettyPhoto (Jquerry lightbox made by no-margin-for-errors.com) so that explains the need for a thumbnail and the href tag with a rel attribute. $YouTubeUsername = ""; if (!$_GET[playlist]) { $feedURL = "http://gdata.youtube.com/feeds/api/users/".$YouTubeUsername."/playlists?v=2"; $sxml1 = simplexml_load_file($feedURL); foreach ($sxml1->entry as $entry1) { $playlist = explode(":", $entry1->id); echo "<a href='index.php?mod=videos&playlist=".$playlist[5]."'>".$entry1->title."</a><br/>"; } } else { $feedURL = "http://gdata.youtube.com/feeds/api/playlists/".$_GET[playlist]."?v=2"; $sxml = simplexml_load_file($feedURL); foreach ($sxml->entry as $entry) { $media = $entry->children('http://search.yahoo.com/mrss/'); $attrs = $media->group->content->attributes(); $videoURL = $attrs['url']; $videoURL = preg_replace('/\?.*/', '', $videoURL); $videoURL = str_replace("/v/","/embed/",$videoURL); $videoID = explode("/", $videoURL); $videoTitle = $media->group->title; echo "<div style='float:left;margin:0 15px 15px 0; border: 1px solid black'> <a href='http://www.youtube.com/watch?v=$videoID[4]' rel='prettyPhoto' title='$videoTitle' style='display:block;'> <img src='http://img.youtube.com/vi/$videoID[4]/1.jpg' alt='YouTube'/> </a></div>\n"; } } I hope this script will help others. Have fun! And just so you know, i contacted Sandip Karande by skype and his going to update the class he made to work with the last version of the youtube api ... So before you use my script, be sure you take a look at the youtube api class for an update. The code would of been a lot cleaner with it lol
  12. Looks like youtube changed it's api and thats the reason why nothing is working in that script As a work arround ... i came up with this: <?php $YouTubeUsername = ""; $feedURL = "https://gdata.youtube.com/feeds/api/users/".$YouTubeUsername."/favorites"; $sxml = simplexml_load_file($feedURL); foreach ($sxml->entry as $entry) { $media = $entry->children('http://search.yahoo.com/mrss/'); $attrs = $media->group->content->attributes(); $videoURL = $attrs['url']; $videoURL = preg_replace('/\?.*/', '', $videoURL); $videoURL = str_replace("/v/","/embed/",$videoURL); $videoTitle = $media->group->title; echo "<div style='float:left;margin:0 15px 15px 0; border: 1px solid black'><iframe frameborder='0' class='youtube-player' width='320' height='245' src='$videoURL'></iframe></div>\n"; } ?> It will list all the favorite videos of a user. I hope this will help others. I am pretty sure you will be able to tweak the code to do what ever oce you get the hang of the new api. good luck!
  13. Hey guys i am trying to use the youtube class created by Sandip Karande. For some reason, it seems like it's not working right ... Warning: SimpleXMLElement::xpath() [simplexmlelement.xpath]: Undefined namespace prefix in /home/mdjlamar/public_html/aCMS/core/ClassYouTubeAPI.php on line 178 You can download the script from here http://www.phpclasses.org/package/6259-PHP-Manage-and-get-information-from-YouTube-videos.html I saw other developers getting this error but did not find any fix to it. I did not touch anything yet apart from the username/password var from the exemple.php file. When i output the result it gets very nasty ...
  14. thx your right it works now :-)
  15. Ok so if nobody can help me get dns_get_record() to work ... is there an alternate way of doing this?
  16. It looks like this: aal-t.com ns1.loumic.com ns2-r3-chicago.webserversystems.com ns2.loumic.com ------------------------------------------------------- aadq.ca ------------------------------------------------------- academienouvellegeneration.com ------------------------------------------------------- aefmq.ca ------------------------------------------------------- aefmq.com ------------------------------------------------------- aefmq.org ------------------------------------------------------- aero-atelier.com -------------------------------------------------------
  17. Hey guys i need to find the DNS of a hudge list of domains to check if there pointing at my server or not. This is what i did: $str = 'AAL-T.COM<br> AADQ.CA<br> ACADEMIENOUVELLEGENERATION.COM<br> AEFMQ.CA<br> AEFMQ.COM<br> AEFMQ.ORG<br> AERO-ATELIER.COM<br>'; // [...] $line = explode('<br>', strtolower($str)); foreach($line as $domain){ $dns = dns_get_record($domain, DNS_NS); sort($dns); echo "<strong>$domain</strong><br>"; foreach ($dns as $record) { echo $record['target']."<br/>"; } echo '<hr>'; } ?> For some reason the first loop outputs the target right but every other domain after if ruturns empty ... am i missing something?
  18. Hey guys i need help creating a working "follow me" button for pinterest. All the buttons i found is only an URL to the page and the user needs to click on the follow me button so it's not really the best way of doing it ... I was looking at the source code and the link looks like "http://pinterest.com/USERNAME/follow/" but when you open the page you get a 404 error. I took a look at the javascript and man did they make it complicated ... so fare what i understand is that the link returns FALSE so you never end up opening /follow at all In fact i think it submits an invisible forme some how ... but i can't put my hand on how it's made Take a look at it and let me know what you understand. Steps to reproduce: Create an account at www.pinterest.com Open up the profil of sombody else and click the redbutton "Follow all" What needs to be done: Find a way to host else where the same button that would make the user follow the given user Any help would be very appreciated
  19. Hey guys i am trying to extract the HTML of a loop of links. Each links are diffrent pages and i manualy cheked and there all diffrent ... but for some reason, the loop always sends back the same html ... the one from the first loop. while($i<=3){ echo file_get_contents("http://www.amazon.com/s/ref=nb_sb_noss_1/187-7591397-0314036?url=search-alias%3Dvideogames&field-keywords=ps3#/ref=sr_pg_$i?rh=n%3A468642%2Ck%3Aps3+game&page=$i&d=1&keywords=ps3+game&ie=UTF8&qid=1333219791"); echo "<hr>"; $i++; } Normaly i should get page 1 2 3 ... but i get 3 times the page 1 ... the URL is good because if i manualy open them the content is diffrent in each page
  20. lol sorry forgot i had to use preg_match_all hehe
  21. hey guys i need to extract all the IP's of a string and loop them for more operations but for some reason i only get the first one <?php $string = '80.37.14.13 80.37.14.14 80.37.14.15'; preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $string, $matches); foreach ($matches as $ip){ echo "$ip<br>"; } ?> The string is not really seperated by spaces ... it can actualy be messy and have ips rapped arround a lot of code. The regex works because i do get the first one ... What did i miss?
  22. OMG you did it !!! it works !!! Thank you !!!
  23. Thx MMDE. i got that same result once but unfortunatly it's not good. this is what it outputed 1, 1 2, 1 3, 2 4, 1 5, 2 6, 3 7, 1 8, 2 9, 3 10, 4 11, 1 12, 2 13, 3 14, 4 15, 5 16, 1 17, 2 18, 3 19, 4 20, 5 It should output 1, 0 2, 1 3, 1 4, 2 5, 2 6, 3 7, 3 8, 4 9, 4 10, 5 11, 5 12, 6 13, 6 14, 7 15, 7 16, 8 17, 8 18, 9 19, 9 20, 10
  24. I need to populate a table of 10.000 members. They each need to be connected by folowing the bi-level marketing laws .. 1 member finds 2 members, Ex: 0 12 3456 [...] My problem is i dont have a clue of how to generate such a table. Everything i tryed did not work. Knowing that 10.000 members = 100 level deep in the pyramide, i started with a while loop of 100, but how the hell can i loop only the last level. In the above exemple, the last level is 3456. The last level should be the members that does not yet have 2 recruted members.
×
×
  • 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.