Jump to content

Dharmender

Members
  • Posts

    31
  • Joined

  • Last visited

Posts posted by Dharmender

  1. My client wants to have backup and restore facility online.

     

    I have made online backup sql file.

     

    Now I want to allow user to upload sql file.

     

     

    You can't execute an sql file, you can use the mysql commands to use loadfile.

     

    But yes, this is a horrible, horrible idea.

     

  2. I want to display the items in tree structure with checkboxes. How can I get this.

     

    Suppose I have table

    Menus

    id, parent_id, menuname

     

    and Table

    operations

    menuid, roleid, edit ,delete, add, update

     

    How can I show the Menus in tree structure with add delete and edit checkboxes in front of them which dont have children

  3. I want to have role based access in Cakephp. I want that when I create a new Role the menu in tree structure should appear from where the admin can select the menu and operation. I have gone through ACl component but can't understand its functioning

  4. I have a form where user uploads file i.e. Excel Sheet

    The data read from sheet is to be store in mysql database.

    The headers location is not fixed. So I need to search the header with the mysql table column name.

    Records below header are to be inserted into database. How can I search teh header row in Excel using cakephp

  5. View is not displaying error messages.Validation done at model level

     

    My view is add.ctp

    <?php
    echo $this->Session->Flash();
    
    foreach($this->form->validationerrors as $errors)
    {
     echo $errors['Publishers'];
    }
    
    if(isset($updates))
    {
     $id=$updates['Agreement']['id'];
     $pubname=$updates['Agreement']['publisherid'];
    }
    echo $this->Form->create('Agreement', array('action' => 'add', 'type' => 'file'));
    //echo $this->Form->file('File');
    echo "<table><tr><td>Publisher Name</td><td>".$this->Form->input('Publishers',array('label'=>false,'default'=>@$pubname))."</td></tr>";
    echo "<tr><td>Agreement File</td><td>".$this->Form->file('File',array('label'=>false))."</td></tr>";
     echo "<tr><td colspan='2'>".$this->Form->input('id',array('label'=>false,'default'=>@$id,'type'=>'hidden'))."</td></tr>";
    echo "<tr><td colspan='2'>".$this->Form->submit('Upload',array('label'=>false,'after' => $this->Html->link('Cancel', array('action' => 'view'))))."</td></tr></table>";
    
    echo $this->Form->end();
    ?>
    

     

    Model is

    <?php
    //License Agreements
    //Created By Dharmender On 8-2-2013
    class Agreement extends AppModel
    {
    var $name = 'Agreement';
    var $validate=array(
    	 'Publishers' => array(
    		 'rule' => 'notEmpty',
    	 'message' => 'Please enter publisher name.'
     ));
    
    }
    ?>
    

     

    Controller is

    <?php
    class AgreementsController extends AppController {
    
    var $name = 'Agreements';
    var $components = array('Session');
    
    function add($id=null)
    {
     if($id!=null)
     {
    	 $updates=$this->Agreement->findById($id);
    	 $this->set('updates',$updates);
     }
    
     if(@$this->request->data['Agreement']['id']==NULL)
     {
    				 $this->Agreement->create();
    			 if (!empty($this->request->data) &&
    				 is_uploaded_file($this->request->data['Agreement']['File']['tmp_name']))
    				 {
    				 $fileData = fread(fopen($this->request->data['Agreement']['File']['tmp_name'], "r"),
    										 $this->request->data['Agreement']['File']['size']);
    				 $this->request->data['Agreement']['name'] = $this->request->data['Agreement']['File']['name'];
    				 $this->request->data['Agreement']['type'] = $this->request->data['Agreement']['File']['type'];
    				 $this->request->data['Agreement']['size'] = $this->request->data['Agreement']['File']['size'];
    				 $this->request->data['Agreement']['data'] = $fileData;
    				 if($this->request->data['Agreement']['Publishers']=='ram')
    					 {
    					 $id2=1;
    					 }
    					 else
    					 {
    						 $id2=2;	
    					 }
    				 $this->request->data['Agreement']['publisherid']=$id2;
    				 $this->request->data['Agreement']['createdon'] = date ('Y-m-d H:i:s');
    				 if($this->Agreement->save($this->data))
    				 {
    						 $this->Session->setFlash('File Uploaded Successfully!');
    						 $this->Redirect('view');
    					 }
    					 else
    					 {
    						 $this->Session->setFlash('Error in File Uploading!');
    				 }
    				 }
    		 }
     else
     {
    				 $this->Agreement->id=$this->request->data['Agreement']['id'];
    				 if (!empty($this->request->data) &&
    					 is_uploaded_file($this->request->data['Agreement']['File']['tmp_name'])) {
    					 $fileData = fread(fopen($this->request->data['Agreement']['File']['tmp_name'], "r"),
    											 $this->request->data['Agreement']['File']['size']);
    					 $this->request->data['Agreement']['name'] = $this->request->data['Agreement']['File']['name'];
    					 $this->request->data['Agreement']['type'] = $this->request->data['Agreement']['File']['type'];
    					 $this->request->data['Agreement']['size'] = $this->request->data['Agreement']['File']['size'];
    					 $this->request->data['Agreement']['data'] = $fileData;
    					 if($this->request->data['Agreement']['Publishers']=='ram')
    					 {
    					 $id2=1;
    					 }
    					 else
    					 {
    						 $id2=2;	
    					 }
    					 $this->request->data['Agreement']['publisherid']=$id2;
    					 $this->request->data['Agreement']['createdon'] = date ('Y-m-d H:i:s');
    					 if($this->Agreement->save($this->data))
    					 {
    						 $this->Session->setFlash('Record Updated Successfully!');
    						 $this->Redirect('view');
    					 }
    					 else
    					 {
    						 $this->Session->setFlash('Error in File Updating!');
    					 }
    				 }
    				 }
    			 }
    
    
    

  6. Thanks for taking the time to help me.

     

    I am not sure where to start with the effect I would like.

     

    There will be a dropdown list and I would like a picture next to it.

     

    Then, as the user selects different inputs from the dropdown list the picture will change accordingly.

     

    I appreciate any help I can receive.

     

    Thank you,

     

    Brett Hartel

     

    You can use Ajax and jquery for onchange of dropdownlist value and submit the value. On that value show image

    $.("#drpdn).change(function(){

    $.ajax({

    type: "POST",

    url: "image.php", //your current php file

    data: 'drpdn':$("#drpdn").val(),

    dataType: 'html',

    success: function() {

     

    }

    });

    });

     

    get the value of drpdn and use it to find image corresponding to it like

    if(isset($_POST['drpdn']))

    {

    $drpdn=$_POST['drpdn'];

    ///code to find image corresponding to $drpdn

  7. Output the checkbox wherever you want it to be. Then attach some Javascript to its onclick so that all the name=customers[] checkboxes are checked.

     

    Are you using any Javascript framework, like jQuery or whatever else is still popular these days that isn't jQuery?

    Using jquery.

    Can I select all checkboxes using single click in Jquery. How can I get the values of all checkboxes in jquery for single click action

  8. You can save the value of doctype in variable and use it or you can directly use it

    $result=mysql_query("SELECT * FROM comm_statement WHERE paycode = 'PAYJBARR'");

     

    while($test = mysql_fetch_array($result))

    {

    $id = $test['id'];

    $doctype=$test['doctype'];

    echo "<tr align='left'><font size='-2' face='Arial, Helvetica, sans-serif'>";

    echo"<td>". $test['date']. "</td>";

    echo"<td>" .$test['batch']."</td>";

    echo"<td>" .$test['advisercode']."</td>";

    echo"<td>" .$doctype."</td>";

    echo"<td><a href ='../../documents/advisers/DMS/$doctype'>download</a>";

  9. If you take checkboxes name as an array

     

    <input type = "checkbox" name = "country[]" value="states">United states <input type ="checkbox" value = "uk" name="country[]">united kingdom <br>

    <input type = "submit" name ="submit">

     

    You can get the value of checkboxes using loop

     

    foreach($_POST['country'] as $value)

    {

    echo 'Checked: '.$value.';

    //You can put your code here

     

    }

  10. i am trying to catch the id from the url sent in this way...

    http://localhost/Form/Admin/members_details.php?uid=14<---------------- This Id
    

     

    I have tried using $_REQUEST but its not workinh...

     

    I have done this...

    $uid=$_REQUEST['uid'];
    $sql="SELECT * FROM students WHERE student_id='$uid'";
    $result= mysql_query($result);
    while($row=mysql_fetch_array($result)){
    ..........
    ...........
    ........ There are few codes....
    }
    

     

    But i'm getting error in while loop...

     

    Error is

    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Form\Admin\members_details.php on line 6
    

     

    Any help would be grately appreciated...

    in Your select statement remove single quote from $uid. Query should be

    $sql="SELECT * FROM students WHERE student_id=$uid";

     

    And in your While loop use mysql_fetch_assoc($result) and in your code write row['filedname']

     

    And if you want to use mysql_fetch_array the the code would be

     

    while($row[]=mysql_fetch_array($result))

    {

    ///use $row[0] $row[1] etc....

    }

  11. don't use a foreach loop for database results. this is especialy true when using mysql_fetch_array as it will provide double the results that are looking for.

    The tried and tested method:

    $sql = "SELECT id, name FROM supplierinfo LIMIT 3"; //your SQL changed to only get the 3 results
    $result = mysql_query($sql) or die(mysql_error()); //execute the query
    while($row = mysql_fetch_assoc($result)) //while there are records then step through each row and fetch data into an associative array called $row
    {
    //display record by using $row['name'] and/or $row['id']
    }
    

     

    It only displays current row. I want next two rows also to be displayed next to it.

     

    I have found the solution for it using mysql_data_seek($result,$i)

    Like This

        $result=mysql_query($sql);
    			   $j = mysql_num_rows($result) - 1;
                           echo $j;
                           for ($i=0;$i<=$j; )
                           {
    
                           if (mysql_data_seek($result, $i))
                           {
    					    $row=mysql_fetch_assoc($result);
    					    //echo $row
    					  }
    				 if (mysql_data_seek($result, ++$i))
                           {
    					    $row=mysql_fetch_assoc($result);
    					    //echo $row
    					  }
    					 if (mysql_data_seek($result, ++$i))
                           {
    					    $row=mysql_fetch_assoc($result);
    					    //echo $row
    					  }
    			 }
    
    

  12. I am not sure what you are actually trying... But this is an example how we create a list box dynamically with Database values..

     

    $query="select id, name from supplierinfo";
    $result = mysqli_query( $dbc, $query);
    
     echo '<select name="" >';
     	 while( $row = mysqli_fetch_array($result, MYSQLI_NUM)) {
    echo '<option value="' . $row[0] . '">' . $row[1] . '</option>';
    }
     echo '</select>'; 

     

    Is this what you are searching?

    I want listbox as given here http://demo.koolphp.net/Examples/KoolListBox/Features/CheckBoxes/index.php

  13. I am not sure what you are actually trying... But this is an example how we create a list box dynamically with Database values..

     

    $query="select id, name from supplierinfo";
    $result = mysqli_query( $dbc, $query);
    
     echo '<select name="" >';
     	 while( $row = mysqli_fetch_array($result, MYSQLI_NUM)) {
    echo '<option value="' . $row[0] . '">' . $row[1] . '</option>';
    }
     echo '</select>'; 

     

    Is this what you are searching?

     

    I know this procedure. What I want is every option should have checkbox before it.

    Check this link http://demo.koolphp.net/Examples/KoolListBox/Features/CheckBoxes/index.php

×
×
  • 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.