How to pass DATA to PopUp Div in PHP? - javascript

I want to the pass ID value to POPUP DIV and update into table with status , suggest_text area with ID.
if I pass like this href="#pop1?id=<?php echo $row['id']; ?> The POPUP div is Not opening. so I dont know how to pass,so some one tell me that how can I pass in PHP or else in Javascript
Thanks in advance
<div class="widget-content">
<table class="table table-bordered table-striped data-table">
<thead>
<tr>
<th>S.No</th>
<th>Employee Name</th>
<th>Reason</th>
<th>Category</th>
<th>From</th>
<th>To</th>
<th>No Of Days</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$result=mysql_query("select * from leave_request");
while($row=mysql_fetch_array($result))
{?>
<tr>
<td><?php echo $row['id'];?></td>
<td> <?php echo $row['emp_name'];?></td>
<td> <?php echo $row['reason'];?></td>
<td> <?php echo $row['category'];?></td>
<td><?php echo $row['from_date'];?></td>
<td><?php echo $row['to_date'];?></td>
<td><?php echo $row['no_of_days'];?></td>
<td>
Accept |
Reject |
Suggest </td>
<div id="pop1" class="pop-up">
<?php $suggest_id = $_GET['id']; ?>
<div class="popBox">
<div class="popScroll">
<form>
<textarea name="suggest" id="suggest" cols="60" rows="8" ></textarea>
<input type="text" name="id" value="<?php echo $suggest_id; ?>">
<input type="text" name="status" value="3">
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
<!-- popup content end here -->
</div>
<span>Back to links</span>
</div>
Back to links
</div>
</tr>
<?php }?>
</tbody>
</table>
</div>

As I see your popup div is in WHILE loop so you can get your id like this :-
Initialize a value say K = 1; and put this value to every popup
Suggest
Full Code :-
<?php
$result=mysql_query("select * from leave_request");
while($row=mysql_fetch_array($result))
{
$k =1;
?>
<tr>
<td><?php echo $row['id'];?></td>
<td> <?php echo $row['emp_name'];?></td>
<td> <?php echo $row['reason'];?></td>
<td> <?php echo $row['category'];?></td>
<td><?php echo $row['from_date'];?></td>
<td><?php echo $row['to_date'];?></td>
<td><?php echo $row['no_of_days'];?></td>
<td>
Accept |
Reject |
Suggest </td>
<div id="pop<?php echo $k; ?>" class="pop-up">
<div class="popBox">
<div class="popScroll">
<form>
<textarea name="suggest" id="suggest" cols="60" rows="8" ></textarea>
<input type="text" name="id" value="<?php echo $row['id']">
<input type="text" name="status" value="3">
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</form>
<!-- popup content end here -->
</div>
<span>Back to links</span>
</div>
Back to links
</div>
</tr>
<?php
$k++;
}?>

Related

Pass PHP variable with button to popup via javascript?

