I made a page which in html, php and jquery.
My php script will load all data where date is equals with date selected in text input which using JQuery datepicker.
My problem is when I selected a date in datepicker and then the page will load the data, the text input at datepicker being blank (no text or date).
so how to keep the selected date in the text input?
<link rel="stylesheet" href="/resources/demos/style.css">
$(function() {
$("#datepicker").datepicker({dateFormat: 'yy-mm-dd'});
});
$(document).ready(function() {
$('#datepicker').change(function() {
$('#calendar').submit();
});
});
I need some advices to fix this. So thank you for your help. And also I want to apologize if my topic is alike with another.
Thanks for your help.
Here is my code script
<center>
<form id="calendar" action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET">
<div id="datepicker_start"></div>
<input type="hidden" id="datepicker" name="datepicker">
</form>
</center>
<?php
$host = "localhost";
$dbname = "dbname";
$username = "root";
$password = "";
try {
$conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $pe) {
die("Could not connect to the database $dbname :" . $pe->getMessage());
}
if(isset($_GET["datepicker"])){
$datepicker = $_GET["datepicker"];
$datepicker2 = date('d-m-Y', strtotime($datepicker));
}else{
$datepicker = date('Y-m-d');
$datepicker2 = date('d-m-Y', strtotime($datepicker));
}
$stmt = $conn->prepare("my query");
$stmt->bindParam(':date', $datepicker);
$stmt->execute();
$result = $stmt->fetchall();
if (empty($result)) {
echo "<center><h3>.:: Schedule <i>". $datepicker2 ." ::.</i></h1></center>";
echo "<center><h1>.::No Data::.</h1></center>";
}else{
echo "<center><h3>.:: Schedule <i>". $datepicker2 ." ::.</i></h1></center>";
echo
"<table>
<tr>
<th>Data 1</th>
<th>Data 2</th>
<th>Data 3</th>
<th>Data 4</th>
<th>Data 5</th>
<th>Data 6</th>
<th>Data 7</th>
<th>Data 8</th>
<th>Data 9</th>
</tr>"
;
foreach($result as $row)
{
echo "<tr>";
echo "<td>" . $row['data 1'] . "</td>";
echo "<td>" . $row['data 2'] . "</td>";
echo "<td>" . $row['data 3'] . "</td>";
echo "<td>" . $row['data 4'] . "</td>";
echo "<td>" . $row['data 5'] . "</td>";
echo "<td>" . $row['data 6'] . "</td>";
echo "<td>" . $row['data 7'] . "</td>";
echo "<td>" . $row['data 8'] . "</td>";
echo "<td>" . $row['data 9'] . "</td>";
}
echo "</tr>";
echo "</table>";
}
?>
Form Submit reloads The Page.
So you should send the Date from server script on form submit and set it on the input field.
or you can use ajax
Related
I am trying to create a page to allow toggling on and off certain forums in website, created from raw data in an SQL server. However I need each to have an individual ID so I can show/hide them based on user preference. I am not sure how to go about it. Here is my existing code, disregard the connection values, I am hiding them on purpose. thanks.
$db_host = "host";
$db_username = "username";
$db_pass = "pass";
$db_name = "name";
$db = new PDO('mysql:host='.$db_host.';dbname='.$db_name,$db_username,$db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$query = $db->query('SELECT p.name, p.company, o.prodtype AS Type
FROM ownedproducts AS o
JOIN product as p ON p.productID = o.productID
WHERE o.usersID = 2');
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title> User Forum Selection </title>
</head>
<body>
<div>
<input type="text" id="userid">
</div>
<div>
<hr>
<table id=table border = '2'>
<tr id=table-row>
<th id=table-header>Name</th>
<th id=table-header>Company</th>
<th id=table-header>Type</th>
</tr>
<?php
while ($row = $query->fetch())
{
echo "<tr id=table-row >";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
What about using the product id ? That sounds logical here.
Select it :
$query = $db->query('SELECT p.productID, p.name, p.company, o.prodtype AS Type ...
Then use it in your rows :
while ($row = $query->fetch())
{
echo "<tr id='table-row-" . $row['id'] . "' >";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
Always use single and double quote in id as (id=' ', id=" ")
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title> User Forum Selection </title>
</head>
<body>
<div>
<input type="text" id="userid">
</div>
<div>
<hr>
<table id=table border = '2'>
<tr id=table-row>
<th id=table-header>Name</th>
<th id=table-header>Company</th>
<th id=table-header>Type</th>
</tr>
<?php
while ($row = $query->fetch())
{
echo "<tr id=table-row >";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
use it in your rows :
<?php
foreach( $query->fetch() as $rows=> $row)
{
echo "<tr id='table-row-'.$rows >";
echo "<td>" . $row[or</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
?>
I'd probably do it in a foreach and use the key.
foreach( $query->fetch() as $key => $row)
{
echo "<tr id='table-row-'.$key >";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
I am not able to update one column field. Please Suggest me what is the wrong thing in my code
index.php
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db_name = "logistics";
$lastId="";
//create connection
$con = mysqli_connect($host, $user, $pass, $db_name);
$result = mysqli_query($con,"SELECT * FROM notification");
?>
<div class="table-inner-wrapper">
<h5 class="text- blll"> Active Alerts </h5>
<table class="table table-hover table-striped">
<tr class="t_head">
<th>ID </th>
<th>Forklift ID</th>
<th>Timestamp</th>
<th>Duration</th>
<th>Alert Details</th>
<th></th>
<th>Remark</th>
<th></th>
</tr>
<?php
while($row = mysqli_fetch_array($result)){
echo "<form action='' id='remarks' method='post'>";
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['forklift_id'] . "</td>";
echo "<td>" . $row['noti_start'] . "</td>";
echo "<td>" . $row['duration'] . " hr</td>";
echo "<td>" . $row['alert_details'] . "</td>";
echo "<td><i class='email' id='". $row['id'] ."'> <i class='fa fa-inbox fa-2x'> </i> </i> </td>";
echo "<td><textarea class='remarks' id='".$row['id']."'> ".$row['remarks']." </textarea></td>";
echo "<td><input type='button' class='btn btn-info remark' value='submit' id='".$row['id']."'></td>";
echo "</tr>";
echo "</form>";
}
?>
</table>
</div>
<script type="text/javascript">
$(() => {
$(document).ready(function(){
$(".remark").on('click',function(e){
e.preventDefault();
var id = $(this).attr('id');
var remarks = $("textarea.remarks").val();
// alert(remarks);
// alert(id);
$.ajax({
url:'remark.php',
method:'POST',
data: {id: id, remarks: remarks},
success:function(data){
alert(data);
// return data;
}
});
});
});
})
</script>
remark.php
<?php
$conn = new mysqli('localhost', 'root', '', 'logistics');
$remarks = $_POST['remarks'];
echo $remarks;
$id = $_REQUEST['id'];
echo $id;
$sql = "UPDATE notification SET remarks='".$remarks."' WHERE id='".$id."' " ;
if($conn->query($sql)===TRUE){
echo "DATA updated";
}
?>
I am trying to update remarks column value on submit based on row id but it's updating only a first row of column value and if i click on the remaining rows it is not updating the remarks value.
A couple things:
I would change $id = $_REQUEST['id']; to $id = $_POST['id'];
Secondly, your <form> tag is inside your while loop which means you are echoing out a new form on every iteration. All of the forms will have the same id. This will cause you problems and fits the type of behavior that you are describing. Remove the <form> tags from the inside of the loop like so:
echo "<form action='' id='remarks' method='post'>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['forklift_id'] . "</td>";
echo "<td>" . $row['noti_start'] . "</td>";
echo "<td>" . $row['duration'] . " hr</td>";
echo "<td>" . $row['alert_details'] . "</td>";
echo "<td><i class='email' id='". $row['id'] ."'> <i class='fa fa-inbox fa-2x'> </i> </i> </td>";
echo "<td><textarea class='remarks' id='".$row['id']."'> ".$row['remarks']." </textarea></td>";
echo "<td><input type='button' class='btn btn-info remark' value='submit' id='".$row['id']."'></td>";
echo "</tr>";
}
echo "</form>";
This line:
var remarks = $("textarea.remarks").val();
will only give you the value of the first textarea with the class remarks. You need to access the remarks from the textarea associated with the button instead. You do have a problem though that you have multiple elements with the same id, so you need to fix that first. Try changing this code:
echo "<td><i class='email' id='". $row['id'] ."'> <i class='fa fa-inbox fa-2x'> </i> </i> </td>";
echo "<td><textarea class='remarks' id='".$row['id']."'> ".$row['remarks']." </textarea></td>";
to
echo "<td><i class='email' id='e". $row['id'] ."'> <i class='fa fa-inbox fa-2x'> </i> </i> </td>";
echo "<td><textarea class='remarks' id='t".$row['id']."'> ".$row['remarks']." </textarea></td>";
Now your textarea field has a unique id which is still related to $row['id']. So in your event code, you can write:
var remarks = $("#t" + id).val();
to get the value of remarks associated with that button.
I want to remove DB row data from HTML table. I have an HTML table where I have called all the database table values. I want to give a delete order option to the user. I have used a delete button for that. To do this, I am trying to use ajax and jquery with php delete query. But the issue is When I click on delete it just deletes the HTML row data. It should delete that particular id row from DB as well. I need your help. Please let me know what I have done wrong? I am very much new to ajax and jquery.
remove.php
<?php
include "config.php";
$id = $_REQUEST['id'];
// Delete record
$query = "DELETE FROM mi_home_tv WHERE id='$id'";
mysqli_query($link,$query);
echo 1;
jquery+ajax code
<script src='jquery-3.0.0.js' type='text/javascript'></script>
<script type="text/javascript">
$(document).ready(function(){
// Delete
$('.delete').click(function(){
var el = this;
var id = this.id;
var splitid = id.split("_");
// Delete id
var deleteid = splitid[1];
// AJAX Request
$.ajax({
url: 'remove.php',
type: 'POST',
data: { id:deleteid },
success: function(response){
// Removing row from HTML Table
$(el).closest('tr').css('background','tomato');
$(el).closest('tr').fadeOut(800, function(){
$(this).remove();
});
}
});
});
});
</script>
Button Code:
echo "<td> <span id='del_<?php echo $id; ?>' type='submit' class=' delete btn c-theme-btn c-btn-uppercase btn-xs c-btn-square c-font-sm'>Delete</span> </td>";
php code:
<form method="post" action="remove.php">
<?php
echo " <thead>
<tr>
<th>Order ID</th>
<th>Date</th>
<th>Name</th>
<th>Store Name</th>
<th>Zip</th>
<th>City</th>
<th>Address</th>
<th>Contact</th>
<th>Tv Varient</th>
<th>Total</th>
<th>Delivery</th>
<th>Action</th>
</tr>
</thead>
<tbody>";
while($row = mysqli_fetch_array($result))
{
$id = $row['id'];
echo"<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['rdate'] . "</td>";
echo "<td>" . $row['rname'] . "</td>";
echo "<td>" . $row['rstore'] . "</td>";
echo " <td>" . $row['rzip'] . "</td>";
echo "<td>" . $row['rcity'] . "</td>";
echo "<td>" . $row['raddress'] . "</td>";
echo "<td>" . $row['rphone'] . "</td>";
echo "<td>" . $row['rtv_varient'] . "</td>";
echo"<td>" . $row['ramount'] . "</td>";
echo"<td>" . $row['rdelivery'] . "</td>";
echo "<td> <input type='submit' value='delete' id='del_<?php echo $id; ?>' type='submit' class=' delete btn c-theme-btn c-btn-uppercase btn-xs c-btn-square c-font-sm'>Delete</button> </td>";
echo"</tr>";
}
?>
</form>
You should have a form which will have an input as follows:
<form method="post" action="remove.php">
<input type="submit" value="Delete" name="id" />
</form>
I am making a Leave Management System using PhP-Mysql.
I have a table which takes input from user while applying for their leaves.
(name, leavetype, fromdate, todate, supervisor, reason and status). Only the status column has a predefined value 'pending'.
Now I want to introduce two buttons (Accept/Reject) on each row. Which on click will change the value for Status field.
I am not sure how to do it, I have tried updating the table column but it updates only if there is a where Condition, which will not be the correct procedure for such case.
<div id="content">
<?php
$connect = new mysqli("127.0.0.1","root","","leavedb");
$sql = "SELECT
name,
leavetype,
fromdate,
todate,
supervisor,
reason,
DATEDIFF(todate,fromdate) as Days,
status as Status
FROM leavereq";
$result = $connect->query($sql);
?>
<table id="myTable">
<tr>
<th>Name</th>
<th>Leave Type</th>
<th>From Date</th>
<th>To Date</th>
<th>Supervisor</th>
<th>Reason</th>
<th>No. of Days</th>
<th>Status</th>
</tr>
<?php
while ($report=$result->fetch_assoc())
{
echo "<tr>";
echo "<td>".$report['name']."</td>";
echo "<td>".$report['leavetype']."</td>";
echo "<td>".$report['fromdate']."</td>";
echo "<td>".$report['todate']."</td>";
echo "<td>".$report['supervisor']."</td>";
echo "<td>".$report['reason']."</td>";
echo "<td>".$report['Days']."</td>";
echo "<td>".$report['Status']."</td>";
echo "<td>" . '<input type="submit" name="approve" value="Approve">' . "</td>";
echo "<td>" . '<input type="submit" name="reject" value="Reject">' . "</td>";
}
?>
</table>
</div>
//In the html : You have to add unique id for every <td> of status & also wants to change the input type of approve & reject...also require javascript
// check below
<script>
function function_name(status_id,req)
{
var status;
status='status'+status_id;
if(req=='approve')
{
document.getElementById(status).innerHTML='approve';
//pass ajax call to update entry in db
}
else if(req=='reject')
{
document.getElementById(status).innerHTML='reject';
//pass ajax call to update entry in db
}
</script>
<table id="myTable">
<tr>
<th>Name</th>
<th>Leave Type</th>
<th>From Date</th>
<th>To Date</th>
<th>Supervisor</th>
<th>Reason</th>
<th>No. of Days</th>
<th>Status</th>
</tr>
<?php
$i=0;
while ($report=$result->fetch_assoc())
{
echo "<tr>";
echo "<td>".$report['name']."</td>";
echo "<td>".$report['leavetype']."</td>";
echo "<td>".$report['fromdate']."</td>";
echo "<td>".$report['todate']."</td>";
echo "<td>".$report['supervisor']."</td>";
echo "<td>".$report['reason']."</td>";
echo "<td>".$report['Days']."</td>";
echo "<td id='status$i'>pending</td>";
echo "<td>" . '<button type="button" name="approve"'.$i.' onClick="return function_name($i,approve);">Approve</button>' . "</td>";
echo "<td>" . '<button type="button" name="reject"'.$i.' onClick="return function_name($i,reject);">Reject</button>' . "</td>";
$i++;
}
?>
</table>
EDIT:
Ok I found why it was not working. Jquery was ok but instead of value I took text, so instead .val just .text
So I have a little problem here.
I have a task to export outlook contact file and import it to a database, then display it in html table.
So I did that already and it was not that hard, but here is the next task:
I have my table, with a lot of rows and cells. My first cell is "First Name". When the user clicks on any of the "First Name" to open new window and create input textarea with the value of that cell.
So for example when I click on the name "Georgi" new window should popup with new textarea with the name "Georgi". When I click on "Tomas" new window should popup with new textarea with the name "Tomas". So this textarea should be universal for all names.
I mean I did it for only one name, but do not know how to do it for all names.
I hope you understood me what I want. Here is a picture of the table:
code:
<table id = "firstname" border="2" cellpadding="1" cellspacing="1" width="10000" >
<tr>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Suffix</th>
<th>Company</th>
<th>Department</th>
<th>Job Title</th>
<th>Business Street</th>
<th>Business Street 2</th>
<th>Business Street 3</th>
<th>Business City</th>
<th>Business State</th>
<th>Business Postal Code</th>
<th>Business Country/Region</th>
<th>Home Street</th>
<th>Home Street 2</th>
<th>Home Street 3</th>
<th>Home City</th>
<th>Home State</th>
<th>Home Postal Code</th>
<th>Home Country Region</th>
<th>Other Street</th>
<th>Other Street 2</th>
<th>Other Street 3</th>
<th>Other City</th>
<th>Other State</th>
<th>Other Postal Code</th>
<th>Other Country/Region</th>
<th>Assistant's Phone</th>
<th>Business Fax</th>
<th>Business Phone</th>
<th>Business Phone 2</th>
<th>Callback</th>
<th>Car Phone</th>
<th>Company Main Phone</th>
<th>Home Fax</th>
<th>Home Phone</th>
<th>Home Phone 2</th>
<th>ISDN</th>
<th>Mobile Phone</th>
<th>Other Fax</th>
<th>Other Phone</th>
<th>Pager</th>
<th>Primary Phone</th>
<th>Radio Phone</th>
<th>TTY/TDD PHone</th>
<th>Telex</th>
<th>Account</th>
<th>Anniversary</th>
<th>Assistant's Name</th>
<th>Billing Information</th>
<th>Birthday</th>
<th>Business Address PO Box</th>
<th>Categories</th>
<th>Children</th>
<th>Directory Server</th>
<th>Email Address</th>
<th>Email Type</th>
<th>Email Display Name</th>
<th>Email Address 2</th>
<th>Email Type 2</th>
<th>Email Display Name 2</th>
<th>Email Address 3</th>
<th>Email Type 3</th>
<th>Email Display Name 3</th>
<th>Gender</th>
<th>Government ID Number</th>
<th>Hobby</th>
<th>Home Address PO Box</th>
<th>Initials</th>
<th>Internet Free/Busy</th>
<th>Keywords</th>
<th>Language</th>
<th>Location</th>
<th>Manager's Name</th>
<th>Mileage</th>
<th>Notes</th>
<th>Office Location</th>
<th>Organizational ID Number</th>
<th>Other Address PO Box</th>
<th>Priority</th>
<th>Private</th>
<th>Profession</th>
<th>Referred By</th>
<th>Sensitivity</th>
</tr>
<tr class='table_row'>
<?php
mysqli_select_db($con,'outlook');
$sql = "SELECT * FROM contacts";
$myData = mysqli_query($con,$sql);
while($record = mysqli_fetch_array($myData))
{
echo "<tr>";
echo "<td id=\"fname\">" . "<a class='why' href='#' onClick='myFunction()'>" . $record['first_name'] . "</a>" . "</td>";
echo '<script type="text/javascript">';
echo 'function myFunction(){';
echo 'var myWindow = window.open("", "", "width=1024, height=555, left=450, top=100");';
echo 'myWindow.document.write(';
echo '"';
echo '<html>';
echo '<head>';
echo '<script src=\"http://code.jquery.com/jquery-1.9.1.js\"><\/script>';
echo '<script type=\"text/javascript\">';
echo '<\/script>';
echo '</head>';
echo '<body>';
echo '<div id=\"showcase\" style=\"background-color: #F5FFE0; margin-right: 25%; margin-left: 30%; padding-left:3%; padding-right:2%; border:solid 5px #242222;\">';
echo '<p style=\"background-color:#7A993D;\">Personal</p>';
echo '<select>';
echo '<option selected >Full Name</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['first_name']).'\" style=\"margin-left: 25.3%;\"><br>';
echo '<select>';
echo '<option selected>Company</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['company']).'\" style=\"margin-left: 26.3%;\"><br>';
echo '<select>';
echo '<option selected>Job Title</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['job_title']).'\" style=\"margin-left: 28%;\"><br><br>';
echo '<p style=\"background-color:#7A993D;\">Internet</p>';
echo '<select>';
echo '<option>E-Mail</option>';
echo '<option>E-Mail 2</option>';
echo '<option>E-Mail 3</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['email_address']).'\" style=\"margin-left: 28%;\"><br>';
echo '<select>';
echo '<option selected>Web page address</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['internet_free_busy']).'\" style=\"margin-left: 12.5%;\"><br>';
echo '<p style=\"background-color:#7A993D;\">Phone numbers</p>';
echo '<select>';
echo '<option>Assistant</option>';
echo '<option selected>Business</option>';
echo '<option>Business 2</option>';
echo '<option>Business Fax</option>';
echo '<option>Callback</option>';
echo '<option>Car</option>';
echo '<option>Company</option>';
echo '<option>Home</option>';
echo '<option>Home 2</option>';
echo '<option>Home Fax</option>';
echo '<option>ISDN</option>';
echo '<option>Mobile</option>';
echo '<option>Other</option>';
echo '<option>Other Fax</option>';
echo '<option>Pager</option>';
echo '<option>Primary</option>';
echo '<option>Radio</option>';
echo '<option>Telex</option>';
echo '<option>TTY/TDD</option>';
echo '</select>';
echo '<script>';
echo 'var myColor = document.getElementById(\"fname\").value;';
echo '<\/script>';
echo '<input type=\"text\" value=myColor style=\"margin-left: 20%;\"><br>';
echo '<select>';
echo '<option>Assistant</option>';
echo '<option selected>Business</option>';
echo '<option>Business 2</option>';
echo '<option>Business Fax</option>';
echo '<option>Callback</option>';
echo '<option>Car</option>';
echo '<option>Company</option>';
echo '<option>Home</option>';
echo '<option>Home 2</option>';
echo '<option>Home Fax</option>';
echo '<option>ISDN</option>';
echo '<option>Mobile</option>';
echo '<option>Other</option>';
echo '<option>Other Fax</option>';
echo '<option>Pager</option>';
echo '<option>Primary</option>';
echo '<option>Radio</option>';
echo '<option>Telex</option>';
echo '<option>TTY/TDD</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['business_phone']).'\" style=\"margin-left: 20%;\"><br>';
echo '<select>';
echo '<option>Assistant</option>';
echo '<option>Business</option>';
echo '<option>Business 2</option>';
echo '<option selected>Business Fax</option>';
echo '<option>Callback</option>';
echo '<option>Car</option>';
echo '<option>Company</option>';
echo '<option>Home</option>';
echo '<option>Home 2</option>';
echo '<option>Home Fax</option>';
echo '<option>ISDN</option>';
echo '<option>Mobile</option>';
echo '<option>Other</option>';
echo '<option>Other Fax</option>';
echo '<option>Pager</option>';
echo '<option>Primary</option>';
echo '<option>Radio</option>';
echo '<option>Telex</option>';
echo '<option>TTY/TDD</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['business_fax']).'\" style=\"margin-left: 20%;\"><br>';
echo '<select>';
echo '<option>Assistant</option>';
echo '<option>Business</option>';
echo '<option>Business 2</option>';
echo '<option>Business Fax</option>';
echo '<option>Callback</option>';
echo '<option>Car</option>';
echo '<option>Company</option>';
echo '<option>Home</option>';
echo '<option>Home 2</option>';
echo '<option>Home Fax</option>';
echo '<option>ISDN</option>';
echo '<option selected>Mobile</option>';
echo '<option>Other</option>';
echo '<option>Other Fax</option>';
echo '<option>Pager</option>';
echo '<option>Primary</option>';
echo '<option>Radio</option>';
echo '<option>Telex</option>';
echo '<option>TTY/TDD</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['mobile_phone']).'\" style=\"margin-left: 20%;\"><br>';
echo '<p style=\"background-color:#7A993D;\">Addresses</p>';
echo '<select>';
echo '<option selected>Business</option>';
echo '<option >Home</option>';
echo '<option >Other</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['business_street']).'\" style=\"margin-left: 26.5%;\"><br><br>';
echo '<\/div>';
echo '</body></html>';
echo '"';
echo ');';
echo '}';
echo '</script>';
echo "<td>" . $record['middle_name'] . "</td>";
echo "<td>" . $record['last_name'] . "</td>";
echo "<td>" . $record['suffix'] . "</td>";
echo "<td>" . $record['company'] . "</td>";
echo "<td>" . $record['department'] . "</td>";
echo "<td>" . $record['job_title'] . "</td>";
echo "<td>" . $record['business_street'] . "</td>";
echo "<td>" . $record['business_street2'] . "</td>";
echo "<td>" . $record['business_street3'] . "</td>";
echo "<td>" . $record['business_city'] . "</td>";
echo "<td>" . $record['business_state'] . "</td>";
echo "<td>" . $record['business_postal_code'] . "</td>";
echo "<td>" . $record['business_country_region'] . "</td>";
echo "<td>" . $record['home_street'] . "</td>";
echo "<td>" . $record['home_street2'] . "</td>";
echo "<td>" . $record['home_street3'] . "</td>";
echo "<td>" . $record['home_city'] . "</td>";
echo "<td>" . $record['home_state'] . "</td>";
echo "<td>" . $record['home_postal_code'] . "</td>";
echo "<td>" . $record['home_country_region'] . "</td>";
echo "<td>" . $record['other_street'] . "</td>";
echo "<td>" . $record['other_street2'] . "</td>";
echo "<td>" . $record['other_street3'] . "</td>";
echo "<td>" . $record['other_city'] . "</td>";
echo "<td>" . $record['other_state'] . "</td>";
echo "<td>" . $record['other_postal_code'] . "</td>";
echo "<td>" . $record['other_country_region'] . "</td>";
echo "<td>" . $record['assistants_phone'] . "</td>";
echo "<td>" . $record['business_fax'] . "</td>";
echo "<td>" . $record['business_phone'] . "</td>";
echo "<td>" . $record['business_phone2'] . "</td>";
echo "<td>" . $record['callback'] . "</td>";
echo "<td>" . $record['car_phone'] . "</td>";
echo "<td>" . $record['company_main_phone'] . "</td>";
echo "<td>" . $record['home_fax'] . "</td>";
echo "<td>" . $record['home_phone'] . "</td>";
echo "<td>" . $record['home_phone2'] . "</td>";
echo "<td>" . $record['isdn'] . "</td>";
echo "<td>" . $record['mobile_phone'] . "</td>";
echo "<td>" . $record['other_fax'] . "</td>";
echo "<td>" . $record['other_phone'] . "</td>";
echo "<td>" . $record['pager'] . "</td>";
echo "<td>" . $record['primary_phone'] . "</td>";
echo "<td>" . $record['radio_phone'] . "</td>";
echo "<td>" . $record['tty_tdd_phone'] . "</td>";
echo "<td>" . $record['telex'] . "</td>";
echo "<td>" . $record['account'] . "</td>";
echo "<td>" . $record['anniversary'] . "</td>";
echo "<td>" . $record['assistants_name'] . "</td>";
echo "<td>" . $record['billing_information'] . "</td>";
echo "<td>" . $record['birthday'] . "</td>";
echo "<td>" . $record['business_address_po_box'] . "</td>";
echo "<td>" . $record['categories'] . "</td>";
echo "<td>" . $record['children'] . "</td>";
echo "<td>" . $record['directory_server'] . "</td>";
echo "<td>" . $record['email_address'] . "</td>";
echo "<td>" . $record['email_type'] . "</td>";
echo "<td>" . $record['email_display_name'] . "</td>";
echo "<td>" . $record['email_address2'] . "</td>";
echo "<td>" . $record['email_type2'] . "</td>";
echo "<td>" . $record['email_display_name2'] . "</td>";
echo "<td>" . $record['email_address3'] . "</td>";
echo "<td>" . $record['email_type3'] . "</td>";
echo "<td>" . $record['email_display_name3'] . "</td>";
echo "<td>" . $record['gender'] . "</td>";
echo "<td>" . $record['government_id_number'] . "</td>";
echo "<td>" . $record['hobby'] . "</td>";
echo "<td>" . $record['home_address_po_box'] . "</td>";
echo "<td>" . $record['initials'] . "</td>";
echo "<td>" . $record['internet_free_busy'] . "</td>";
echo "<td>" . $record['keywords'] . "</td>";
echo "<td>" . $record['language'] . "</td>";
echo "<td>" . $record['location'] . "</td>";
echo "<td>" . $record['managers_name'] . "</td>";
echo "<td>" . $record['mileage'] . "</td>";
echo "<td>" . $record['notes'] . "</td>";
echo "<td>" . $record['office_location'] . "</td>";
echo "<td>" . $record['organizational_id_number'] . "</td>";
echo "<td>" . $record['other_address_po_box'] . "</td>";
echo "<td>" . $record['priority'] . "</td>";
echo "<td>" . $record['private'] . "</td>";
echo "<td>" . $record['profession'] . "</td>";
echo "<td>" . $record['referred_by'] . "</td>";
echo "<td>" . $record['sensitivity'] . "</td>";
}
?>
</tr>
You could add an id to the desired td just like
echo "<td id='helper'>" . $record['middle_name'] . "</td>";
And then use jquery
$('#helper').click(function(){
var x=window.open();
x.document.open();
x.document.write('<textarea>'+$(this).val()+'</textarea>');
x.document.close();
});
Hope it worlks!
You can try this:( the window.open(...); function) link : w3schools the simple call just opens a window with the specified url, but there is also a custom call, that enables you to specify the content
ie:
var myWindow = window.open("", "MsgWindow", "width=200, height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");
example taken from the above page. I guess in your situation you just have to replace the <p>..</p> with some generated tags (which if I read correctly you already do)