It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am using 2 div elements as tabber
1) search candidate
2) my list.In search candidate when i select some candidate ,than that candidate is added to selected_candidate table and displayed in my list div ,but to display it in my list i have to reload whole page ,how can i display it without reloading whole page
<div class="tabber" style="width: auto;">
<div <?php if(isset($_POST['submita'])){ echo "class=\"tabbertab tabbertabhide\"";}else{echo "class=\"tabbertab\"";} ?>>
<h3>SEARCH CANDIDATE</h3>
//.....select candidate code.....//
</div>
<div <?php if(isset($_POST['searchsel_list'])){ echo "class=\"tabbertab tabbertabdefault\"";}else{echo "class=\"tabbertab\"";} ?>>
<h3>MY LIST</h3>
<div id="tabr">
<script>
$("td").removeAttr("style");​
</script>
<form method="post" action="csearch.php?epage=csearch" name="mylist">
<div class="CSSTableGenerator">
<table id="mylist_remark">
<caption>SELECTED CANDIDATE LIST</caption>
<!-- headings -->
<tr>
<th>REMARK</th>
<th> <input name="delete_sel" id="delete_sel" value="DELETE" type="submit" class="button"/></th>
<th>NAME</th>
<th>CELL NO</th>
<th>STATUS</th>
<th>EMAIL ID</th>
<th>LOCATION</th>
<th>QAULIFICATION INFORMATION</th>
<th>KIND OF WORK</th>
<th>DETAILED CV</th>
</tr>
<!-- /headings -->
<?php
if($mresult_set)
{
if (mysql_num_rows($mresult_set) == 0)
{
echo "<tr>";
echo "<td colspan=\"9\" ><p align=\"center\" class=\"message\"> <blink><span style=\"color:red;\" > NO CANDIDATE SELECTED</span></blink></p></td>";
echo "</tr>";
}
$j=0;
while($data_set1 = mysql_fetch_array($mresult_set))
{
// $i=0;
if($data_set1['ca']=='')
{
$qua="";
}
else
{
$qua=$data_set1['ca'];
}
if($data_set1['cs']=='')
{
$qua="";
}
else
{
$qua.=",".$data_set1['cs'];
}
if($data_set1['cwa']=='')
{
$qua.="";
}
else
{
$qua.=",".$data_set1['cwa'];
}
if($data_set1['completed']=='')
{
$qua.="";
}
else
{
$qua.=", Completed(".$data_set1['completed'].")";
}
if($data_set1['persuing']=='')
{
$qua.="";
}
else
{
$qua.=", Persuing(".$data_set1['persuing'].")";
}
echo "<tr >";
echo "<td><input id={remark{$j}} type=\"text\" class=\"fancyText\" onkeyup=\"writeremark(this.id,{$data_set1['eid']},{$emprid});\" value=\"{$data_set1['remark']}\" maxlength=\"15\" placeholder=\"Write Remark\" /></td>";
echo "<td style=\"text-align:center;\"><input id=\"listrow_sel{$j}\" type=\"checkbox\" name=\"list_sel[]\" value=\"{$data_set1['eid']}|{$emprid}\" /></td>";
echo "<td>{$data_set1['ename']} {$data_set1['lname']}</td>";
echo "<td>{$data_set1['ecell']}</td>";
echo "<td>{$data_set1['eposition']}</td>";
echo "<td>{$data_set1['eemail']}</td>";
if($data_set1['ecity']=='')
{
echo "<td>{$data_set1['ecountry']}</td>";
}
else
{
echo "<td class=\"showmsg\" title=\"Country ={$data_set1['ecountry']}, State = {$data_set1['estate']} \" >{$data_set1['ecity']}</td>";
}
// echo "<td>{$data_set['ecountry']},{$data_set['estate']},{$data_set['ecity']}</td>";
echo "<td>{$qua}</td>";
echo "<td>{$data_set1['other_work1']} {$data_set1['other_work2']}{$data_set1['other_work3']}{$data_set1['other_work4']} {$data_set1['other_work5']} {$data_set1['other_work6']} {$data_set1['other_work7']} {$data_set1['other_work8']} {$data_set1['other_work9']} {$data_set1['other_work10']}{$data_set1['other_work1e']} {$data_set1['other_work2e']} {$data_set1['other_work3e']} {$data_set1['other_work4e']} {$data_set1['other_work5e']} {$data_set1['other_work6e']} {$data_set1['other_work7e']} {$data_set1['other_work8e']} {$data_set1['other_work9e']} {$data_set1['other_work10e']}</td>";
echo "<td><a style=\"cursor:hand;\" href=\"detailcv.php?id={$data_set1['eid']}&flag=0\" target=\"_blank\" ><input style=\"cursor:auto;width:40px;\" class=\"button\" name=\"cv\" type=\"button\" value=\"C V\" /></a></td>";
//echo "<td class=\"edit\" contenteditable=\"true\">Write Remark</td>";
echo "</tr>";
$j++;
}
}
?>
<tr><td colspan="10">
<img src="images/pdfdown.jpg" alt="Adobe Doc" width="42" height="42" title="Download List In PDF"/>   
<a id="showcand" href="<?php echo $listurl1;?>"><img src="images/excel.gif" alt="Excel Doc" width="42" height="42" title="Download List In Excel "/></a>
<?php ?>
</td></tr>
</table></div>
</form>
</div>
In this Image i am showing tabber,when i click on MY list ,hoe can i load its form without loading whole page so that selected candidate will be visible,i came to know that it can be done using Ajax ,but i dont know how i can do it in my code
you can do with the help of ajax. for that you have to call ajax function on select candidate whom you want to add to your list.
ajax function demo are as follows:
function getList(){
$.ajax({
type: "POST",
url: "List.php", // file where you process the list.
data: {name:name1,sda:name2}, // post data you want to pass to the file for processing
success:function(data){
//change the content of your mylist div here
}
});
}
you can try it.
Related
My question is how to display specific content based on user session php.
I have a file called profile.php. When a user click on another user the first user gets redirected to the profile.php file. In this file I want the users to be able to see all the posts that user has made.
Image illustration:
Something like this:
<?php
if ($_SESSION['username'] == ($_GET[‘id’])) {
//DISPLAY rows with info from Database just like the attached code.
//DISPLAY edit button ONLY if the current user session is the same as the current id of the profile page.
}
?>
profile.php code below:
<?php
session_start();
require('connect.php');
if (#$_SESSION["username"]) {
?>
<!DOCTYPE html>
<html>
<head>
<title>Profile page</title>
</head>
<body>
<?php include('header.php'); ?>
<center>
<?php echo '<table border="1px;">'; ?>
<tr>
<td>
<span>ID</span>
</td>
<td width="400px" style="text-align: center;">
Name
</td>
<td width="80px" style="text-align: center;">
Creator
</td>
<td width="80px" style="text-align: center;">
Date
</td>
<td width="80px" style="text-align: center;">
Edit
</td>
</tr>
</center>
</body>
</html>
<?php
if (#$_GET['id']) {
$check_d = mysql_query("SELECT * FROM users WHERE id ='".$_GET['id']."'");
while ($row_d = mysql_fetch_assoc($check_d)) {
echo "<h1>Post made by: ".$row_d['username']."</h1>";
$check_u = mysql_query("SELECT * FROM topics WHERE topic_creator='".$row_d['username']."'");
while ($row_u = mysql_fetch_assoc($check_u)) {
$id = $row_u['topic_id'];
echo "<tr>";
echo "<td>".$row_u['topic_id']."</td>";
echo "<td><a href='topic.php?id=$id'>".$row_u['topic_name']."<br /></a></td>";
echo "<td>".$row_u['topic_creator']."<br /></td>";
echo "<td>".$row_u['date']."<br /></td>";
echo "<td><a href='edit.php?edit=$id'>Edit</a><br /></td>";
echo "</tr>";
}
}
}
echo "</table>";
if (#$_GET['action'] == "logout") {
session_destroy();
header("Location: login.php");
}
}else {
echo "You must be logged in.";
}
?>
If anyone knows how to solve this I would be most grateful!
Most of the answers I could find online involves user level distribution where the admin and user levels are predetermined. This is not what I would prefer. I simply would like the current user that is logged in to be able to edit their own posts, but not the other user posts.
I hope that this made sense, but if not, just ask!
Thanks beforehand!
// E.
If logged in user shouldn't edit other user's posts, then don't show the edit column, then you can do simple if check for the column Edit like below
while ($row_d = mysql_fetch_assoc($check_d)) {
echo "<h1>Post made by: ".$row_d['username']."</h1>";
$check_u = mysql_query("SELECT * FROM topics WHERE topic_creator='".$row_d['username']."'");
while ($row_u = mysql_fetch_assoc($check_u)) {
$id = $row_u['topic_id'];
echo "<tr>";
echo "<td>".$row_u['topic_id']."</td>";
echo "<td><a href='topic.php?id=$id'>".$row_u['topic_name']."<br /></a></td>";
echo "<td>".$row_u['topic_creator']."<br /></td>";
echo "<td>".$row_u['date']."<br /></td>";
// Add if condition here
if($_SESSION['current_logged_in_user_id'] === $row_u['topic_creator_id']) {
echo "<td><a href='edit.php?edit=$id'>Edit</a><br /></td>";
}
echo "</tr>";
}
}
but don't use mysql_* functions. use mysqli or PDOs for security reasons like protecting yourself from sql injection attacks.
<html>
<head><head>
<title>Home Page</title>
<body>
<style>
.looks
{
border:1px solid black;
}
</style>
<center><h1>Welcome Students!</h1><br><br></center>
<span style="float: right;">
Logout
</span>
<h2>List of Students in system are : </h2>
<div id="list">
<table class='looks'>
<tr><th>Student Name</th>
<th></th><th></th><th></th></tr>
<?php
foreach ($list->result() as $row)
{
echo "<tr>";
echo "<td style='width:30%'>".$row->name."</td>";
echo "<td><input type='submit' value='Add Student' style='float:left'
onclick="site_url().'/user_c/add'"></td>";
echo '<td><input type="submit" value="Update Student"
style="float:left"></td>';
echo '<td><input type="submit" value="Delete Student"
style="float:left"></td>';
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
Parse Error
The foreach loop is executed and the values of student are displayed on the
home_v.php page. Besides the names of these students, I have added a button
(Add Student).On clicking this button I want to open another view page
user_v.php, for which I have used onclick tag in the button. But it is not
working and I get the error attached below. Kindly help as what is the mistake
I am making.
//controller
function add()
{
$this->load->view('user_v');
}
You are making mistake in concatenating PHP and HTML data.
And to make it work on the click do following changes:
echo "<td><input type='submit' value='Add Student' style='float:left'
onclick=window.location='". site_url("user_c/add")."'></td>";
This question already has answers here:
Why does jQuery or a DOM method such as getElementById not find the element?
(6 answers)
Closed 9 years ago.
Hi I click on one of the links given in the save column. Once it is clicked the code between the script tags should be run and give an alert ('BBBBBBBBBBBBBBBBBBBB'). But I can't figure out why it doesn't give the expected result. Please someone help me to correct this
<html>
<title></title>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script></head>
<script>
$(".QuestionEdit").click(function(){
alert('BBBBBBBBBBBBBBBBBBBB');
var B=$(this).attr('id');
var Data=B.replace("QuestionEdit","");
alert(Data);
return false;
});
</script>
</head>
<body>
<?php
echo "<form>";
echo "<div id='QuestionDetails' style=' position:relative; top=50px;'>";
$Query="SELECT * FROM Questions WHERE Form_ID='0'";
echo "<table border='1' id='DisplayFormDetailss'>
<tr style='background-color:#D0A9F5;' height='40px;'>
<th width='100px;'>Question_ID</th>
<th width='420px;'>Question Name</th>
<th width='100px;'>Inactivate</th>
<th width='70px;'>Edit</th>
</tr>";
$i=0;
while($i<5){
echo "<tr height='25px;'>";
echo "<td><input name='QuestionID[]' id='QuestionID ".$i."' align=center value='8'></input></td>";
echo "<td><input name='QuestionName[]' style='width:420px;' id='QuestionName".$i."' align=left value='7'></input></td>";
echo "<td name='QuestionInactive[]' id='QuestionInactive".$i."' align=center><input type='checkbox'></input></td>";
echo "<td class='QuestionEdit' id='QuestionEdit".$i."' align=center><a href='' align=left>Edit</a></td>";
echo "</tr>";
$i++;
}
echo "</table>";
echo "</div>";
echo "<div id='Sub' style='position:relative; top:50px;'>";
echo "<input type='submit' value='Save The Table'></input>";
echo "</div>";
echo "</form>";
?>
</body>
</html>
The div.QuestionEdit is not loaded when the script executes. Wrap the script in $(document).ready() to execute when the DOM is available.
$(document).ready(function(){
$(".QuestionEdit").click(function(){
alert('BBBBBBBBBBBBBBBBBBBB');
var B=$(this).attr('id');
var Data=B.replace("QuestionEdit","");
alert(Data);
return false;
});
});
Solution:
$(document).ready(function() {
$(".QuestionEdit").click(function(){
alert('BBBBBBBBBBBBBBBBBBBB');
var B=$(this).attr('id');
var Data=B.replace("QuestionEdit","");
alert(Data);
return false;
});
});
Your script is running before the document has loaded.
Use the document ready callback to run any jQuery code that needs to access the DOM so it runs when the DOM is loaded.
$( document ).ready(function() {
// Handler for .ready() called.
});
I am very new to JavaScript what is related to it.
I have a set of dynamic rows and corresponding columns to those rows. In one column I have a button. When I click on it, it displays the results of a select query in another page based on the Posted Competence_ID.
The query works fine and I get correct results when I click on the button. However, what I would like to do now, is to display that message in an alert when the button is clicked and stay on the same page rather than opening a new tab..
Here is the relevant HTML code that shows the table I use:
echo "<table border='1' id='mycompstable' class='sortablee' cellpadding='0' cellspacing='0'>";
echo "<tr><th>ID</th><th>Competence Group</th><th>Competence Class</th><th>Competence Description</th><th>Own Evaluation</th><th>Manager's evaluation from last year</th><th>Target levels</th><th>Gap</th><th>Action</th><th class='unsortable'>Action ready target </th></tr>";
foreach($descs as $compi){
echo "<tr>";
echo "<td>".$compi['Competence_ID']."</td>";
echo "<td><p style='text-align: center;'>".$compi['Competence_Group']."</p></td>";
if(isset($compi['Competence_class'])){echo "<td>".$compi['Competence_class']."</td>";}else echo "<td><p style='text-align: center;'>-</p></td>";
echo "<td>".$compi['Competence_Description']."</td>";
echo "<td class='evaluation'>";
echo "<select class='ownlevelselect' id='ownlevelselect-.".$compi['Competence_ID']."' name='level-".$compi['Competence_ID']."' >";
if (isset($compi['ownlevel']) && $compi['ownlevel']!= '' && !empty($compi['ownlevel']) && $compi['ownlevel']!= 0) {
echo "<option selected value='".$compi['ownlevel']."' selected='selected'>".$compi['ownlevel']."</option>";
}
echo "<option value='' >--</option>";
echo "<option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option>";
echo "</select>";
echo $compi['ownlevel'];
echo '<a test="'.$compi['Competence_ID'].'" onClick="showLevels('.$compi['Competence_ID'].');" target="_blank" href="'.INDEX.'?categ='.$_GET['categ'].'&action='.$_GET['action'].'&subaction=viewlevels'.'&levels='.$compi['Competence_ID'].'">';
echo '<img class="linkki" src="'.KUVAT.'paivita.gif" alt="'._("tiedot").'" title="'._("Click to view the description of each level?").'"/></a>';
echo "</td>";
Here is the code to retrieve the data:
function fetchlevels($Competence_id){
$this->query="SELECT * FROM levels WHERE comp_id=".$_REQUEST['levels'];
$tulos=$this->suoritaKysely();
return $tulos;
}
And here is the page that I want to show in the message:
$levels=$this->levels;
$comp=$this->compdesc;
echo "Levels explanation for the competence:".$comp['Competence_Description']."<br>";
echo "Level 1 = ".$levels[0]['lvl1'];
echo "<br>"."level 2 = ".$levels[0]['lvl2'];
echo "<br>"."level 3 = ".$levels[0]['lvl3'];
echo "<br>"."level 4 = ".$levels[0]['lvl4'];
echo "<br>"."level 5 = ".$levels[0]['lvl5'];
echo "<br><br>";
echo '<input type="button" value="close" window onclick="window.close();">';
?>
Any kind of help would be very much appreciated
Here is a Ajax simulation in jsfiddle
http://jsfiddle.net/ncubica/Umxjb/
HTML
<i style='display:none' id="loadingPopup">Loading</i>
<table>
<tr>
<td data-id="td1"> row 1</td>
</tr>
<tr>
<td data-id="td2"> row 2</td>
</tr>
<tr>
<td data-id="td3"> row 3</td>
</tr>
</table>
javascript
$("table").on("click", function(event){
var $target = $(event.target);
if($target.is("td")){
var id = $target.attr("data-id");
makeAjax(id);
}
});
//simulating ajax
function makeAjax(id){
//you will have to use ajax an retrieve you json format
//i will simulate ajax only
$("#loadingPopup").show();
var _json = { id : id, value : "some value", description : "some description"};
setTimeout(function(){response(_json)}, 1000);
}
function response(_json){
$("#loadingPopup").hide();
alert(_json.id + " - " + _json.value);
}
CSS
table{font-family:arial; font-size:12px; width:100%}
table tr td{border-bottom:1px solid #CCC; padding:10px;}
Just an example based on the given info!
echo '<a onClick="showLevels('.$compi['Competence_ID'].');">';
echo '<img class="linkki" src="'.KUVAT.'paivita.gif" alt="'._("tiedot").'" title="'._("Click to view the description of each level?").'"/></a>';
Javascript/jQuery/Ajax
function showLevels(comp_id)
{
$.ajax({
type: "GET",
url: "process_file.php?comp_id="+comp_id,
success: function (result) {
alert(result);
}
});
}
process_file.php
<?php
//Your database Config.
$comp_id=$_REQUEST['comp_id'];
$this->query="SELECT * FROM levels WHERE comp_id=".$comp_id;
$tulos=$this->suoritaKysely();
//Proper Output Actions
$levels=$this->levels;
$comp=$this->compdesc;
echo "Levels explanation for the competence:".$comp['Competence_Description']."<br>";
echo "Level 1 = ".$levels[0]['lvl1'];
echo "<br>"."level 2 = ".$levels[0]['lvl2'];
echo "<br>"."level 3 = ".$levels[0]['lvl3'];
echo "<br>"."level 4 = ".$levels[0]['lvl4'];
echo "<br>"."level 5 = ".$levels[0]['lvl5'];
echo "<br><br>";
?>
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to be able to style this table:
With a dark background, the text returned is unreadable:
<?php
echo "
<table border = '1'>
<tr>
<th>Client ID</th>
</tr>";
echo "<tr>";
echo "<td>" .$clientID. "</td>";
echo "</tr>";
echo "</table>";
}
?>
The PHP is working. But how do I change the color of the text in the table?
Found a solution
I found a simple solution to what was needed. Use the bgcolor = '#fff', this fixed the issue.
<?php
echo "
<table border = '1'>
*bgcolor='#fff'*
<tr>
<th>Client ID</th>
</tr>";
echo "<tr>";
echo "<td>" .$clientID. "</td>";
echo "</tr>";
echo "</table>";
}
?>
Here's a basic rundown of how to implement styles onto your page:
HTML HEAD
<head>
<!-- example css -->
<style type="text/css">
table.mytable {
border: 1px solid #FF0000;
}
table.mytable > thead > tr > th {
font-size: 2em;
}
table.mytable > tbody > tr > td {
color: #999;
}
</style>
<!-- or below: include a css file -->
<link rel="stylesheet" type="text/css" href="/path/to/my/css/file.css">
</head>
Your Table (see my changes to the DOM)
<table class="mytable">
<thead>
<tr>
<th>Client ID</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<!-- notice how I include php without echoing the whole table -->
<?php echo $clientID; ?>
</td>
</tr>
</tbody>
</table>
Learn CSS
Check out this website for a good tutorial and reference to follow for adding css properties to your page.
try using Bootstrap, just download it and put the files in the correct folders, put ths css files in your css folder, the js files in your javascript folder and the same thing with images, finally in your code just add classes like this:
<?php
echo "
<table class='table table-striped' >
<tr>
<th>Client ID</th>
</tr>";
echo "<tr>";
echo "<td>" .$clientID. "</td>";
echo "</tr>";
echo "</table>";
}
?>
take a look here for more information: http://twitter.github.com/bootstrap/base-css.html#tables