Jump to content

php_begins

Members
  • Posts

    259
  • Joined

  • Last visited

Everything posted by php_begins

  1. I tried the above and also few other formats, but didnt get any result.. one of the methods i tried was : $arrErrors['test'] = "Please Enter Client's name"; $this->view->arrErrors=$arrErrors['test']; Zend doc didnt provide any help on this one..
  2. I have the following code in zend: $arrErrors=array(); if (!empty($this->post['submit'])) { // Each time theres an error, add an error message to the error array // using the field name as the key. if (empty($this->post['client_name'])) $arrErrors['client_name'] = "Please Enter Client's name as it appears in the carrier software"; } if i set $this->view->arrErrors=$arrErrors in the controller, Can I access it as $this->arrErrors['client_name'] in the view?
  3. $lead_query=$this->db->query(" SELECT CONCAT(`first_name`, ' ', `last_name`) AS `client_name` , `state` FROM leads WHERE `lead_id`='$lead_id' "); The above worked for me.
  4. .i dont know how that attached file got uploaded there..
  5. I have the following mysql query: $lead_query=$this->db->query(" SELECT `first_name`, `last_name` , `state` FROM leads WHERE `lead_id`='$lead_id' "); $this->view->lead_query=$lead_query->fetchALL(); Now when I retrieve the above details I need to return the first_name last_name together(separated as space) and the name of the key as client_name in the array. I need it that way because when i return a json_encode($lead_query), I want to return the first_name.last_name as client_name.
  6. For a quick fix. I tried the following and worked. echo str_replace( array( '[', ']'), '', json_encode($this->view->lead_query));
  7. I have this jquery.ajax form which populates data from the database and auto fills the form fields upon button click. It works great when the form is of type <input type="text"> But it does not auto fill when the form field is a select box. here is my code so far! <script type="text/javascript"> $(document).ready(function() { function myrequest(e) { var lead_id = $('#lead_id').val(); $.ajax({ method: "GET", url: "/pdp/fetch-client-data/", dataType: 'json', cache: false, data: { lead_id: lead_id }, success: function( responseObject ) { alert('success'); $('#client_name').val( responseObject.client_name ); $('#state').val(responseObject.state); }, failure: function() { alert('fail'); } }); } $('#fetchFields').click(function(e) { e.preventDefault(); myrequest(); }); $("#lead_id").bind("change", function(e) { myrequest(); }); }); </script> <table width="600" align ='center'> <form action ='<?php echo $SERVER['PHP_SELF']; ?>' method='post'> <tr> <td> <label for="lead_id">Lead id: </label> <input type="text" name="lead_id" id="lead_id"> <button id="fetchFields">Fetch</button> </td> </tr> <tr> <td> Agent: <select name="agent"> <option value="">[select]</option> <?php foreach($this->agent_query as $agent){ ?> <option value="<?php echo $agent['id']; ?>"><?php echo $agent['name'];?></option> <?php } ?> </select> </td> </tr> <tr> <td> <label for="client_name">Client Name: </label> <input type="text" name="client_name" id="client_name"> </td> </tr> <tr> <td> <label for="state">State: </label> <select name="state" id='state'> <option id='state' value='1'></option> </select> </td> </tr> <tr> <td> # of Policies: <select name="policies"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </td> </tr> <tr> <td> <input type="submit" value="NEXT" name="submit"> </td> </tr> </form> </table>
  8. I am returning the following through JSON: $this->view->lead_query=$lead_query->fetchALL(); header('OK', true, 200); header('Content-type: application/json'); echo json_encode($this->view->lead_query); I am getting the results in this format: [{"client_name":"Steve Harris","state":"TX"}] Now if the above output was displayed without the square brackets [] I can populate the values in my form correctly. Is there a way i can return the output without the square brackets?
  9. oh is it because of the brackets []. is there a way i can remove it and echo?
  10. This is the output of json encode. I wonder why I am not able to retrieve the following data in my form fields! [{"client_name":"Steve Harris","state":"TX"}]
  11. Thanks you have been of great help. I ll dig deeper and come back with the solution.
  12. Thanks a lot. That solved one part of the problem. When I click fetch, the page doesnt refresh and i get a success alert. However it does not fill the remaining form fields. So i am not sure if the php code is getting the correct results and returning it back in proper json format.
  13. This is my php code: public function fetchClientDataAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $leadid=$this->get['lead_id']; $lead_query=$this->db->query(" SELECT client_name,state FROM `pdp_client_info` WHERE lead_id='$leadid' "); $this->view->lead_query=$lead_query->fetchALL(); //$this->view->lead-count=count($lead_query); if(count($lead_query) > 0) echo json_encode($lead_query); }
  14. when i click on the fetch button the page gets refreshed and i get nothin!
  15. I am using jquery.ajax to fetch remianing form elements when i click the fetch button. so i need to use something like $leadid=$_GET['leadid'] in the controller. I shall try the method above you suggested. This is how my view function looks like now: <script type="text/javascript"> $(document).ready(function() { function myrequest(e) { var leadid = $('#leadid').val(); $.ajax({ method: "GET", url: "/pdp/fetch-client-data.php", dataType: 'json', cache: false, data: { leadid: leadid }, success: function( responseObject ) { alert('success'); $('#clientname').val( responseObject.clientname ); $('#state').val(responseObject.state); /* once you've gotten your ajax to work, then go through and replace these dummy vals with responseObject.whatever */ }, failure: function() { alert('fail'); } }); } $('#fetchFields').click(function(e) { e.preventDefault(); myrequest(); }); }); [code]<form action ='<?php echo $SERVER['PHP_SELF']; ?>' method='post'> <tr> <td> <label for="leadid">Lead id: </label> <input type="text" name="leadid" id="leadid"> <button id="fetchFields">Fetch</button> </td> </tr> <tr> <td> <label for="clientname">Client Name: </label> <input type="text" name="clientname" id="clientname"> </td> </tr> <tr> <td> <label for="state">State: </label> <input type="text" name="state" id="state"> </td> </tr> </form>
  16. I am a beginner in the ZEND framework. I am passing a variable through ajax query like this $.ajax({ method: "GET", url: "/filename/fetch-client-data.php", dataType: 'json', // and so on I need to get the variable passed by the form. I dont know how to use the $_GET['varaible name'] from the form. Here is what I am trying in the controller function public function fetchClientDataAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $this->get('variablename')=$variable_name; } Can someone point me in the correct direction
  17. Here's what I got back. Can u please tell me what it means: id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE u ALL NULL NULL NULL NULL 49 100.00 Using where; Using filesort 1 SIMPLE l ref agent_id agent_id 5 consumer_united.u.id 3412 100.00 Using index
  18. Thanks guys..both the queries is literally stopping down the server. This is the result of explain statement for left join(phpmyadmin): I dont know what it means. id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE u ALL NULL NULL NULL NULL 49 Using where; Using filesort 1 SIMPLE l ref agent_id agent_id 5 u.id 1754 Using index I could not run an explain in my simple join query as i am waiting for someone to kill the query. The server is not responding.
  19. I was running this query and feel this is slowing down the server: $agent_query=$this->db->query(" SELECT u.id,u.name,u.team_id,l.agent_id from users AS u,leads AS l WHERE u.id=l.agent_id AND u.team_id IS NOT NULL AND u.is_active='1' ORDER BY u.name ASC "); Is there a better way to write the above code.
  20. Is there another way to count no of rows returned by a query.The following code returns 1 even though there is no result returned.(i am working on ZEND). $this->view->overdue_query = $overdue_query->fetchAll(); /*Get overdue count */ $this->view->overdue_count = count($overdue_query);
  21. I am writing code in the ZEND framework and i need to get the current day in like 2012-02-03: In the controller: $time=date('YYYY-mm-dd',time()); $this->view->time=$time; In view: <?php echo $this->time; ?> Output: 2012201220122012-0202-0303 I dont know why it is displaying like that instead of once...there is no loop anywhere.
  22. if its a query $query=select fields from tablename where fieldname='A' OR fieldname='B"; while($row=mysql_fetch_assoc($query)) { echo $row['fieldname']; } or something on the similar lines depending on what you need.
  23. It is not datetime data type..it is of type date.
×
×
  • 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.