Dharmender
-
Posts
31 -
Joined
-
Last visited
Posts posted by Dharmender
-
-
I need to upload SQL file and run it in controller in cakephp. I am unable to execute using exec and shell_exec both returns errors i.e. exec given empty string and shell_exec gives null value.
How to run mysql command using exec or shell_exec
-
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
-
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
-
I tried xpdf. But its of no help. I have tried pdf2text also. but it returns text. I want the result in array so that I can further process it as per my need.
-
I have a PDF file. I want to read the table in PDF file and store it in array
Any suggestions
-
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
-
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!'); } } } }
-
I need ajax pagination script with edit and delete options. I have created one but when I delete a record it doesnot get updated where as when i add or edit record it gets updated.
-
I need to create a module where a user can upload csv,xml or excel file and the data from file can be inserted into MySql database.Any plugin which can do it
-
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
-
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
-
I have checkboxes with arrays like this
foreach($result as $row)
{
<input type="checkbox" name="customers[]" value=$row['id'] />$row['name']<br>;
}
I want a CheckBox above all these on whose click all checkboxes of customer[] should be selected
-
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>";
-
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
}
-
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....
}
-
I am java developer and now working on PHP. I Have learnt Drupal and CakePHP. but facing problems in simple PHP
-
Easiest option is to save it as a CSV file, and then import it into Excel.
1. How can we save it as csv.
2. Why not directly into .xls format
-
I have generated HTML table from Mysql data using PHP. I want to export this table to Excel. I have 'googled' a lot but not satisfied with it.
-
<snip removed 100's of lines of quoted post>
Why you are again and again connecting to database and generating it.
Use it once at top of page. For generating table you can echo tr like this echo "<tr><td>"
-
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 } }
-
$event_date = date('Y-m-d', strtotime($event_date));
Any suggestion guys??tnx..
From where the value of $event_date is coming. Is it on form submit
-
In Mysql query I want to display three records at time
$sql="select id,name from supplierinfo"; $result=mysql_query($result); foreach($result as $row) { //display record here for current row // I want next two records here }
-
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
-
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
Cakephp-- Run Sql File in controller
in Frameworks
Posted
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.