I have a table created dynamically with PHP to display requests. In each row of my table there is a button to open a popup. The ID of each request should be transferred to this popup in order to read out all data.
How can I make it so that in a dynamic table (all button names are the same) each button is differentiated, or recognized which button I pressed? And how can I pass the variable from PHP to the popup via javascript?
I would appreciate any help, I've been trying for days now, but I'm not getting any results.
Here's the table view
Popup window
<table id="meineTabelle" data-role="table" class="content"
data-mode="columntoggle" data-column-btn-text="Spalten">
<thead>
<div class="tablehead">
<tr>
<th class="thblackborder" data-priority=""></th>
<th class="thblackborder" data-priority="">1.Projektant</th>
<th class="thblackborder" data-priority=""></th>
<th class="thblackborder" data-priority="">2.Projektant</th>
<th class="thblackborder" data-priority=""></th>
<th class="thblackborder" data-priority="">3.Projektant</th>
<th class="thblackborder" data-priority=""></th>
<th class="thblackborder" data-priority="">4.Projektant</th>
<th class="thblackborder" data-priority=""></th>
<tr>
<th class="">ID</th>
<th class="">Vorname</th>
<th class="">Nachname</th>
<th class="">Vorname</th>
<th class="">Nachname</th>
<th class="">Vorname</th>
<th class="">Nachname</th>
<th class="">Vorname</th>
<th class="">Nachname</th>
<th class="">Titel</th>
<th class="">Standort</th>
<th class="">Klasse</th>
<th class="">Beginn</th>
<th class="">Abgabe</th>
<th class="">Beschreibung</th>
<th class="">Status</th>
<th class="">Erstellt</th>
</tr>
</tr>
</div>
</thead>
<tbody>
<?php
foreach ($Ausgabe as $row) {
?>
<form>
<tr onclick="dialogOeffnen('loslegen-dialog')">
<td>
<?php echo $row["ID"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Vorname"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Nachname"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Vorname2"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Nachname2"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Vorname3"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Nachname3"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Vorname4"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Nachname4"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Titel"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Standort"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Klasse"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Beginn"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Abgabe"] . "<br>"; ?>
</td>
<td>
<center>Link</center>
</td>
<td>
<?php echo $row["Genehmigt"] . "<br>"; ?>
</td>
<td>
<?php echo $row["Erstellt"] . "<br>"; ?>
</td>
<td>
<input type="button" value="" onclick="">
</td>
</tr>
</form>
<?php
}
?>
</tbody>
</table>
Popup HTML
<div id="body-overlay"></div>
<div class="dialog" id="loslegen-dialog">
<a href="#" role="button" class="dialog-schließen-button" onclick="dialogSchliessen('loslegen-dialog')">
<i class="fas fa-times"></i>
</a>
<div class="textarea">
<h1><?php echo $row['ID'] ?></h1>
<textarea placeholder="Platz für Bemerkungen" name="Bemerkungen" id="" cols="30" rows="10"></textarea>
</div>
<form classaction="">
<div class="txt_field">
<input type="text" name="email" value="<?= $fetch_profile['email'];?>" required>
<span></span>
<label>E-Mail</label>
</div>
<div class="txt_field">
<input type="text" name="password" required>
<span></span>
<label>Passwort</label>
</div>
<input type="submit" value="Bestätigen" name="submit">
<div class="signup_link">
</form>
</div>
<script src="dialoge.js">
</script>
<script>
</script>
</body>
</html>
</body>
</html>
dialoge.js
function dialogOeffnen(dialogId) {
document.getElementById(dialogId).classList.add("sichtbar");
document.getElementById("body-overlay").classList.add("sichtbar");
}
function dialogSchliessen(dialogId) {
document.getElementById(dialogId).classList.remove("sichtbar");
document.getElementById("body-overlay").classList.remove("sichtbar");
}
If I echo out $row["ID"] for sure it shows me the last ID in my table
First, let's clean up your HTML a bit. Tables have predetermined structures. That means that a only some elements can be used as a parent or child. For example, you can't nest a <tr> inside a another <tr>. Learn about the basics of tables.
<table id="meineTabelle" data-role="table" class="content" data-mode="columntoggle" data-column-btn-text="Spalten">
<thead>
<tr>
<th>ID</th>
<th>Vorname</th>
<th>Nachname</th>
<th>Vorname</th>
<th>Nachname</th>
<th>Vorname</th>
<th>Nachname</th>
<th>Vorname</th>
<th>Nachname</th>
<th>Titel</th>
<th>Standort</th>
<th>Klasse</th>
<th>Beginn</th>
<th>Abgabe</th>
<th>Beschreibung</th>
<th>Status</th>
<th>Erstellt</th>
</tr>
</thead>
<tbody>
<?php foreach ($Ausgabe as $row) : ?>
<tr>
<td><?= $row["ID"] ?></td>
<td><?= $row["Vorname"] ?></td>
<td><?= $row["Nachname"] ?></td>
<td><?= $row["Vorname2"] ?></td>
<td><?= $row["Nachname2"] ?></td>
<td><?= $row["Vorname3"] ?></td>
<td><?= $row["Nachname3"] ?></td>
<td><?= $row["Vorname4"] ?></td>
<td><?= $row["Nachname4"] ?></td>
<td><?= $row["Titel"] ?></td>
<td><?= $row["Standort"] ?></td>
<td><?= $row["Klasse"] ?></td>
<td><?= $row["Beginn"] ?></td>
<td><?= $row["Abgabe"] ?></td>
<td>Link</td>
<td><?= $row["Genehmigt"] ?></td>
<td><?= $row["Erstellt"] ?></td>
<td>
<button class="dialog-open" type="button" value="<?= $row["ID"] ?>">Button</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
I've changed your button to a <button> element because it's a bit more flexible to use. Output the ID of the row in the value attribute. Give the button a class value to identify it with. We'll need this for JS.
Select the table in JavaScript. Listen for click events that happen within the table. The code below checks if the clicked element (event.target) is a button with the class we gave it. If it is, then we'll read the value from button and pass it to the open modal function.
const table = document.querySelector('#meinTabelle');
table.addEventListener('click', event => {
if (event.target.matches('.dialog-open') {
const dialogId = event.target.value;
dialogOeffnen(dialogId);
}
});
function dialogOeffnen(dialogId) {
document.getElementById(dialogId).classList.add("sichtbar");
document.getElementById("body-overlay").classList.add("sichtbar");
}

How to store the input value to php variable

<input type="text" id="transaction_id_input" name="transaction_name">
Above is the value that I want to store in PHP variables so I can compare it in the MySQL data to display specific data. I try storing the input value also to a javascript document.getElementByID("sampleID").value then store it in a variable but it didn't also work, hoping you will help me solve this problem.
<form method="GET" id="reg" name="valid" action="<?php echo htmlspecialchars(
$_SERVER["PHP_SELF"]
); ?>">
<input type="text" id="transaction_id_input" name="transaction_name">
<div class="wrapper" >
<div class="search-input">
<a href="" target="_blank" hidden></a>
<input type="text" id="searchmodal" placeholder="Type to search..">
<div class="icon"><i class="fas fa-search"></i></div>
</div>
</div>
<br><br>
<div class="card-header" id="cardheader2">
List of Medicine Transaction
</div><br><br>
<div class="enrollbutton2">
<a class="nav-link" id="transactioninfo_to_addtransan_class" data-toggle="modal" data-target="#myModal_transaction">Add Transaction
<span>
<lord-icon
src="https://cdn.lordicon.com/mecwbjnp.json"
trigger="loop"
colors="primary:#ffffff,secondary:#ffffff"
stroke="70"
style="width:30px;height:30px">
</lord-icon>
</span>
</a>
</div>
<div class="tableholdermodal" id="transactiontable">
<br><br><br><br>
<table>
<thead>
<tr>
<th scope="col">Transaction No.</th>
<th scope="col">Medicine Code</th>
<th scope="col">Supply</th>
<th scope="col">Lot No.</th>
<th scope="col">Expiration Date</th>
<th scope="col">Inputed Date</th>
</tr>
</thead>
<tbody id="myModalTable">
<?php
include "pdo_connection2.php";
$stm3 = $conn->query(
"SELECT * FROM tbl_transaction WHERE transaction_medicinecode = '' "
);
$rows = $stm3->fetchAll(PDO::FETCH_ASSOC);
if (count($rows) > 0) {
foreach ($rows as $row) { ?>
<tr>
<td data-label='Transaction ID' value="<?php echo $row[
"transaction_id"
]; ?>"><?php echo $row["transaction_id"]; ?></td>
<td data-label='Medicine Code' value="<?php echo $row[
"transaction_medicinecode"
]; ?>"><?php echo $row["transaction_medicinecode"]; ?></td>
<td data-label='Supply' value="<?php echo $row[
"transaction_supply"
]; ?>"><?php echo $row["transaction_supply"]; ?></td>
<td data-label='Lot No.' value="<?php echo $row[
"transaction_lotnum"
]; ?>"><?php echo $row["transaction_lotnum"]; ?></td>
<td data-label='Expiration Date' value="<?php echo $row[
"transaction_expdate"
]; ?>"><?php echo $row["transaction_expdate"]; ?></td>
<td data-label='Date Registered' value="<?php echo $row[
"transaction_date"
]; ?>"><?php echo $row["transaction_date"]; ?></td>
<td data-label='Action'>
<button type="button" class="transaction_update_class" name="transaction_update_name" data-toggle="modal" data-target="#myModalupdate_transactopn" value="<?php echo $row[
"transaction_id"
]; ?>">
<lord-icon
src="https://cdn.lordicon.com/wloilxuq.json"
trigger="loop"
colors="primary:#fb0054,secondary:#f55b2a "
stroke="70"
style="width:55px;height:55px">
</lord-icon>
</button>
<button type="button" class="transaction_delete_class" name="transaction_delete_name" data-toggle="modal" data-target="#myModaldelete_transaction" value="<?php echo $row[
"transaction_id"
]; ?>">
<lord-icon
src="https://cdn.lordicon.com/gsqxdxog.json"
trigger="loop"
colors="primary:#fb0054,secondary:#f55b2a "
stroke="70"
style="width:55px;height:55px">
</lord-icon>
</button>
</td>
</tr>
<?php }
} else {
?>
<tr><td><h4 id="h4nodatafound">------ NO DATA FOUND ------</h4></td></tr>
<?php
}
?>
</tbody>
</table>
</div>
</form>

