Jump to content

sarojthapa60

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by sarojthapa60

  1. I have 5 dropdowns on a tab of a website. I have a database table in MS SQL Server. The table has all the data of 5 dropdowns with one of the fieldNames called Region_Name, say the Region_Names are A, B, C, D, and E. I have written codes to display a table and enabled row editing for one of the RegionNames. Now, I am wondering if I could modify the same codes to display associated table with row editing enabled using different queries when a dropdown is clicked. That could reduce the code repetition and improve the performance. But I do not know how to achieve this. Could anyone please give me some hints? I am using PHP PDO to connect to the database.
  2. I have a Datatables using HTML (DOM) sourced data. I have 30 columns in my table. I have a print button, button when I print about 6 columns do not fit. Also, some cells have background colors. How can I customize this Print function so that I can print 11 by 17 preserving the background colors of the cells? My script for Datatables: <script> $(document).ready(function() { $('#myTable').DataTable( { "order": [[0, "asc"]], "paging": false, "scrollCollapse": true, "columnDefs": [{ "targets": [0], "visible": false, "searchable": false }], dom: 'Bfrtip', buttons: [ { extend: 'print', text: 'Print', } ] } ); } ); </script>
  3. My app has multiple navigation menus on the home page. The menus are created using <ul><li>. I want to open the tabs on the same parent page on the main section of the page. How can I use AJAX to do so?
  4. I have only four options in the dropdowns. I am trying to change the background color of the cell of the table, not the background color of the dropdown.
  5. Yes, $capacity indicates which color is selected. I was able to incorporate $capacity into the query and it matches the "colors" column in the matrix_dropdowns. I am trying a different approach now. In the form of edit.php, I created the dropdowns like: <tr> <td>Capacity</td> <td><label> <select name="txt_capacity" class="textfields" id="capacity"> <option id="0">Select One</option> <option id="1"> GREEN</option> <option id="2">AMBER</option> <option id="3">RED</option> <option id="4">BLACK</option> I am trying to create a javascript function to check the values and change the background color dynamically. Thanks. </select> </label> </td> </tr>
  6. Sorry about that. didn't know everyone could see that.
  7. I have dropdowns in my "Edit.php" file. When the edit option in index.php is clicked, it brings to the form. Some of the input for the forms have dropdowns queried from a table called matrix_dropdowns. What I am trying to achieve is: "Capacity" field has dropdowns namely GREEN, AMBER, RED, and BLACK. If an initial value is GREEN or the user chooses GREEN option, I want the background to be green, AMBER ->yellow color. The codes for edit.php is shown below: <?php require_once('include/database.php'); if (isset($_POST['btn_submit'])) { if (isset($_POST['txt_id'])) { $id = $_POST['txt_id']; } else { $id = ''; } if (isset($_POST['txt_capacity'])) { ////It has dropdowns, namely GREEN, AMBER, RED, BLACK. $capacity = $_POST['txt_capacity']; } else { $capacity = 0; } if (isset($_POST['txt_ownership'])) { $ownership = $_POST['txt_ownership']; } else { $ownership = ''; } try { $stmt = $conn->prepare("UPDATE MATRIX SET Capacity=:capacity, Ownership=:ownership WHERE OBJECTID =:id"); $stmt->execute(array(':capacity' => $capacity, ':ownership'=>$ownership, ':id' => $id)); if ($stmt) { header('Location:index.php'); exit(); } } catch (PDOException $e) { echo $e->getMessage(); } } $object_id=''; $capacity = ''; $ownership = ''; if (isset($_GET['id'])) { $id = $_GET['id']; $stmt = $conn->prepare("SELECT * FROM MATRIX WHERE OBJECTID=:id"); $stmt->execute(array(':id' => $id)); $row = $stmt->fetch(PDO::FETCH_ASSOC); $object_id = $row['OBJECTID']; $capacity = $row['Capacity']; $ownership = $row['Ownership']; } ?> <!DOCTYPE html> <html> <head> <title>Edit the Data</title> </head> <body> <h2>Edit the records</h2> <form action="" method="post"> <table border="3px" cellpadding="5px"> <tr> <td>Capacity</td> <td><label> <select name="txt_capacity" class="textfields" id="capacity"> <option id="0">Select One</option> <?php require_once('include/database.php'); $stmt = $conn->prepare("SELECT * FROM MATRIX_DROPDOWNS"); $stmt ->execute(); $result = $stmt->fetchAll(); foreach($result as $row){ ?> <option id="<?=$row['OBJECTID'];?>"><?=$row['colors']?></option> <?php } ?> </select> </label> </td> </tr> <tr> <td>Ownership</td> <td><label> <select name="txt_ownership" class="textfields" id="ownership"> <option id="0">Select One</option> <?php require_once('include/database.php'); $stmt = $conn->prepare("SELECT * FROM MATRIX_DROPDOWNS"); $stmt ->execute(); $result = $stmt->fetchAll(); foreach($result as $row){ ?> <option id="<?=$row['OBJECTID'];?>"><?=$row['colors']?></option> <?php } ?> </select> </label> </td> </tr> <tr> <td><label> <input type="hidden" name="txt_id" value="<?= $object_id; ?>"> </label> </td> <td><label><input type="submit" name="btn_submit" value="Submit"> </label> </td> </tr> </table> </form>
  8. require_once('include/database.php'); ?> <!DOCTYPE html> <html> <head> </head> <body> <section> <table id="myTable" class="tablesorter"> <thead> <tr> <th>Capacity</th> <th>Ownership</th> <th>Action</th> </tr> </thead> <tbody> <?php $stmt = $conn->prepare("SELECT * FROM MATRIX ORDER BY OBJECTID ASC"); $stmt ->execute(); $result = $stmt->fetchAll(); foreach($result as $row) { ?> <tr> <td><?=$row['Ownership'];?></td> <td><?=$row['Capacity'];?></td> <td><a href="edit.php?id=<?=$row['OBJECTID'];?>">Edit </a> </td> </tr> </tbody> <?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.