Jump to content

tazeha

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by tazeha

  1. I use java script code to disable click on link in php but not working onclick="return false" I use tow way for add java script code to php link but both not working.. First way: $data .= '<td bgcolor="FFFFCC">'."<a href='http://priceha.ir/' onclick=\"return false\">.$row2->model.</a>".'</td>'; The second way: $data .= '<td bgcolor="FFFFCC">'."<a href='http://priceha.ir/' onclick='return false'>.$row2->model.</a>".'</td>';
  2. Hello with curl every 1 min go to the web and get the coin price and then store in the database. Now in my code compare latest tow records from table db ... if new price higher of old price echo price with color green.. and if less echo with red color and if equal echo with black color. <table border="1" width="50%"> <tr> <td>Date</td> <td>Amont</td> </tr> <?php $params =null; //or any params $mrkfPDO = new PDO('mysql:host=localhost;dbname=usd', 'root', '', array( PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" ) ); $mrkfStatement = $mrkfPDO->prepare("select * from uds order by id desc limit 2 ");$mrkfStatement->execute($params);$pays = $mrkfStatement->fetchAll(PDO::FETCH_ASSOC);$color = 'black';$resultcount = count($pays);if ($resultcount == 2) { if ($pays[1]['price'] > $pays[0]['price']) $colour = 'red'; if ($pays[1]['price'] < $pays[0]['price']) $colour = 'green'; }if ($resultcount > 0) { echo "<tr><td><span style='color: $color'>" .$pays [$resultcount-1]['price'] . "</span></td></tr>"; } ?> But I don't know why when echo higher price dos not change color to green.. and always is black
  3. My problem fix.. I should use $i=1 instead $i=0 because --- ['Amount'] < $pays[($i-1)
  4. Hello when I run my code give error Undefined offset: -1 in 3 line : if($pays[$i]['Amount'] < $pays[($i-1)]['Amount']) elseif($pays[$i]['Amount'] > $pays[($i-1)]['Amount']) .$pays[$i]['price']. <?php $params =null; //or any params $mrkfPDO = new PDO('mysql:host=localhost;dbname=YOUR_DB_NAME', 'DB_USER', 'DB_PASS', array( PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" ) ); $mrkfStatement = $mrkfPDO->prepare("SELECT Date, Amount FROM payments limit 0,100"); $mrkfStatement->execute($params); $pays = $mrkfStatement->fetchAll(PDO::FETCH_ASSOC); for($i=0; $i<=count($pays); $i++) { $color = 'black'; if($pays[$i]['Amount'] < $pays[($i-1)]['Amount']) $color="red"; elseif($pays[$i]['Amount'] > $pays[($i-1)]['Amount']) $color = 'green'; else $color = 'black'; echo "<tr> <td>" . $pays[$i]['Date'] . "</td> <td> <span style='color: $color'>" .$pays[$i]['Amount']. "</span> </td> </tr>"; } ?>
  5. I write this but diplay undefined $(document).ready(function(){ $.getJSON('js.json', function(data) { $.each(data.mesghal, function() { $("ul").append("<li>Price:" + this['p'] +"</li><li>Date:" + this['p'] +"</li>"); }); }); }); results: Price:undefined Date:undefined Price:undefined
  6. hello json data is array I want display mesghal values p,d,.... { "ati1": { "p": "8,935,000", "d": 0, "dp": 0, "dt": "", "h": "8,935,000", "l": "8,780,000", "t": "۲۵ تیر", "t-g": "16 July" }, "ati2": { "p": "8,665,000", "d": 0, "dp": 0, "dt": "", "h": "8,860,000", "l": "8,665,000", "t": "۲۵ تیر", "t-g": "16 July" }, "ati3": { "p": "8,720,000", "d": 0, "dp": 0, "dt": "", "h": "8,905,000", "l": "8,720,000", "t": "۲۵ تیر", "t-g": "16 July" }, "ati4": { "p": "8,840,000", "d": 0, "dp": 0, "dt": "", "h": "9,020,000", "l": "8,825,000", "t": "۲۵ تیر", "t-g": "16 July" }, "ons": { "p": "1,135.30", "d": "10.70", "dp": 0.94, "dt": "low", "h": "1,146.50", "l": "1,135.30", "t": "۱۸:۳۰", "t-g": "18:30" }, "mesghal": { "p": "3,889,000", "d": 0, "dp": 0, "dt": "", "h": "3,934,000", "l": "3,883,000", "t": "۲۵ تیر", "t-g": "16 July" }} <script type='text/javascript'> $(document).ready(function(){ $.getJSON('saipa.php', function(data) { console.log(data); $.each(data, function(key, val) { $('ul').append('<li id="shoker">' + val.p + ' ' + val.h + ' ' + val.t + ' ' + val.l + '</li>'); }); }); }); </script> but can't display pleas help
  7. Hello In mysql is 50 row, example: id = 1,2,3,4,5,... I want echo only row 5 until 20 how can I? my code foreach ( $result as $row ) { $data .='<tr>'; $data .= '<td>'.$row->Shakhes.'</td>'; $data .='<td>'.$row ->Value.'</td>'; $data .='<td>'.$row ->TopValue.'</td>'; $data .= '<td>'.$row->DownValue.'</td>'; $data .= '<td>'.$row->Difference.'</td>'; $data .='</tr>'.PHP_EOL; }
  8. I find problem. INSERT INTO `Dadoo`(name,liveprice,`change`,lowest,topest) ... change is escape but give this error after fixing top error. Column count doesn't match value count at row 1 (this mean I have multie columns .. )
  9. Hello I write code to save foreach data to the database. foreach data is arrays . For this reason firs convert array to string and then save to the database but display following error on firefox. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'change,lowest,topest) VALUES ('[{"Name":"سu06a9ه بهاu' at line 1 my code $con = @mysql_connect ("localhost","root", ""); mysql_select_db("coin", $con); if (!$con) { die(mysql_error()); }else {foreach($table_rows as $tr) { // foreach row $row = $tr->childNodes; if($row->item(0)->tagName != 'tblhead') { // avoid headers $data[] = array( 'Name' =>trim($row->item(0)->nodeValue), 'LivePrice' => trim($row->item(2)->nodeValue), 'Change'=> trim($row->item(4)->nodeValue), 'Lowest'=> trim($row->item(6)->nodeValue), 'Topest'=> trim($row->item(8)->nodeValue), ///'Time'=> trim($row->item(10)->nodeValue), ); }} $newstring = json_encode($data); $date=array();mysql_select_db ( "coin", $con );"CREATE TABLE `Dadoo`(id INT NOT NULL AUTO INCREMENT,name VARCHAR(255),liveprice VARCHAR(255),change VARCHAR(255),lowest VARCHAR(255),topest VARCHAR(255),PRIMARY KEY(id)) ENGINE=MyISAM" or die(mysql_error());$debugquery = mysql_query("INSERT INTO `Dadoo`(name,liveprice,change,lowest,topest) VALUES ('$newstring')"); if (!$debugquery) { die(mysql_error()); }}mysql_close(); How fix it.
  10. But I'm very trying to work with this in the More sites witch write about curl
  11. Thanks. Can you write fix code with multi_get_content?
  12. I write following code to get Multiple page of the this site: www.mobile.ir This website have mobile price category .. this category have 42 navigation page. I write following code with curl_multi_init and xpath to get data from Multiple page from category. $ch1= curl_init ("http://www.mobile.ir/phones/prices.aspx");$ch2 = curl_init ("http://www.mobile.ir/phones/prices.aspx?sort=date&dir=desc&brandid=0&terms=&duration=14&pagesize=50&price_from=-1&price_to=-1&provinceid=0&shopid=0&page=2");curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch1,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');curl_setopt($ch1, CURLOPT_HEADER, 0);curl_setopt($ch1, CURLOPT_ENCODING, 'UTF-8');curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch2,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');curl_setopt($ch2, CURLOPT_HEADER, 0);curl_setopt($ch2, CURLOPT_ENCODING, 'UTF-8');$mh = curl_multi_init();//add the two handlescurl_multi_add_handle($mh,$ch1);curl_multi_add_handle($mh,$ch2);$active = null;//execute the handlesdo {$mrc = curl_multi_exec($mh, $active);} while ($mrc == CURLM_CALL_MULTI_PERFORM);while ($active && $mrc == CURLM_OK) {if (curl_multi_select($mh) != -1) {do {$mrc = curl_multi_exec($mh, $active);} while ($mrc == CURLM_CALL_MULTI_PERFORM);}}$dom = new DOMDocument('1.0', 'utf-8');libxml_use_internal_errors(true);$dom->loadHTML($mrc);libxml_clear_errors();$xpath = new DOMXpath($dom);$data = array();$table_rows = $xpath->query('//table[@id="price_table"]/tbody/tr'); // target the row (the browser rendered <tbody>, but actually it really doesnt have one)if($table_rows->length <= 0) { // exit if not foundecho 'no table rows found';exit;}$s = "stxECna";foreach($table_rows as $tr) { // foreach row$row = $tr->childNodes;if($row->item(0)->tagName != '<tr class="carHeader"> <td>نام کارخانه </td> <td>نام خودرو </td> <td>قیمت نمایندگی (ریال) </td> <td>قیمت بازار (ریال) </td> </tr>') { // avoid headers$data[] = array('Name' => trim($row->item(2)->nodeValue),'Price' => trim($row->item(4)->nodeValue),);}}echo '<pre>';print_r($data); But don't display data ... when I use curl_init() to get data from one page without problem working and displaying data (name and price) but when use curl_multi_init dont display I really need..
  13. Hello I write the code to get and scrap data form website . That website have a navigation page (1,2,3,4,5) I want auto get data form one page to end page of website.mean(starting scrap from 1 page and then auto get data from two page ,...) . following is piece of my code witch I write. require_once "xpath.php";set_time_limit(0);$starUrl= "http://www.digionline.ir/Allprovince/viewcat/%D9%82%DB%8C%D9%85%D8%AA-%D8%AE%D8%B1%DB%8C%D8%AF-%D9%81%D8%B1%D9%88%D8%B4-%D9%85%D8%B4%D8%AE%D8%B5%D8%A7%D8%AA-%D9%84%D9%BE-%D8%AA%D8%A7%D9%BE---Laptop--/cat=10101";function sracperdigi($url){$baseUrl ="http://www.digionline.ir";$array = array();$xpath = new XPATH($url);//pluginha.com$produsttitleQuery = $xpath->query("//span[@class='product-page-detail-wrapper- text']/text()");$produstpriceQuery = $xpath->query("/html/body/div[5]/div/div/div[3]/div[2]/ul/li/span[1]/span[2]/text()");//$produstlinkQuery = $xpath->query("/html/body/div[5]/div/div/div[3]/div[2]/div[2]/span/a");for ($x = 0; $x <40; $x++){$string = $array[$x]['title'] = $produsttitleQuery->item($x)->nodeValue ."*";$string = $array[$x]['price'] = $produstpriceQuery->item($x)->nodeValue ."*";// $string = $array [$x]['link'] =$baseUrl.$produstlinkQuery->item($x)->nodeValue."*";}}
  14. Hello I write this script I want to update page every day or hour . <?php$arrtxt = file_get_contents('array.txt');$newarr = json_decode($arrtxt);//Select Name and Price from array $par1= array_column( $newarr, 0);$par2 = array_column( $newarr, 1);//Combine Name and Price array$c = array_combine($par1, $par2);foreach($c as $name=>$price){ echo 'Name:'.' '.$name.'<br />'.'<hr>'.PHP_EOL; echo 'price:'.' '.$price.'<br />'.'<hr>'.PHP_EOL;}
  15. Hello How can I extract array from txt file. $data = Array( [0] => Array ( [0] => AMDSempron 145 [1] => 860,000 [2] => 910,000 ) [1] => Array ( [0] => IntelCore 2 Quad Q8200 2.33GHz 4MB L2 Cache [1] => 1,800,000 [2] => 1,800,000 ) [2] => Array ( [0] => IntelCore i7-920 Processor (8M Cache, 2.66 GHz, 4.80 GT/s [1] => 3,300,000 [2] => 3,300,000 ) [3] => Array ( [0] => IntelCore⢠i5-3450 Processor -6M Cache, up to 3.50 GHz [1] => 5,600,000 [2] => 6,800,000 ) [4] => Array ( [0] => Intel® Core⢠i3-530 Processor -4M Cache, 2.93 GHz [1] => 2,350,000 [2] => 2,380,000 )} Then inputing array to text file. This file.txt Array( [0] => Array ( [0] => AMDSempron 145 [1] => 860,000 [2] => 910,000 ) [1] => Array ( [0] => IntelCore 2 Quad Q8200 2.33GHz 4MB L2 Cache [1] => 1,800,000 [2] => 1,800,000 ) [2] => Array ( [0] => IntelCore i7-920 Processor (8M Cache, 2.66 GHz, 4.80 GT/s [1] => 3,300,000 [2] => 3,300,000 ) [3] => Array ( [0] => IntelCore⢠i5-3450 Processor -6M Cache, up to 3.50 GHz [1] => 5,600,000 [2] => 6,800,000 ) [4] => Array ( [0] => Intel® Core⢠i3-530 Processor -4M Cache, 2.93 GHz [1] => 2,350,000 [2] => 2,380,000 )} Now How Can I extracting? I writed this code. <?phpfile_put_contents('array.txtl', print_r($data, TRUE));$arrtxt = file_get_contents('array.txt',treu);//Select Name and Price from array $par1= array_column( $arrtxt, 0);$par2 = array_column( $arrtxt, 1);//Combine Name and Price array$c = array_combine($par1, $par2);foreach($c as $name=>$price){ echo 'Name:'.' '.$name.'<br />'.'<hr>'.PHP_EOL; echo 'price:'.' '.$price.'<br />'.'<hr>'.PHP_EOL;}?> but give thise error: array_column() expects parameter 1 to be array, resource given in C:wampwwwcurlindex.php on line 28
  16. this website language is persian and Iranian; when I searching examp. download in google . google refering to this website witch have download tag and then this web site open site's in iframe. the alexa.com Speed ​​reduction is very much .... in 5 month alexa rank from 10 ,000,000 mil to 6,965 .. that website don use Ads in any web site .
  17. Hello. I find website below T but Idon't know how it's work ? is any php script like this ? http://jashnvareh.aliexirs.ir/%D9%85%D9%86%D8%A7%D8%B7%D9%82-%D9%86%D9%81%D8%AA-%D8%AE%DB%8C%D8%B2-%D8%AC%D9%86%D9%88%D8%A8%DB%8C.html
  18. I want display in result.htm display this : $titles="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$prices="<b>قیمت:</b>". $item['price'] . "</br> ";echo$titles="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$prices="<b>قیمت:</b>". $item['price'] . "</br> "; : led قیمت: 25000 ,.. but when use $html->save('result.htm') displaying main web pag of $html= file_get_html("http://www.digionline.ir/Allprovince/viewcat/%D9%82%DB%8C%D9%85%D8%AA-%D8%AE%D8%B1%DB%8C%D8%AF-%D9%81%D8%B1%D9%88%D8%B4-%D9%85%D8%B4%D8%AE%D8%B5%D8%A7%D8%AA-%D9%87%D8%A7%D8%B1%D8%AF-%D8%AF%D9%8A%D8%B3%D9%83-%D9%83%D8%A7%D9%85%D9%BE%D9%8A%D9%88%D8%AA%D8%B1/cat=20101",10); .. please run top script..
  19. hello I write this script with simple_html_do parser lib. now how can I save results I use $html->save('result.htm'); but display main web page url not my result <?phpinclude_once('simple_html_dom.php');// Create DOM from URL$html= file_get_html("http://www.digionline.ir/Allprovince/viewcat/%D9%82%DB%8C%D9%85%D8%AA-%D8%AE%D8%B1%DB%8C%D8%AF-%D9%81%D8%B1%D9%88%D8%B4-%D9%85%D8%B4%D8%AE%D8%B5%D8%A7%D8%AA-%D9%87%D8%A7%D8%B1%D8%AF-%D8%AF%D9%8A%D8%B3%D9%83-%D9%83%D8%A7%D9%85%D9%BE%D9%8A%D9%88%D8%AA%D8%B1/cat=20101",10);foreach($html->find('ul#product-page-product') as $ul) {{ foreach($ul->find('li') as $li) { $item['title']= $li->find('span.product-page-detail-wrapper-text', 0)->plaintext; $item['price'] = $li->find('span.product-detail-wrapper-price', 0)->plaintext; $lis[] = $item; }} } $ul = array();echo$titles="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$prices="<b>قیمت:</b>". $item['price'] . "</br> ";echo$titles="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$prices="<b>قیمت:</b>". $item['price'] . "</br> ";$html->save('result.htm');?> Thank's
  20. can you fix top code and Explain the fix code/ thanks
  21. Thank's for your help. Now I create <?phpinclude_once('simple_html_dom.php');// Create DOM from URLheader("Refresh: 300;");$html = file_get_html('http://www.digikala.com/Product/DKP-33708/Kenwood-KMM023-Food-Processor/%D8%BA%D8%B0%D8%A7%D8%B3%D8%A7%D8%B2-%DA%A9%D9%86%D9%88%D9%88%D8%AF-KMM023');$con = mysql_connect ("localhost","root", ""); mysql_select_db("price", $con); if (!$con) { die(mysql_error()); }else {// Find all article blocksforeach($html->find('div#content') as $article) { $item['title'] = $article->find('h1', 0)->plaintext; $item['intro'] = $article->find('h3', 0)->plaintext; $item['details'] = $article->find('span.finalprice', 0)->plaintext; $articles[] = $item;}$articles = array("$item"=>"title","$item"=>"intro","$item"=>"details");mysql_select_db ( "price", $con );mysql_qeury("CREATE TABLE Persons(id INT NOT NULL AUTO INCREMENT,PRIMARY KEY(id),title CHAR(30),intro TNT,details CHAR 30) ENGINE=MyISAM") or die(mysql_error());$debugquery = mysql_query("INSERT INTO Persons (title, intro, details) VALUES ('$articles')"); if (!$debugquery) { die(mysql_error()); }}echo$title="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$dec="<b>توضیحات:</b> ". $item['intro'] . "</br> ";echo$pr="<b>قیمت:</b> ". $item['details'] . " </br> ";//to fetch all images from a webpage$images = array();foreach($html->find('img') as $img) {$images[] = $img->src;}echo " $images[29]";?> but I have 2 problem. When run top code Receives Error line 23 Fatal error: Call to undefined function mysql_qeury() in C:wampwwwNew foldersimplehtmldom_1_5test.php on line 23 mysql_qeury("CREATE TABLE Persons(id INT NOT NULL AUTO INCREMENT,PRIMARY KEY(id),title CHAR(30),intro TNT,details CHAR 30) ENGINE=MyISAM") or die(mysql_error()); and what is database field table photo Specifications for save in database. type is :blob but what are other's setting? Thank's
×
×
  • Create New...