highlight column differences

I need to Highlight columns that have different values.
If the value on $b['nama'] and $c['nama'] is not the same i need to highlight the <tr>. I wanted the system admin to easily see which of the field is having different values so the admin can decide to approve user edit request or to reject the request.
<?php
error_reporting(0);
$b = $data->row_array();
$c = $data2->row_array();
?>
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">User requested changes</h6>
</div>
<div class="card-body">
<table id="tabel" class="table table-bordered table-striped" style="width: 75%">
<thead>
<tr>
<th>Variable</th>
<th>Current data</th>
<th>Requested changes</th>
</tr>
</thead>
<tbody>
<tr>
<td>Nama</td>
<td>
<?php echo $b['nama']; ?>
</td>
<td>
<?php echo $c['nama']; ?>
</td>
</tr>
<tr>
<td>NIP Baru</td>
<td>
<?php echo $b['nipBaru']; ?>
</td>
<td>
<?php echo $c['nipBaru']; ?>
</td>
</tr>
<tr>
<td>NIP lama</td>
<td>
<?php echo $b['nipLama']; ?>
</td>
<td>
<?php echo $c['nipLama']; ?>
</td>
</tr>
<tr>
<td>Gelar depan</td>
<td>
<?php echo $b['gelarDepan']; ?>
</td>
<td>
<?php echo $c['gelarDepan']; ?>
</td>
</tr>
<tr>
<td>Gelar belakang</td>
<td>
<?php echo $b['gelarBelakang']; ?>
</td>
<td>
<?php echo $c['gelarBelakang']; ?>
</td>
</tr>
<tr>
<td>Tempat lahir</td>
<td>
<?php echo $b['tempatLahir']; ?>
</td>
<td>
<?php echo $c['tempatLahir']; ?>
</td>
</tr>
</tbody>
</table>
<button type="submit" class="btn btn-primary btn-sm" style="width:10%"><span class="icon-cursor"></span> Approve</button>
<button type="submit" class="btn btn-primary btn-sm" style="width:10%"><span class="icon-cursor"></span> Reject</button>
</div>
</div>
</div>
Check if those two values are different and apply a class to the row
<tr<?php if ($b['nama'] != $c['nama']) { echo ' class="highlight"'; } ?>>
<td>Nama</td>
<td>
<?php echo $b['nama']; ?>
</td>
<td>
<?php echo $c['nama']; ?>
</td>
</tr>
then use CSS to highlight the cells
.highlight td {
background: yellowgreen;
}
try this code
you can change the bgcolor value or you can create css class and inside of if you echo the class='my_class'
<?php
error_reporting(0);
$b = $data->row_array();
$c = $data2->row_array();
?>
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">User requested changes</h6>
</div>
<div class="card-body">
<table id="tabel" class="table table-bordered table-striped" style="width: 75%">
<thead>
<tr>
<th>Variable</th>
<th>Current data</th>
<th>Requested changes</th>
</tr>
</thead>
<tbody>
<tr <?php if ($b['nama'] != $c['nama']){echo "bgcolor='#FF0000'";} ?>>
<td>Nama</td>
<td>
<?php echo $b['nama']; ?>
</td>
<td>
<?php echo $c['nama']; ?>
</td>
</tr>
<tr <?php if ($b['nipBaru'] != $c['nipBaru']){echo "bgcolor='#FF0000'";} ?> >
<td>NIP Baru</td>
<td>
<?php echo $b['nipBaru']; ?>
</td>
<td>
<?php echo $c['nipBaru']; ?>
</td>
</tr>
<tr <?php if ($b['nipBaru'] != $c['nipBaru']){echo "bgcolor='#FF0000'";} ?> >
<td>NIP lama</td>
<td>
<?php echo $b['nipLama']; ?>
</td>
<td>
<?php echo $c['nipLama']; ?>
</td>
</tr>
<tr <?php if ($b['gelarDepan'] != $c['gelarDepan']){echo "bgcolor='#FF0000'";} ?> >
<td>Gelar depan</td>
<td>
<?php echo $b['gelarDepan']; ?>
</td>
<td>
<?php echo $c['gelarDepan']; ?>
</td>
</tr>
<tr <?php if ($b['gelarBelakang'] != $c['gelarBelakang']){echo "bgcolor='#FF0000'";} ?> >
<td>Gelar belakang</td>
<td>
<?php echo $b['gelarBelakang']; ?>
</td>
<td>
<?php echo $c['gelarBelakang']; ?>
</td>
</tr>
<tr <?php if ($b['tempatLahir'] != $c['tempatLahir']){echo "bgcolor='#FF0000'";} ?> >
<td>Tempat lahir</td>
<td>
<?php echo $b['tempatLahir']; ?>
</td>
<td>
<?php echo $c['tempatLahir']; ?>
</td>
</tr>
</tbody>
</table>
<button type="submit" class="btn btn-primary btn-sm" style="width:10%"><span class="icon-cursor"></span> Approve</button>
<button type="submit" class="btn btn-primary btn-sm" style="width:10%"><span class="icon-cursor"></span> Reject</button>
</div>
</div>
</div>
You can define a class named 'same' and 'different'. Then in php check if the values are same and echo the class property based on being same or different.
php
<tr>
<td>Nama</td>
<td class="<?php echo ($b['nama'] == $c['nama'])? 'same': 'different'; ">
<?php echo $b['nama']; ?>
</td>
<td class="<?php echo ($b['nama'] == $c['nama'])? 'same': 'different'; ">
<?php echo $c['nama']; ?>
</td>
</tr>
In Styles
.same{
color:green;
}
.different{
color:red;
}
We have used ternary operator to figure out if the variables are same or not.
https://www.abeautifulsite.net/how-to-use-the-php-ternary-operator
Since you seem to be using Bootstrap, you could just apply an already defined style to the cells to highlight the difference. For instance:
<tr>
<td>Nama</td>
<td class="<?php echo ($b['nama'] == $c['nama'])? 'bg-success': 'bg-danger'; ">
<?php echo $b['nama']; ?>
</td>
<td class="bg-<?php echo ($b['nama'] == $c['nama'])? 'bg-success': 'bg-danger'; ">
<?php echo $c['nama']; ?>
</td>
</tr>
By doing this, if $b['nama'] and $c['nama'] are different, the cells would have an near-red background and if they are equal, they'd have a near-green background. If you'd like to only highlight differences (in order to make the screen less overwhelming, just replace the 'bg-success' with '' so the equal cells don't get styled

Page redirect After Update data with custom code in wordpress

I have put a WordPress code to change the profile. The data is being updated, but after updating it is not redirected to the main page. Now I have to redirect it to another page if it gets redirected, then data not update. How could I do that?
<form method="post" id="adduser" action="<?php the_permalink(); ?>" class="profile-field">
<table class="table table-bordered">
<tbody>
<!--tr>
<td>Name</td>
<td><?php echo $user_details['first_name'][0]; ?></td>
</tr>
<tr>
<td>Email</td>
<td><?php echo wp_get_current_user()->user_email;?></td>
</tr-->
<p class="form-username">
<label for="first-name"><?php _e('First Name', 'profile'); ?></label>
<input class="text-input" name="first-name" type="text" id="first-name"
value="<?php the_author_meta( 'first_name', $current_user->ID ); ?>" />
</p>
<p class="form-username">
<label for="last-name"><?php _e('User mail', 'profile'); ?></label>
<input class="text-input" name="last-name" type="text" id="last-name"
value="<?php the_author_meta( 'user_email', $current_user->ID ); ?>" />
</p>
<!--tr>
<td>Company Code</td>
<td><?php echo $user_details['companycode'][0]; ?></td>
</tr>
<tr>
<td>Industry</td>
<td><?php echo $user_details['industury'][0]; ?></td>
</tr>
<tr>
<td>Job title</td>
<td><?php echo $user_details['jobtitle'][0]; ?></td>
</tr>
<tr>
<td>Experience</td>
<td><?php echo $user_details['experience'][0]; ?> Years</td>
</tr>
</tbody>
</table-->
<?php do_action('edit_user_profile',$current_user); ?>
<p class="form-submit">
<?php echo $referer; ?>
<div>
<button name="updateuser" type="submit" id="updateuser" class="submit button"
value="<?php _e('Update', 'profile'); ?>">update</button>
<?php //wp_nonce_field( 'update-user' ) ?>
<input name="action" type="hidden" id="action" value="update-user" />
</p>
<!--a class="profileinfo-edit" id ="edit" href="<?php echo site_url();?>/my-profile">Update Profile</a-->
</form>
<?php endif; ?>
See: https://codex.wordpress.org/Action_Reference/profile_update
add_action( 'profile_update', 'my_profile_update', 10, 2 );
function my_profile_update( $user_id, $old_user_data ) {
// Redirect
$redirect_url = '/your-redirect/permalink';
wp_redirect( $redirect_url );
exit();
}

get values from query string (table tr td) foreach line into jquery ui dialog

i have some code, see:
<script>
$$.ready(function() {
// Profile Dialog
$( "#user-dialog" ).dialog({
autoOpen: false,
modal: true,
width: 400,
open: function(){ $(this).parent().css('overflow', 'visible'); $$.utils.forms.resize() }
}).find('button.submit').click(function(){
var $el = $(this).parents('.ui-dialog-content');
if ($el.validate().form()) {
$el.dialog('close');
}
}).end().find('button.cancel').click(function(){
var $el = $(this).parents('.ui-dialog-content');
$el.find('form')[0].reset();
$el.dialog('close');;
});
$('#user-table').on('click', '.open-user-dialog', function(){
$( "#user-dialog" ).dialog( "open" );
return false;
});
});
</script>
<table id="user-table">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>action</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT id,user_name FROM users";
if ($result = $verbindung->query($sql)) {
while ($row = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $row["id"];?></td>
<td><?php echo $row["user_name"];?></td>
<td>
<button class="open-user-dialog"><img src="img/icons/packs/fugue/16x16/bullet_go.png"/> view</button>
</td>
</tr>
<?php }} ?>
</tbody>
</table>
<div style="display: none;" id="user-dialog" title="user view">
<form action="">
<div class="row">
<label>
<strong>User details</strong>
</label>
<div>
<input type="text" id="user_id" value="<?php echo $id; ?>">
<input type="text" id="user_name" value="<?php echo $user_name; ?>">
</div>
</div>
</form>
<div class="actions">
<div class="left">
<button class="grey cancel">cancel</button>
</div>
<div class="right">
<input id="submit" onclick="userFunction()" type="button" value="go">
</div>
</div>
</div>
How i get my details from table to my jquery dialog?
the dialog is working fine, but i dont get the values $row['id'] and $row['user_name'] to display in my jquery dialog.
What I also try, I do not get the data in my dialog to be able to process them further.
How i can pass $row['id'] and $row['user_name'] for each line to my dialog?
Can someone Help me?
Firstly you add Php code in Php tags.You don't write if and while in php.
<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>action</th>
</tr>
</thead>
<tbody>
<?php
if ($result = $verbindung->query($sql)) {
while ($row = $result->fetch_assoc()) {
?>
<tr>
<td><?php echo $row["id"];?></td>
<td><?php echo $row["user_name"];?></td>
<td>
<button class="open-user-dialog"><img src="img/icons/packs/fugue/16x16/bullet_go.png"/> view</button>
</td>
</tr>
<?php }} ?>
</tbody>
</table>
<div style="display: none;" id="user-dialog" title="user view">
<form action="">
<div class="row">
<label>
<strong>User details</strong>
</label>
<div>
<input type="text" id="user_id" value="<?php echo $id; ?>">
<input type="text" id="user_name" value="<?php echo $user_name; ?>">
</div>
</div>
</form>
<div class="actions">
<div class="left">
<button class="grey cancel">cancel</button>
</div>
<div class="right">
<input id="submit" onclick="userFunction()" type="button" value="go">
</div>
</div>
try this

Categories

Resources