Jump to content

dumb2champ

Members
  • Posts

    33
  • Joined

  • Last visited

dumb2champ's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello there.. I have a problem when loading comment from my database.. Here are working scripts which does not query the message/comment from database.. <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "responder"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //query the user table $sql = "SELECT * FROM user"; $result = $conn->query($sql); //get comment from array $comment = $_GET['comment'] + 1; //I want to replace below array comment with my database comment $ar = array( "Hello there.", "How are you?" ); require_once("facebook.php"); $config = array(); $config['appId'] = 'myapp'; $config['secret'] = 'mysecret'; $config['fileUpload'] = false; $fb = new Facebook($config); if ($result->num_rows > 0) { foreach ($result as $key) { $params = array( //long-live-token "access_token" => $key['offense_token'], //comment //need to replace this from database "message" => $ar[$comment], ); if($comment<10) { try { $ret = $fb->api('/my-comment-id/comments', 'POST', $params); echo 'Successfully posted to Facebook'; sleep(5); header('Location: set-comment.php?comment='.$comment); } catch(Exception $e) { echo $e->getMessage(); } } else{ echo "done"."<br>"; } } } ?> Above scripts working fine without querying from my database So my issues now, how do I query and loop each comment from database? Here my comment/message table.. TQ
  2. Hello everyone.. I have a question to delete comment based from user-id itself. I use PHP SDK to delete any comment to my facebook page and it was success as long as I specify the comment-id.. Below are my codes to delete a comment from comment-id $request = new FacebookRequest( $session, 'DELETE', '/{comment-id}' ); $response = $request->execute(); $graphObject = $response->getGraphObject(); Is it possible to delete comment based on user-id itself? I know that I just need to query the graph api to get the comment-id from A but each comment have different id`s so its hard to query the comment-id everytime.. For example: A, B, and C comment to my facebook post and I want to delete the comment where the user-id is from A? So, if the api scan and found out that A is commenting to my post, it will be deleted instead deleting B and C I really appreciate for any help from you guys.. Thanks
  3. What i mean was to output <q_name> object..thanks
  4. Thanks Barrand.. One more question..i dont quite understand the codes which is: foreach ($xml2->xpath('//item') as $i) { $a1[(string)$i->q_id] = (int)$i->value; } If i want to add another object say, <q_name>This is Q1<q_name> after <q_id> which is like this: <item> <q_id>4131001</q_id> <q_name>This is Q1<q_name> <----- <value>7</value> </item> How to edit the scripts?
  5. I got Notice: Undefined offset: 4131001 Output 4131001 Notice: Undefined offset: 4131001 on line 17 10 4232002 5
  6. sory the result should be 3 and 5...sory
  7. Hello... I want to calculate the value from 2 difference files using simplexml load file... But the result not as expected.. My output should be 7 and 5 where 10 - 7 and 8 - 3. My first xml files. <?xml version="1.0" encoding="UTF-8"?> <items> <item> <q_id>4131001</q_id> <value>10</value> </item> <item> <q_id>4232002</q_id> <value>8</value> </item> </items> My second xml files. <?xml version="1.0" encoding="UTF-8"?> <items> <item> <q_id>4131001</q_id> <value>7</value> </item> <item> <q_id>4232002</q_id> <value>3</value> </item> </items> My scripts. <?php $xml = simplexml_load_file('q1.xml'); $xml2 = simplexml_load_file('q2.xml'); foreach ($xml -> item as $item) { $value1 = $item->value; echo $item->q_id.'<br />'; //echo $value1.'<br />'; foreach ($xml2 -> item as $item2) { $value2 = $item2->value; $total = $value1 - $value2; echo $total.'<br />'; } } ?> The result should be 7 and 5 where 10 - 7 and 8 - 3 but there is another unknows value which is 3 and 1... How to solve the issue.. Thank for any help..
  8. Thanks for ur reply I just edit the codes and turn on error reporting...but no error occur I also update fclose after the loop...the result are same So why does the tabs/spaces exist? Do i need to add anything to trim/strip the black space/tabs? But when im echoing the output there`s blank spaces/tabs exist.. thanks
  9. Hello... I have problem concerning in php fwrite function... Each time i run the codes, it will add blank spaces/tab for every loop... My screenshot My Codes //create a file $fileCreate = fopen("test.txt","w") or die("Unable to open file!"); foreach ($in_xml_river->item as $item) { $pushData = $item->station_id."::LEVEL\r\n"; fwrite($fileCreate, $pushData); fclose($fileCreate) } Please help me out to solve this issue...thanks
  10. Thanks CroniX...thanks.. That what i want to achieve... I have done step 1 now to step 2... but seriously im new in this framework and js.... i hope you can help if there problem in my codes... thanks
  11. Ok..thanks for ur reply and solution but i know how to achieve ur solution... sorry...what i want is to refresh the view if theres new created data either from client(view)/server(database) side i know ajax can do the job by using setintervel if i not mistaken.... but i dont know how to make it to work with my scripts.... another solution is again using ajax by returning newest created item in database(timestamp).. u can see that my database keep track of any created/updated data.... thanks for ur time....i hope u can help me with the simplest solution by applying ajax to my scripts... thank you
  12. Thanks Anemic for ur respond... Yeah auto refresh the page can do the work but how to return only new data without getting all data in database? it is using ajax? How to achieve that?can you provide example...with my codes... Thanks...
  13. Hello... Im just started to codes in Laravel 5... I need help to auto update my view when theres new data in database... Below are screenshot of my view... this is my supplycontroller class SupplyController extends Controller { /** * Display a listing of the resource. * * @return Response */ public function index() { $supplies=Supply::all(); return view('supplies.index',compact('supplies')); } Below are my index.blade.php @extends('layout/template') @section('content') <h1>Supplies</h1> <a href="{{url('/supplies/create')}}" class="btn btn-success">Create Supply</a> <hr> <div class="ref"> <table class="table table-striped table-bordered table-hover"> <thead> <tr class="bg-info"> <th>Id</th> <th>Items</th> <th>Desc</th> <th colspan="3">Actions</th> </tr> </thead> <tbody> @foreach ($supplies as $supply) <tr> <td>{{ $supply->id }}</td> <td>{{ $supply->supply_item }}</td> <td>{{ $supply->supply_desc }}</td> <td><a href="{{url('supplies',$supply->id)}}" class="btn btn-primary">Read</a></td> <td><a href="{{route('supplies.edit',$supply->id)}}" class="btn btn-warning">Update</a></td> <td> {!! Form::open(['method' => 'DELETE', 'route'=>['supplies.destroy', $supply->id]]) !!} {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!} {!! Form::close() !!} </td> </tr> @endforeach </tbody> </table> </div> @endsection My database... Im really appriciate for anyone to help with examples... It it using javascripts?ajax? How to achieve the auto update view which return only updated/new data in database... 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.