Jump to content

livewirerules

Members
  • Posts

    45
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

livewirerules's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a feed that contains over 10000 vehicles and is about 300 mb and trying to grab and display the name and the price of each vehicle.The problem is it displays all the data in the feed. Below is the feed that i used <vehicle> <type>Double Cab </type> <price>19.5k</price> <model>GTX</model> <descrip>sdsadasdasdsa</descrip> </vehicle> <vehicle> <type>Cruise </type> <price>78k</price> <model>Ultra</model> <descrip>sdsadasdasdsa</descrip> </vehicle> <vehicle> <type>Jeep/ Wagon </type> <price>2k</price> <model>Body Kit</model> <descrip>sdsadasdasdsa</descrip> </vehicle> I’m using the below code. $url = 'vcfeed.php'; $xname ="test"; $xPassword ="testuser"; $post_data = array("username" => $xname, "password" => $xPassword"); $ch = curl_init($url); $c[CURLOPT_POST] = true; $c[CURLOPT_POSTFIELDS] = $post_data; foreach($c as $k=>$v){$c[$k] = $v;} curl_setopt_array($ch,$c); $xml = curl_exec($ch); curl_close($ch); $z = new XMLReader; $z->open($xml); $doc = new DOMDocument; while ($z->read() && $z->name !== 'vehicle'); while ($z->name === 'vehicle') { $node = simplexml_import_dom($doc->importNode($z->expand(), true)); echo $node->model; echo $node->price; $z->next('vehicle'); } Although i have used echo $node->model; echo $node->price; It doesn’t show those 2 values for each result. Can someone tell me what am i doing wrong here?
  2. It is a list of phone numbers stored in a new line 578854745 578854845 578854945 578854545 578857545
  3. Hi Im trying to load telephone numbers from a csv file and work around the array key values. But when when i try all the key values seems to be Zero. I tried to sort and assing new array key values but still its the same. Below is the code if (($open=fopen("phone.csv","r"))!== FALSE) { while (($data=fgetcsv($open))!==FALSE) { foreach ($data as $key =>$numbr){ /// working code logic echo $key."<br>"; } }} the output is as below 0 0 0 0 0 0 0 can someone please tell me how to assign the keys.
  4. $count=0; $numb=50; foreach ($sepkeys as $dbkey) { for ($page=10;$page<=$numb;$page=$page + 10) { // the if block $count=$count+1; } } I am trying to maintain a separate a count for each key number in the above code. Eg: key- 574, it searches from pages 10-50 and increments the count by 1. The problem that I have is the count is continuous. After searching for the first key and moves on to the next key and them I need the count to start from the beginning rather than being continuous. Eg: key-874 : count = 22, in my case the next key 875 : the count is 23 I need to make it 1. I removed the if block and several lines because the code is too long. Can someone please suggest me a way how to do it
  5. Figured it out using an array.. works fine now
  6. when i echo the variable $name out side the loop it says "Notice: Undefined variable name" and when i echo it inside the loop it works fine
  7. How do i use the values withing a while loop out side the loop? eg: $sql="select *from custwhere account='".$number."'"; $result=mysql_query($sql) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $name=$row['username']; $email=$row['email']; } I want to use the variables $name and $email outside the loop.. Ho wdo i do it?
  8. sorry... actually its a partial code.The complete code within the loop was about 200 lines,i just edited for a few lines. there are no syntax errors
  9. Im am trying to retrieve all the transaction information that is done by user. Below is my code $sql="select * from trans where tfid='987456'"; $result=mysql_query($sql) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $date=$row['h_date']; $ref=$row['ref']; price=$row['price']; echo"<tr> <td>$date</td> <td>$ref</td> <td>$price</td> </tr>"; I have around 6 transactions with the same tfid. but in the above code it shows only the first result.. how do i show all the 6 transactions? thanks
  10. how do i return a value from a loop within a function? function deprecated() { $sql="select * from table where id=1"; $result=mysql_query($sql) or die(mysql_error()); while ($row=mysql_fetch_array($result)) { $date=$row['date']; $cat=$row['cat']; } } i want to return both $date and $cat.... How do i do it?
  11. Can anyone tell how to Disable Maximum execution time in PHP? although i have set it to 3000 seconds it still stops at 60 seconds? Any help how to disable the time limit?
  12. Im tring to pass 2 variables to a function that uses Curl through a loop. testfunction($id,$page) curl_setopt($ch, CURLOPT_URL, "testserver.com/index.php?id=$id&page=$page"); The problem is that the result works only the first time. When i pass $id=5 and $page 5 it works fine. But when its incremented by the loop where $id=10 and $page =6. Nothing seems to be displayed. Can anyone please tell me when i am doing wrong??
  13. I need to match text that contain forward slashes /hello /test /MyWorks For eg: i want to match "/hello"? any help will be appreciated
×
×
  • 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.