Jump to content

Senthilkumar

Members
  • Posts

    171
  • Joined

  • Last visited

Everything posted by Senthilkumar

  1. Hi, Thanks for your reply. I have modified my code ans per your suggesion. My modified cose is <tr style="text-align: center" class="parent-container"> <td></td> <td> <select class="background" name="District[]"> <option value="">District</option> </select> </td> <td> <select id="Brand" name="Brand[]" class="Brand"> <option value="">Select Brand</option> <?php $query = "SELECT * FROM brand ORDER BY Brand_Name ASC"; $result = $conn->query($query); if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Brand_ID'].'">'.$row['Brand_Name'].'</option>'; } }else{ echo '<option value="">Country not available</option>'; } ?> </select> </td> <td> <select id="Category" name="Category[]" class="Category"> <option value="">Select Brand first</option> </select> </td> <td> <select id="Sub_Category" name="Sub_Category[]" class="Sub_Category"> <option value="">Select Category first</option> </select> </td> <td> <select id="Model" name="Model[]" class="Model"> <option value="">Select Sub-Category first</option> </select> </td> <td><input type='number' name="Quantity[]"></td> <td><input type='number' name="ASP[]"></td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="<?php echo $ID; ?>" /> </td> </tr> <script> $(document).on('change', '.Brand', function(){ var BrandID = $(this).val(); if(BrandID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Brand_ID='+BrandID, success: function (html) { $('#Category').html(html); $('#Sub_Category').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { $('#Category').html('<option value="">Select Brand first</option>'); $('#Sub_Category').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); $(document).on('change', '.Category', function(){ var CategoryID = $(this).val(); if(CategoryID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Category_ID='+CategoryID, success: function (html) { $('#Sub_Category').html(html); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); } else { $('#Sub_Category').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); $(document).on('change', '.Sub_Category', function(){ var Sub_CategoryID = $(this).val(); if(Sub_CategoryID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Sub_Category_ID='+Sub_CategoryID, success: function (html) { $('#Model').html(html); } }); } else { BrandID.find('.Model').html('<option value="">Select Sub_Category first</option>'); } }); </script> When i am selecting Brand it is working (Category list is populating). But wheni am selecting Category again this is not working and Sub-Category list is not pupulating. Can you please lookon it
  2. Dear Team, I am adding table row in dynamically and in that row i having 4 drop down list called Brand, Category, Sub-Category and model. I want the dropdown list to be populated from databse based on selection of another one ( Brand --> category --> Sub-Category --> model). My php page is My databse is My php code is <?php session_start(); error_reporting(0); ini_set('display_errors','Off'); include("../connection.php"); include("../paginator.class.php"); $id=$_SESSION['id']; if($_SESSION['id'] == '') { session_destroy(); // header("location:logout.php"); //redirect to index.php } $query=mysqli_query($conn,"SELECT * FROM users where id='$id'"); $row=mysqli_fetch_array($query); $Name = $row['Name']; $Emp_No = $row['Emp_No']; $Designation = $row['Designation']; $Type = $row['User_Type']; $Type1 = $row['User_Type']; $Branch = $row['Branch']; $Approver = $row['Approver']; ?> <!DOCTYPE html> <!-- Created by CodingLab |www.youtube.com/CodingLabYT--> <html lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <!--<title> Drop Down Sidebar Menu | CodingLab </title>--> <link rel="stylesheet" href="css/tiv.css"> <!-- Boxiocns CDN Link --> <link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <div class="sidebar"> <div class="logo-details"> <img src="Image/Schwing_Logo.jpg" style="height:30px; width:100px; margin-left:10px; margin-top:0px" /> <img src="Image/XCMG_LOGO.png" style="height:30px; width:100px; margin-left:10px; margin-top:0px" /> </div> <ul class="nav-links"> <li> <a href="Dashboard.php" > <i class='bx bxs-dashboard'></i> <span class="link_name">Dashboard</span> </a> </li> <li> <a href="TIV.php" class="active"> <i class='bx bx-trending-up'></i> <span class="link_name">TIV Sales Data</span> </a> </li> <li> <a href="Marketing.php"> <i class='bx bxs-business'></i> <span class="link_name">Marketing & Promotion</span> </a> </li> <li> <a href="PartsandService.php"> <i class='bx bxs-wrench'></i> <span class="link_name">Parts & Service</span> </a> </li> <li> <a href="Manpower.php"> <i class='bx bxs-user-detail'></i> <span class="link_name">Manpower</span> </a> </li> <li> <a href="Manpower.php"> <i class='bx bx-book'></i> <span class="link_name">Equipement & Population</span> </a> </li> <li> <div class="iocn-link"> <a href="#"> <i class='bx bx-wallet-alt'></i> <span class="link_name">Expenses</span> </a> <i class='bx bxs-chevron-down arrow' ></i> </div> <ul class="sub-menu"> <li><a href="Employee_Expense.php">Employee Expense</a></li> <li><a href="Infrastructural_Expense.php">Infrastructural Expense</a></li> <li><a href="Other_Expense.php">Other Expense</a></li> </ul> </li> <li> <a href="#"> <i class='bx bxs-report'></i> <span class="link_name">Reports</span> </a> </li> <li> <div class="profile-details"> <div class="profile-content"> <!--<img src="image/profile.jpg" alt="profileImg">--> </div> <div class="name-job"> <div class="profile_name"><?php echo $Name; ?></div> <div class="job"><?php echo $Designation; ?></div> </div> <a href="Logout.php"> <i class='bx bx-log-out'></i> </a> </div> </li> </ul> </div> <section class="home-section"> <nav> <div class="home-content" style="margin-top:15px"> <span class="text">TIV Sales Data</span> </div> </nav> <br /> <!-- Body Content--> <div class="main" style="top:50px;bottom:20px"> <div> <form method="POST" action=""> <p>Select Month: <input type="month" name="month" placeholder="Select Month" required style="width:auto;border:solid; border-color:black;font-family:Cambria;border-radius:5px;height:30px" /> </p> <table class="table"> <tr> <th style="width:50px">#</th> <th>District</th> <th>Brand</th> <th>Category</th> <th>Sub Category</th> <th>Model</th> <th style="width:80px">Quantity</th> <th>Average Selling Price</th> </tr> <tbody id="tbody"> <template id="row-template"> <tr style="text-align: center"> <td></td> <td> <select class="background" name="District[]"> <option value="">District</option> <?php $qry = mysqli_query($conn,"SELECT DISTINCT Brand_Name FROM model ORDER BY Brand_Name ASC"); while($row = $qry->fetch_assoc()) { echo "<option"; if(isset($_REQUEST['Brand']) and $_REQUEST['Brand']==$row['Brand_Name']) echo ' selected="selected"'; echo ">{$row['Brand_Name']}</option>\n"; } ?> </select> </td> <td> <select id="Brand" name="Brand[]"> <option value="">Select Brand</option> <?php $query = "SELECT * FROM brand ORDER BY Brand_Name ASC"; $result = $conn->query($query); if($result->num_rows > 0){ while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Brand_ID'].'">'.$row['Brand_Name'].'</option>'; } }else{ echo '<option value="">Country not available</option>'; } ?> </select> </td> <td> <select id="Category" name="Category[]"> <option value="">Select Brand first</option> </select> </td> <td> <select id="Sub_Category" name="Sub_Category[]" > <option value="">Select Category first</option> </select> </td> <td> <select id="Model" name="Model[]"> <option value="">Select Sub-Category first</option> </select> </td> <td><input type='number' name="Quantity[]"></td> <td><input type='number' name="ASP[]"></td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="<?php echo $ID; ?>" /> </td> </tr> </template> </tbody> </table> <div style="text-align:center"> <button type="button" onclick="addItem();" style="font-family:Cambria;float:left;background: #0A2558;color:white;cursor:pointer; height:30px; border-radius:5px; padding:5px">Add New<i class='bx bx-plus-medical' style="margin-left:10px"></i></button> <input type="submit" name="addInvoice" value="Submit" style="width:100px;background: #0A2558; color:white;font-family:Cambria;border-radius:5px;height:30px;" /> </div> </form> <?php if (isset($_POST["addInvoice"])) { $month = $_POST["month"]; $Dealername = $Name; $newDate = date("M-Y", strtotime($month)); //for ($a = 0; $a < count($_POST["lang"]); $a++) foreach($_POST['lang'] as $ID => $VAL){ $Brand = $_POST['Brand'] [$ID]; $Category = $_POST['Category'] [$ID]; $Sub_Category = $_POST['Sub_Category'] [$ID]; $Model = $_POST['Model'] [$ID]; $Quantity = $_POST['Quantity'] [$ID]; $ASP = $_POST['ASP'] [$ID]; $District = $_POST['District'] [$ID]; $sql = "INSERT INTO tiv (Month, Brand, Category, Sub_Category, Model, Quantity, Dealer_Name, District, ASP) VALUES ('$newDate', '$Brand', '$Category', '$Sub_Category', '$Model', '$Quantity', '$Dealername', '$District', '$ASP')"; mysqli_query($conn, $sql); } } ?> <script> const template=document.getElementById('row-template'); const tbody=document.getElementById('tbody'); let itemCount=0; function addItem(){ const newRow = template.content.cloneNode(true); const firstTd = newRow.querySelector('td:first-child'); firstTd.textContent=++itemCount; tbody.appendChild(newRow); } </script> </div> </div> </section> <script> $(document).ready(function(){ $('#Brand').on('change', function(){ var BrandID = $(this).val(); if(BrandID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Brand_ID='+BrandID, success:function(html){ $('#Category').html(html); $('#Sub_Category').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); }else{ $('#Category').html('<option value="">Select Brand first</option>'); $('#Sub_Category').html('<option value="">Select Category first</option>'); $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); $('#Category').on('change', function(){ var CategoryID = $(this).val(); if(CategoryID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'Category_ID='+CategoryID, success:function(html){ $('#Category').html(html); } }); }else{ $('#Category').html('<option value="">Select Model first</option>'); } }); $('#Sub_Category').on('change', function(){ var stateID = $(this).val(); if(stateID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'state_id='+stateID, success:function(html){ $('#Sub_Category').html(html); } }); }else{ $('#Sub_Category').html('<option value="">Select Category first</option>'); } }); $('#Model').on('change', function(){ var stateID = $(this).val(); if(stateID){ $.ajax({ type:'POST', url:'ajaxData.php', data:'state_id='+stateID, success:function(html){ $('#Model').html(html); } }); }else{ $('#Model').html('<option value="">Select Sub_Category first</option>'); } }); }); </script> <script> function Category_click_click(){ value_select = $("#Category_click").val(); $.post('TIV.php',{"Category_click":value_select},function(data){ }) } </script> <script> function Sub_Category_click(){ value_select = $("#Sub_Category").val(); $.post('TIV.php',{"Sub_Category":value_select},function(data){ }) } </script> <script> let arrow = document.querySelectorAll(".arrow"); for (var i = 0; i < arrow.length; i++) { arrow[i].addEventListener("click", (e)=>{ let arrowParent = e.target.parentElement.parentElement;//selecting main parent of arrow arrowParent.classList.toggle("showMenu"); }); } let sidebar = document.querySelector(".sidebar"); let sidebarBtn = document.querySelector(".bx-menu"); console.log(sidebarBtn); sidebarBtn.addEventListener("click", ()=>{ sidebar.classList.toggle("close"); }); </script> </body> </html> And ajaxData.php code is <?php // Include the database config file include("../connection.php"); if(!empty($_POST["Brand_ID"])){ // Fetch state data based on the specific country $query = "SELECT * FROM model WHERE Brand_ID = ".$_POST['Brand_ID']." "; $result = $conn->query($query); // Generate HTML of state options list if($result->num_rows > 0){ echo '<option value="">Select Category</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Category_ID'].'">'.$row['Category_Name'].'</option>'; } }else{ echo '<option value="">Category not available</option>'; } }elseif(!empty($_POST["Category_ID"])){ // Fetch city data based on the specific state $query = "SELECT * FROM model WHERE Sub_Category_ID = ".$_POST['Category_ID']." "; $result = $conn->query($query); // Generate HTML of city options list if($result->num_rows > 0){ echo '<option value="">Select Sub-Category</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Sub_Category_ID'].'">'.$row['Sub_Category_Name'].'</option>'; } }else{ echo '<option value="">Sub-Category available</option>'; } }elseif(!empty($_POST["Sub_Category_ID"])){ // Fetch city data based on the specific state $query = "SELECT * FROM model WHERE Model_ID = ".$_POST['Sub_Category_ID']." "; $result = $conn->query($query); // Generate HTML of city options list if($result->num_rows > 0){ echo '<option value="">Select Model</option>'; while($row = $result->fetch_assoc()){ echo '<option value="'.$row['Model_ID'].'">'.$row['Model_Name'].'</option>'; } }else{ echo '<option value="">Model available</option>'; } } ?> Once i crete the new row, the bran list is populating. But if i select the Brand, the other lis is not populating. It is not calling the script and ajax function. I have attached my bot the file here for your reference. Can any one help me to correct the mistake ajaxData.txt TIV.txt
  3. This is my page When i am clicking add button I want to create the drop down like bellow picture But witht the following code if I press add button, it is not creating row. <script> var items = 0; function addItem() { items++; var html = "<tr>"; html += "<td>" + items + "</td>"; html += "<td><select name='tb1' > <?php $qry = mysqli_query($conn,"SELECT Brand_Name FROM brand ORDER BY Brand_Name ASC"); while($row = $qry->fetch_assoc()) { echo "<option"; if(isset($_REQUEST['tb1']) and $_REQUEST['tb1']==$row['Brand_Name']) echo ' selected="selected"'; echo ">{$row['Brand_Name']}</option>\n"; } ?> </select></td>"; html += "<td><input type='text' name='category[]'></td>"; html += "<td><input type='text' name='sub_category[]'></td>"; html += "<td><input type='text' name='model[]'></td>"; html += "<td><input type='number' name='qty[]'></td>"; html += "</tr>"; var row = document.getElementById("tbody").insertRow(); row.innerHTML = html; } </script> My table structure is Please correct my code
  4. Dear Mr.Barand, Can you change the code for using it on MySQL. Because I am using MySQL database for my project.
  5. Hi Team, I created code for add the table row dynamically using add button and insert the values which is entered on that row. I configured the input on my row. I want to add the drop down option which is pull the dat from databse. My entire code is <div class="home-content"> <div> <?php if (isset($_POST["addInvoice"])) { $month = $_POST["month"]; $newDate = date("M-Y", strtotime($month)); for ($a = 0; $a < count($_POST["brand"]); $a++) { $sql = "INSERT INTO tiv (Month, Brand, Category, Sub_Category, Model, Quantity) VALUES ('$newDate', '" . $_POST["brand"][$a] . "', '" . $_POST["category"][$a] . "', '" . $_POST["sub_category"][$a] . "', '" . $_POST["model"][$a] . "', '" . $_POST["qty"][$a] . "')"; mysqli_query($conn, $sql); } } ?> <form method="POST" action=""> <input type="month" name="month" placeholder="Select Month" required style="width:auto;border:solid; border-color:black;font-family:Cambria;border-radius:5px;height:30px" /> <table style="margin-top:10px; height:15px"> <tr> <th>#</th> <th>Brand</th> <th>Category</th> <th>Sub Category</th> <th>Model</th> <th>Quantity</th> </tr> <tbody id="tbody"></tbody> </table> <p> <button type="button" onclick="addItem();" style="font-family:Cambria;background: #0A2558;color:white;cursor:pointer; margin-top:10px;height:30px; border-radius:5px; padding:5px">Add New +</button> </p> <input type="submit" name="addInvoice" value="Submit" style="width:150px; margin-top:10px;font-family:Cambria;border-radius:5px;height:30px;" /> </form> <style type="text/css"> table { width: 100%; border-collapse: collapse; font-family:Cambria; border-radius:10px; } table tr th { border: 1px solid black; padding: 5px; font-family:Cambria; background: #0A2558; color:white; border-color:white; } table tr td { border: 1px solid black; padding: 5px; font-family:Cambria; color:#0A2558; border-color:#0A2558; } </style> <script> var items = 0; function addItem() { items++; var html = "<tr>"; html += "<td>" + items + "</td>"; html += "<td><input type='text' name='brand[]'></td>"; html += "<td><input type='text' name='category[]'></td>"; html += "<td><input type='text' name='sub_category[]'></td>"; html += "<td><input type='text' name='model[]'></td>"; html += "<td><input type='number' name='qty[]'></td>"; html += "</tr>"; var row = document.getElementById("tbody").insertRow(); row.innerHTML = html; } </script> </div> </div> I am trying to use the bellow code on my <td> <select class="background" name="Department" onchange="submit()"> <option value="">Department</option> <?php $qry = mysqli_query($conn,"SELECT DISTINCT Brand FROM model ORDER BY Brand ASC"); while($row = $qry->fetch_assoc()) { echo "<option"; if(isset($_REQUEST['Department']) and $_REQUEST['Department']==$row['Brand']) echo ' selected="selected"'; echo ">{$row['Brand']}</option>\n"; } ?> </select> But it is not working. Can anyone tell me how to use the select option on my code
  6. Dear Mr.Barand, I got the solution what i want exactly. Thanks for your immediate support.
  7. I will modify the employee id later. I updated the table for your reference
  8. Dear Mr.Barand, I have upload my table. you can download that from the bellow link https://drive.google.com/file/d/10cHJOMTP1WpB0_fOu6OuS1FXXWW5bO2D/view?usp=share_link Please provide the query
  9. Dear Team, I want to write the query for fileter the databse and display the values based on the user login. My data structure is like and the database is like When Groupleader 1 is login, he has to view Engineer 1, Engineer 2, Engineer 3 & Engineer 4 When Groupleader 2 is login, he has to view Engineer 5, Engineer 6, Engineer 7 & Engineer 8 When Groupleader 3 is login, he has to view Engineer 9, Engineer 10, Engineer 11 & Engineer 12 When Groupleader 4 is login, he has to view Engineer 11, Engineer 12, Engineer 13 & Engineer 14 When Teamleader 1 is login, he has to view Groupleader 1, Groupleader 2, Engineer 1, Engineer 2, Engineer 3, Engineer 4, Engineer 5, Engineer 6, Engineer 7 & Engineer 8 When Teamleader 2 is login, he has to view Groupleader 3, Groupleader 4, Engineer 9, Engineer 10, Engineer 11, Engineer 12, Engineer 13, Engineer 14, Engineer 15 & Engineer 16 When ASM is login, he has to view Teamleader 1, Teamleader 2, Groupleader 1, Groupleader 2,Groupleader 3, Groupleader 4, Engineer 1, Engineer 2, Engineer 3, Engineer 4, Engineer 5, Engineer 6, Engineer 7, Engineer 8, Engineer 9, Engineer 10, Engineer 11, Engineer 12, Engineer 13, Engineer 14, Engineer 15 & Engineer 16 When Manager is login, he has to view ASM, Teamleader 1, Teamleader 2, Groupleader 1, Groupleader 2,Groupleader 3, Groupleader 4, Engineer 1, Engineer 2, Engineer 3, Engineer 4, Engineer 5, Engineer 6, Engineer 7, Engineer 8, Engineer 9, Engineer 10, Engineer 11, Engineer 12, Engineer 13, Engineer 14, Engineer 15 & Engineer 16 How to filter the database for above my requirement. Can any one help me to solve this
  10. Dear Team, For my table display, I'm making a php mysqli query that turns short lower numbers to greater numbers. I am using the following query $qryStr= "SELECT * FROM mark WHERE Branch = '$Branch' ORDER BY BPosition ASC"; In my table, i am getting the following output on column Branch Position But I want the output should be display like 1,2,3,4,5,6,7,8,9,10,11,12,13,14 etc... Can anyone correct my query
  11. Mr.Barand, You are right. In my table, the "Average" column is in Varchar. No i changed it to decimal format and it is shorts correctly. Thanks for your immediate support
  12. Mr.Barand, Thanks for your reply, For me, the output of your code above still displays 1 on NPOSITION.
  13. Dear team, I'm using a SQL query to get the number of positions based on the value of the field. SQL Query is For BPosition: $rnk = "SELECT Average, Emp_Name, FIND_IN_SET( Average, ( SELECT GROUP_CONCAT(DISTINCT Average ORDER BY Average DESC ) FROM mark WHERE Branch = '$Branch' )) AS rank FROM mark WHERE Emp_Name = '$Emp_Name' AND Year = '$Year' ORDER BY Average DESC "; $rest = mysqli_query($conn,$rnk); $row5 = mysqli_fetch_assoc($rest); $Rank= $row5['rank']; For NPosition: $rnk = "SELECT Average, Emp_Name, FIND_IN_SET( Average, ( SELECT GROUP_CONCAT(DISTINCT Average ORDER BY Average DESC ) FROM mark )) AS rank FROM mark WHERE Branch = '$Branch' AND Emp_Name = '$Emp_Name' AND Year = '$Year' ORDER BY Average DESC "; $rest = mysqli_query($conn,$rnk); $row5 = mysqli_fetch_assoc($rest); $All= $row5['rank']; SQL table "mark" is The first code is for the column BPosition. The position of the column average inside his own branch will be found by this code after it filters the branch. Nposition is the second code. This code will locate the average column's position across all branches. When I use the aforementioned code, it will determine the average column's location depending on the first digit of the inputted integer. Find the Nposition column's outcome. The score is 9 for the first row. It should actually be 3. Nposition, however, displays 1. Can somebody tell me where the error is in my code?
  14. Dear Barand, Thanks for your reply. Can you please modify my code for better understanding
  15. Dear Team, Based on the table row selection from my existing table and display all parameters to another table using Ajax query. My table button is <td align='center'> <a class="link" href="#?edit=<?php echo $Approvel_id ; ?>" onclick="getProfileData(<?php echo $Approvel_id; ?>)">View</a> </td> Based on the Id selection on above button the values should display on bellow table <div id="id02" class="w3-modal "> <div class="container full border w3-modal-content w3-card-4 w3-animate-zoom w3-padding" style="margin:20px;padding:10px;overflow:auto;width:98%;height:auto"> <h2></h2><br /><br /> <div > <br /> <span onclick="document.getElementById('id02').style.display='none'" class="w3-button w3-xlarge w3-hover-red w3-display-topright" title="Close Modal">&times;</span> </div> <div class="tbl-header"> <table cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th align='center' style="width:4%">S.No</th> <th style="width:25%">Description</th> <th style="width:25%">Ratings</th> <th style="width:5%">Target</th> <th style="width:5%">Actual</th> <th style="width:17%">Remarks</th> <th style="width:20.5%">Document</th> </tr> </thead> <tbody> <tr> <td align='center' style="width:4%"> <?php echo $n++; ?> </td> <td style="width:25%"> <span id="Point_Description"></span> </td> <td align='center' style="width:5%"> <span id="Point_Marks"></span> </td> <td style="width:25%"> <span id="Marks_Target"></span> </td> <td align='center' style="width:5%"> <span id="Marks_Actual"></span> </td> <td align='center' style="width:5%"> <span id="Marks_Description"></span> </td> <td align='center' style="width:19%"> <a href=" http://localhost:15296/<?php echo $Directory; ?>/<?php echo $Document; ?>" target="_blank"> <?php echo $Document; ?> </a> </td> </tr> </tbody> </table> </div> </div> </div> My ajax query is <script> function getProfileData(id) { $.ajax({ method: "GET", url: "User_Statment_view.php?id=" + id, success: function(data){ var tmp = data.split("&"); $('#Point_Marks').html(tmp[0]); $('#Point_Marks').html(tmp[1]); $('#Marks_Target').html(tmp[2]); $('#Marks_Actual').html(tmp[3]); $('#Marks_Description').html(tmp[4]); $('#Document').html(tmp[5]); $('#Directory').html(tmp[6]); $('#id02').show(); } }) } </script> My User_Statment_view.php code is <?php include("connection.php"); if(isset($_GET['id'])){ $ID = $_GET['id']; $query = "SELECT* FROM approvel where Approvel_id={$ID}"; $result = mysqli_query($conn, $query); $row1 = mysqli_fetch_array($result); $Name = $row1['Emp_Name']; $Month = $row1['Month']; $sql = "SELECT * FROM marks WHERE Engg_Name = '$Name' AND Month = '$Month' "; $result1 = mysqli_query($conn,$sql); $array[] = array(); while($row = mysqli_fetch_assoc($result1)){ $array[] = $row; } echo $array[0]['Point_Description']. '&'; echo $array[1]['Point_Marks']. '&'; echo $array[3]['Marks_Target']. '&'; echo $array[4]['Marks_Actual']. '&'; echo $array[5]['Marks_Description']. '&'; echo $array[6]['Document']. '&'; echo $array[7]['Directory']; } When i am running my code, i am getting 14 array values on my User_Statment_view.php and my table i am getting only one row value instead of 13 row values. can any one help me how to get all my 13 rows on this table.
  16. Dear Team, I had created page for displaying the profile details along with user image. For that i am using the bellow code to upload and display it. I don't want to use another button for insert the image on database. single button should work both the operations (select and update). <div class="col-md-4"> <div class="profile-img"> <img src="../UserImage/<?=$UserImage?>" alt="" /> <div class="file btn btn-lg btn-primary"> Change Photo <input type="file" name="file" /> </div> </div> </div> In <?php if(isset($_POST['file'])){ $name = $_FILES['file']['name']; $target_dir = "UserImage/"; $target_file = $target_dir . basename($_FILES["file"]["name"]); // Select file type $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); // Valid file extensions $extensions_arr = array("jpg","jpeg","png","gif"); // Check extension if( in_array($imageFileType,$extensions_arr) ){ // Upload file if(move_uploaded_file($_FILES['file']['tmp_name'],$target_dir.$name)){ $address = $_POST['address']; $query = "UPDATE users SET User_Image = '$name' WHERE id = '$id'"; $result = mysqli_query($conn,$query); } } } ?> Can any one help me for this.
  17. Hi team, I amusing 3 drop box on my page inside 3 different forms. Users, Department and Assigned. The user form is used to select the user and sending to another table. The Department and Assigned form is using to filter the table data's. In this i am facing the problem is, when ever is am selecting any of the drop box it resetting another drop box values. if i select any of one of the drop box, it should not reset another drop box which is already selected. <form method="get" > <select name="tb1" onchange="submit()"> <option>Select User</option> <?php $qry = mysqli_query($conn,"SELECT DISTINCT Name FROM users ORDER BY Name ASC"); while($row = $qry->fetch_assoc()) { echo "<option"; if(isset($_REQUEST['tb1']) and $_REQUEST['tb1']==$row['Name']) echo ' selected="selected"'; echo ">{$row['Name']}</option>\n"; } ?> </select> </form> <th scope="col" style="width:20%"> <form method="get" > <select class="background" name="Department" onchange="submit()"> <option>Department</option> <?php $qry = mysqli_query($conn,"SELECT DISTINCT Department FROM points ORDER BY Department ASC"); while($row = $qry->fetch_assoc()) { echo "<option"; if(isset($_REQUEST['Department']) and $_REQUEST['Department']==$row['Department']) echo ' selected="selected"'; echo ">{$row['Department']}</option>\n"; } ?> </select> </form> </th> <th scope="col" style="width:20%"> <form method="get" > <select class="background" name="Assigned" onchange="submit()"> <option>Assigned to</option> <?php $qry = mysqli_query($conn,"SELECT DISTINCT Assigned FROM points ORDER BY Assigned ASC"); while($row = $qry->fetch_assoc()) { echo "<option"; if(isset($_REQUEST['Assigned']) and $_REQUEST['Assigned']==$row['Assigned']) echo ' selected="selected"'; echo ">{$row['Assigned']}</option>\n"; } ?> </select> </form> </th> <?php $condition = ""; if(isset($_GET['Department']) and empty(isset($_GET['Assigned']))) { $condition .= " AND Department ='".$_GET['Department']."'"; } if(isset($_GET['Assigned']) and empty(isset($_GET['Department']))) { $condition .= " AND Assigned ='".$_GET['Assigned']."'"; } if(!empty(isset($_GET['Department'])) and !empty(isset($_GET['Assigned']))) //if(isset($_GET['Department']) and isset($_GET['Assigned'])) { $condition .= " AND Department ='".$_GET['Department']."' AND Assigned ='".$_GET['Assigned']."'"; } $qryStr = "SELECT * FROM points WHERE 1 ".$condition." ORDER BY Point_id ASC"; $qry = mysqli_query($conn, $qryStr); I am attaching my file here for your reference. Please help me to solve this. Assignment.txt
  18. Dear Team, I am new on this forum. I am trying to insert test and file from my GI. My code is <?php if(isset($_POST['submit'])){ $Engg_Name = $Name; $Engg_No = $Emp_No; $Month = $_POST['month']; if(!empty($_POST['lang'])) { foreach($_POST['lang'] as $ID => $VAL){ $Point_Description = $_POST['description'] [$ID]; $Point_Marks = $_POST['rating'] [$ID]; $Marks_Target = $_POST['target'] [$ID]; $Marks_Actual = $_POST['actual'][$ID]; $Marks_Description = $_POST['remarks'] [$ID]; $name = $_FILES['file']['name'] [$ID]; $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["file"]["name"][$ID]); $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); if(move_uploaded_file($_FILES['file']['tmp_name'][$ID],$target_dir.$name)){ $insertquery = "INSERT INTO kra.marks (Engg_Name, Engg_No, Month, Point_Description, Point_Marks, Marks_Target, Marks_Actual, Marks_Description, Document) VALUES('$Engg_Name', '$Engg_No', '$Month', '$Point_Description', '$Point_Marks', '$Marks_Target', '$Marks_Actual', '$Marks_Description', '$name')"; $result = mysqli_query($conn, $insertquery); } } } } ?> <tr> <td align='center' style="width:4%"> <?php echo $n++; ?> </td> <td style="width:25%"> <?php echo $Ass_Description; ?> </td> <td hidden align='center' style="width:5%"> <input type="text" name="description[]" id="target" value="<?php echo $Ass_Description; ?>" class="tbl-input-cus" tabindex="1" /> </td> <td style="width:25%"> <?php echo $Ass_Marks; ?> </td> <td hidden align='center' style="width:5%"> <input type="text" name="rating[]" id="target" value="<?php echo $Ass_Marks; ?>" class="tbl-input-cus" tabindex="1" /> </td> <td align='center' style="width:5%"> <input type="text" name="target[]" id="target" value="1" class="tbl-input-cus" tabindex="1" /> </td> <td align='center' style="width:5%"> <input type="text" name="actual[]" id="actual" value="" class="tbl-input-cus" tabindex="1" /> </td> <td align='center' style="width:17%"> <input type="text" name="remarks[]" id="remarks" value="" class="tbl-input-cus1" tabindex="1" /> </td> <td align='center' style="width:19%"> <input type="file" name="file[]" id="file" value="" class="tbl-input-cus1" tabindex="1" /> </td> <td hidden align='center' style="width:10%"> <input type="checkbox" checked="checked" class="checkbox" name='lang[]' value="<?php echo $ID; ?>" /> </td> </tr> In above code, If the file is not attaching values are not transferring to database. i want if file is not attached also text field should insert to database. Can any one please help me to solve this
×
×
  • 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.