Jump to content

Search the Community

Showing results for tags 'datatable'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 4 results

  1. It give an the link like http://localhost/aps/undefined Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.35 (Win32) OpenSSL/1.1.0i PHP/7.2.11 //The php code to fetch data //The php code to fetch data <?php include('db.php'); $query = ''; $output = array(); $query .= "SELECT * FROM users "; if(isset($_POST["search"]["value"])) { $query .= 'WHERE first_name LIKE "%'.$_POST["search"]["value"].'%" '; $query .= 'OR last_name LIKE "%'.$_POST["search"]["value"].'%" '; } if(isset($_POST["order"])) { $query .= 'ORDER BY '.$_POST['order']['0']['column'].' '.$_POST['order']['0']['dir'].' '; } else { $query .= 'ORDER BY id DESC '; } if($_POST["length"] != -1) { $query .= 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length']; } $statement = $connection->prepare($query); $statement->execute(); $result = $statement->fetchAll(); $data = array(); $filtered_rows = $statement->rowCount(); foreach($result as $row) { $sub_array = array(); $sub_array[] = $row["first_name"]; $sub_array[] = $row["last_name"]; $sub_array[] = '<button type="button" name="update" id="'.$row["id"].'" class="btn btn-warning btn-xs update">Update</button>'; $sub_array[] = '<button type="button" name="delete" id="'.$row["id"].'" class="btn btn-danger btn-xs delete">Delete</button>'; $data[] = $sub_array; } $output = array( "draw" => intval($_POST["draw"]), "recordsTotal" => $filtered_rows, "recordsFiltered" => get_total_all_records(), "data" => $data ); echo json_encode($output); ?> //javasrcipt jquery var dataTable = $('#user_data').DataTable({ "processing":true, "serverSide":true, "order":[], "ajax":{ url:"fetch.php", type:"POST" }, "columnDefs":[ { "targets":[0, 3, 4], "orderable":false, }, ] });
  2. How do disable searching in specific column like Action col Id--Username--Subject--Action | Do not search oTable = $('.datatable table').dataTable({ "bJQueryUI": false, "bAutoWidth": false, "sPaginationType": "full_numbers", "sDom": '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>', "oLanguage": { "sSearch": "<span>Filter all:</span> _INPUT_", "sLengthMenu": "<span>Show entries:</span> _MENU_", "oPaginate": { "sFirst": "First", "sLast": "Last", "sNext": "Next", "sPrevious": "Previous" } }, "order": [], /* No initial order */ "aoColumnDefs": [{ "bSortable": false, "aTargets": ['nosort'] /* Colomn data not sortable. Use <th class="nosort"> */ }] });
  3. Hi, I am a PHP noob. I have a table in which I am showing data from a mysql database. I'm using PDO to do the database stuff. Thus far, all good. In the table I have a hidden field that stores my unique identifier for that row. Each row in the table has an 'Edit' button. I am showing the row in a DataTable. I am displaying the data using form text elements so I can make it editable in place. I have all that working. The problem 'I think' is that the form elements in every row have the same name as in every other row. If I show a single record I can change something and click edit and it works fine. If I fill the table with records, then change something in a row and click edit, it doesn't work. I have tried to concatenate an index number onto the names of each field, thus making them all unique, but it still isn't working. Here is some code: try { if(isset($_POST['update'])){ $updatedQuery = "UPDATE fac_detail SET first_name=:fname, last_name=:lname, height=:height ,cap=:cap,colors=:color WHERE employee_id=:hidden"; $stmt = $dbh->prepare($updatedQuery); $stmt->bindParam(':fname', $_POST['firstName'], PDO::PARAM_STR); $stmt->bindParam(':lname', $_POST['lastName'], PDO::PARAM_STR); $stmt->bindParam(':height', $_POST['height'], PDO::PARAM_STR); $stmt->bindParam(':cap', $_POST['cap'], PDO::PARAM_STR); $stmt->bindParam(':color', $_POST['color'], PDO::PARAM_STR); $stmt->bindParam(':hidden', $_POST['hidden'], PDO::PARAM_STR); $stmt->execute(); } $sql = "SELECT * FROM fac_detail"; $stmt = $dbh->prepare($sql); $stmt->execute(); $arrValues = $stmt->fetchAll(PDO::FETCH_ASSOC); $row = $stmt->fetch(); } catch(PDOException $e) { die($e->getMessage()); } echo "<form action=facultyPage.php method= post>"; echo '<table id="recordTable">'; echo '<thead>'; echo '<tr>'; echo "<th>First Name"; echo "<th>Last Name"; echo "<th>Height</th>"; echo "<th>Cap</th>"; echo "<th>Color</th>"; echo "<th>Editable BUTONNNS</th>"; echo '</tr>'; echo '</thead>'; echo '<tbody>'; $num = 0; foreach ($arrValues as $row){ echo "<tr>"; echo "<td>" . "<input type=text name=firstName value=" . $row['first_name'] . " </ td>"; echo "<td>" . "<input type=text name=lastName value=" . $row['last_name'] . " </ td>"; echo "<td>" . "<input type=text name=height value=" . $row['height'] . " </ td>"; echo "<td>" . "<input type=text name=cap value=" . $row['cap'] . " </ td>"; echo "<td>" . "<input type=text name=color value=" . $row['colors'] . " </ td>"; echo "<td>" . "<input type=hidden name=hidden value='" . $row['employee_id'] . "' /> "; //TODO dropdowns //echo '<td><select name="degree"></td>'; //echo ' <option></option>'; //echo ' <option></option>'; //echo '</select> '; //echo '<td><select name="school" disabled="disabled"></td>'; //echo '<option></option>'; //echo '<option></option>'; //echo '</select>'; echo '<input type="submit" name= "update" value="Update" /></td>'; echo '</tr>'; $num++; } echo '</tbody>'; echo '</table>'; echo "</form>"; I am showing it in a datable, I have that working fine. Each rows form elements have the same names. I think thats where the problem lies. Anyone know an approach or trick I can implement so the submit button knows which row it's on? Thanks in advance...
  4. Hello all, new to the forum. I have been struggling with a PHP problem for the past week and have turned to you as a last resort. I have everything set up mostly right, but there are specific features that I need from http://datatables.net/index that I would love to feature on my inventory page. What happens on my page, is that the whole csv contents show. But the rows do not hide as in the examples you can see on the datatables website. The search bar also does not appear. These are standard features nestled within the datatables.js code. So I am guess they disappear because of the way the PHP is set up to view the rows. These features are really important for the future functionality of my site as well! I have the PHP code as follows: <?php set_time_limit(0); function csv_split($line,$delim=',',$removeQuotes=true) { #$line: the csv line to be split #$delim: the delimiter to split by #$removeQuotes: if this is false, the quotation marks won't be removed from the fields $fields = array(); $fldCount = 0; $inQuotes = false; for ($i = 0; $i < strlen($line); $i++) { if (!isset($fields[$fldCount])) $fields[$fldCount] = ""; $tmp = substr($line,$i,strlen($delim)); if ($tmp === $delim && !$inQuotes) { $fldCount++; $i += strlen($delim)-1; } else if ($fields[$fldCount] == "" && $line[$i] == '"' && !$inQuotes) { if (!$removeQuotes) $fields[$fldCount] .= $line[$i]; $inQuotes = true; } else if ($line[$i] == '"') { if ($line[$i+1] == '"') { $i++; $fields[$fldCount] .= $line[$i]; } else { if (!$removeQuotes) $fields[$fldCount] .= $line[$i]; $inQuotes = false; } } else { $fields[$fldCount] .= $line[$i]; } } return $fields; } $html_body = '<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="/css/demo_page.css"> <link rel="stylesheet" type="text/css" href="/css/demo_table.css"> <title>CSV Contents</title> <style type="text/css"> <!-- .style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; } .style9 {font-size: 12px} .logo h1 {position: absolute; top: 5px; right: 5px; font-size:14px; } .logo img-with-text {float: left; left 5px; font-size:14px; .img-with-text {text-align: justify; width: 40%; height: 20%;} .img-with-text img {display: block; margin: 0 auto;} .search {margin : 0px;} --> </style> <script class="jsbin" src="http://datatables.net/download/build/jquery.dataTables.nightly.js"></script> <script type="text/javascript" language="javascript" src="/js/jquery.js"></script> <div class="img-with-text"> <img src="/image002.png" alt="sometext" /> <p>WC" is West Coast warehouse- please add approximately 2-3 weeks for the arrival to East Coast.<br><br> </p> </div> <div class="logo"> <br>Last Updated on '.date("F j, Y, g:i a",time()+3600).' </h1> </div> </head> <body id="dt_example"> <div id="container"> <h1> Check Inventory Here</h1> <table> <thead> <tr> <th>Item No</th> <th>Description</th> <th>Price</th> <th>Available</th> <th>Back Ordered</th> <th>On Order</th> <th>ETA WH</th> <th>WC On Hand</th> <th>WC On Ord</th> <th>WC Order Date</th> </tr> </thead> <tbody> '; $fp=fopen("csv/inventory4.html",'w'); $write=fputs($fp,$html_body,strlen($html_body)); $i=0; $content = file("webinvt.txt"); foreach($content as $line) { $l=csv_split($line); if(!strstr($l[11],"SET")) { if($i==10) { $tmp = '<tr>'; $write=fputs($fp,$tmp,strlen($tmp)); $i=0; } $onhand = (int)$l[15]; $committed = (int)$l[16]; $avail = $onhand - $committed; $wcdate = substr($l[23],4); $eastdate = substr($l[19],4); if(strstr($l[1],"DISC")) { $html_body ='<tr "> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr>'; } else { $html_body ='<tr> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr> '; } $write=fputs($fp,$html_body,strlen($html_body)); $i++; } } $html_body=' </tbody> <tfoot> <tr> <th>Item No</th> <th>Description</th> <th>Price</th> <th>Available</th> <th>Back Ordered</th> <th>On Order</th> <th>ETA WH</th> <th>WC On Hand</th> <th>WC On Ord</th> <th>WC Order Date</th> </tr> </tfoot> </table> </body> </html>'; $write=fputs($fp,$html_body,strlen($html_body)); fclose($fp); ?> Furthermore, I have to include this piece of javascript inside the HTML variable.: $(document).ready(function() { $('#example').dataTable(); } ); Any help will be greatly 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.