
Senthilkumar
Members-
Posts
184 -
Joined
-
Last visited
Everything posted by Senthilkumar
-
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
-
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
-
Mr.Barand, Thanks for your reply, For me, the output of your code above still displays 1 on NPOSITION.
-
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?
-
Dear Barand, Thanks for your reply. Can you please modify my code for better understanding
-
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">×</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.
-
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.
-
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
-
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