How do I echo a clickable URL in PHP? - php

How do I echo a clickable URL in PHP?
i want to makes this code as a clickable link, so i can click it, but i got no idea how to make it. Please help me if you know this case.
picture of the problem code
and these are my code :
<div class="container-fluid">
<div class="card">
<div class="card-header">Detail Shelter</div>
<div class="card-body">
<?php foreach($shelter as $slt): ?>
<div class="row">
<div class="col-md-4">
<img src="<?php echo base_url().'/upload/'.$slt->gambar ?>" class="card-img-top">
</div>
<div class="col-md-8">
<table class="table">
<tr>
<td>Nama Shelter</td>
<td><strong></strong><?php echo $slt->nama_shelter ?></td>
</tr>
<tr>
<td>Lokasi Shelter</td>
<td><strong></strong><?php echo $slt->lokasi_shelter?></td>
</tr>
<tr>
<td>Deskripsi</td>
<td><strong></strong><?php echo $slt->deskripsi ?></td>
</tr>
<tr>
<td>Telpon</td>
<td><strong></strong><?php echo $slt->no_telp ?></td>
</tr>
</table>
<?php echo anchor('dashboard/index',
'<div class="btn btn-sm btn-danger"> Kembali </div>') ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>

To make a link clickable you need to use the tag see HERE
For example:
<tr>
<td>Lokasi Shelter</td>
<td><strong></strong>LINK TEXT</td>
</tr>
assuming the link you want is <?php echo $slt->lokasi_shelter?>

You just need to do this : click here

Related

open Collapse sidebar with same DB id

I'm currently working on the forum section of my website.
I followed the link #CBroe suggest me on the comments and implemented offcanvas for my previous problem and now I have this:
<table class="table is-indent changes" id="newsTable">
<thead>
<th></th>
<th></th>
</thead>
<tbody>
<?php foreach($fetchNews as $data):
echo '<tr class="trNew btnSelect" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasRight" aria-controls="offcanvasRight" id=\''.$data['id'].'\'>' ?>
<td class="cell-60 responsive-hide" style="width: 100px;">
<img class="author width" src="<?php echo '../../resource/img/users_Initials/' . $data['autore'].'.png' ?>">
</td>
<td id="<?php echo $data['id']; ?>">
<input type="hidden" id="idNew" value="<?php echo $data['id']; ?>" data-value="<?php echo $data['id']; ?>">
<div class="content">
<div class="title" id="title"> <?php echo $data['titolo']; ?> </div>
<div class="metas">
<span class="author"><?php echo $data['autore']; ?> - </span>
<span class="data"><?php echo $data['data']; ?></span>
</div>
</div>
<?php endforeach;?>
</td>
</tr>
</tbody>
</table>
And this is the offcanvas the table below open:
<!--PANEL NEWS-->
<?php foreach($fetchNews as $data):?>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasRight" aria-labelledby="offcanvasRightLabel">
<div class="offcanvas-header">
<h1 id="newsTitolo"><?php echo $data['titolo']??''; ?></h1>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<div class="forum-header">
<img class="author width" src="<?php echo '../../resource/img/users_Initials/' . $data['autore'].'.png' ?>">
<span class="name"><?php echo $data['autore']??''; ?></span>
<span class="time"><?php echo $data['data']??''; ?></span>
</div>
<div class="forum-content">
<div id="newsTesto" class="articolo">
<?php $Parsedown = new Parsedown();
echo $Parsedown->text(file_get_contents('post/'.$data['titolo'].'/'.$data['titolo'].'.txt')??''); ?>
</div>
<p> <?php echo $data['allegato']??'';?></p>
</div>
</div>
</div>
<?php endforeach;?>
<!--END PANEL NEWS-->
What I basically need to do is display the article with the same ID as the title on the table as this example image: table & panel that by clicking on the first title (ahaaa) it opens the corresponding article.
I tried some stuff like adding $data['id'] on both data-bs-target and data-bs-toggle of the and as id of the offcanvas but it didnt work

How i can do a multiple dynamic popup

This code would complete the table, that work find. The problem with this is that when i can show a dynamic popup only work in the first row but in anyelse don't work
<tr>
<td><img src="../mysql/img/<?php echo $fila['imagen'];?>" class="logoempresa" alt="Logo empresa"></td>
<?php $fila['id'];?>
<td><?php echo $fila['empresa'];?></td>
<td><?php echo $fila['puesto'];?></td>
<td><?php echo $fila['jornada'];?></td>
<td><?php echo $fila['salario'];?></td>
<td><?php echo $fila['zona'];?></td>
<td>
<div class="popup-flex">
<button id="popup-btn">Click Me</button>
</div>
<div id="popup-wrapper" class="popup-container">
<div class="popup-content">
<span id="close">×</span>
<p class="observaciones"><?php echo $fila['observaciones'];?></p>
</div>
</div>
</td>
try
<button id="<?= $fila['id'];?> " class="popup-btn">Click Me</button>
jquery
$('.popup-btn').on('click', function(e){
e.preventDefault()
let id = $(this).attr('id')
//do magic
})
Using vanilla Javascript you might try like this. Remove the ID attributes or convert to dataset versions such as data-id="popup-wrapper" rather than id="popup-wrapper" and use the click event triggered by the button to locate that element in the DOM tree. From that point you can navigate up the DOM tree and query once more to find the POPUP. Once you have identified the popup - open it or do something.. here I just toggle a className.
All the PHP tags below have been removed simply to facilitate the snippet/demo...
const clickhandler=function(e){
let popup=this.parentNode.parentNode.querySelector('[data-id="popup-wrapper"]');
popup.classList.toggle('popped');
/* Open the popup... sing and dance! */
};
document.querySelectorAll('.popup-flex > [data-id="popup-btn"]').forEach( bttn=>bttn.addEventListener('click',clickhandler))
.popped{border:2px solid red;}
td{border:1px solid grey}
<table>
<tr>
<td><img src="//placekitten.com/100/100" class="logoempresa" alt="Logo empresa"></td>
<td>$fila['empresa']</td>
<td>$fila['puesto']</td>
<td>$fila['jornada']</td>
<td>$fila['salario']</td>
<td>$fila['zona']</td>
<td>
<div class="popup-flex">
<button data-id="popup-btn">Click Me</button>
</div>
<div data-id="popup-wrapper" class="popup-container">
<div class="popup-content">
<span data-id="close">×</span>
<p class="observaciones">$fila['observaciones']</p>
</div>
</div>
</td>
</tr>
<tr>
<td><img src="//placekitten.com/100/100" class="logoempresa" alt="Logo empresa"></td>
<td>$fila['empresa']</td>
<td>$fila['puesto']</td>
<td>$fila['jornada']</td>
<td>$fila['salario']</td>
<td>$fila['zona']</td>
<td>
<div class="popup-flex">
<button data-id="popup-btn">Click Me</button>
</div>
<div data-id="popup-wrapper" class="popup-container">
<div class="popup-content">
<span data-id="close">×</span>
<p class="observaciones">$fila['observaciones']</p>
</div>
</div>
</td>
</tr>
<tr>
<td><img src="//placekitten.com/100/100" class="logoempresa" alt="Logo empresa"></td>
<td>$fila['empresa']</td>
<td>$fila['puesto']</td>
<td>$fila['jornada']</td>
<td>$fila['salario']</td>
<td>$fila['zona']</td>
<td>
<div class="popup-flex">
<button data-id="popup-btn">Click Me</button>
</div>
<div data-id="popup-wrapper" class="popup-container">
<div class="popup-content">
<span data-id="close">×</span>
<p class="observaciones">$fila['observaciones']</p>
</div>
</div>
</td>
</tr>
</table>

How to loop through all the records in jquery datatable in php

I have JQUERY datatable in my PHP page in which I have one check box, I want to get the values of all the check boxes checked in that datatable with php code by using
implode(',',$_POST['accessflag']);
But it is showing the values only on the current page. I want to get the values of all checked check boxes in the datatable from all the pages of that particular table .anybody please help me to get this done.
my HTML code is
<div class="row control-container pt-2">
<div class="table-responsive col-md-12">
<div class="row">
<div class="col-md-12" style="text-align:center">
<label style="color:red">
<?php if (isset($_SESSION['SaveMsg'])) { echo $_SESSION['$SaveMsg'];unset($_SESSION['$SaveMsg']);}?>
</label>
</div>
</div>
<table id="moduletable" class="table table-sm table-bordered table-hover table-lightfont display">
<thead class="thead-light">
<tr>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GRP_DESC"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MODULE_NAME"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","GMA_ACCESS_FLAG"); ?></th>
<th><?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","OPTIONS"); ?></th>
</tr>
</thead>
<tbody>
<?php
if(isset($_SESSION['$nextset'])){
$limit=$_SESSION['$nextset'];}
else{$limit=0;}
if ($_SESSION['$language']="E") {
$groupdata=SelectData("group_module_access,user_group,modules","gma_id,gma_grp_id,grp_desc,gma_module_id,module_name,gma_access_flag","gma_grp_id=grp_id and gma_module_id=module_id","gma_grp_id,gma_id LIMIT ".$limit.",50");
}
else {
$groupdata=SelectData("group_module_access,user_group,modules","gma_id,gma_grp_id,grp_bldesc as grp_desc,gma_module_id,module_blname as module_name,gma_access_flag","gma_grp_id=grp_id and gma_module_id=module_id","gma_grp_id,gma_id LIMIT ".$limit.",50");
}
foreach ($groupdata as $groupdatalist) {?>
<tr>
<td><?php echo $groupdatalist["grp_desc"];?></td>
<td><?php echo $groupdatalist["module_name"];?></td>
<?php if($groupdatalist["gma_access_flag"]=="N"):?>
<td style="text-align:right;width:10px;"><input type="checkbox" name="accessflag[]" id="accessflag"
value="<?php echo "{$groupdatalist['gma_id']}"?>"/> </td>
<?php else:?>
<td style="text-align:right;width:10px;"><input type="checkbox" checked name="accessflag[]" id="accessflag" width="10px"
value="<?php echo "{$groupdatalist['gma_id']}"?>"/> </td>
<?php endif;?>
<!--<td style="display:none;"><//?php echo $groupdatalist["gma_grp_id"];?></td>
<td style="display:none;"><//?php echo $groupdatalist["gma_module_id"];?></td>
<td style="display:none;"><input type="text" name="gmaid" id="gmaid" value="<//?php echo $groupdatalist["gma_id"];?>"></td>-->
<td>
<?php if($groupdatalist["gma_access_flag"]=="N"):?>
<a href="#" class="btn btn-light btn-sm pt-0 shadow-none"
data-toggle="tooltip" title="<?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MENUPERMISSION");?>">
<i class="fa fa-pencil-square-o"></i>
</a>
<?php else:?>
<a href="group_action.php?gmagrpid=<?php echo $groupdatalist['gma_grp_id']?>&gmamoduleid=<?php echo $groupdatalist['gma_module_id']?>&page=MenuPermission&gmagrpdesc=<?php echo $groupdatalist['grp_desc']?>&gmamodulename=<?php echo $groupdatalist['module_name']?>" class="btn btn-light btn-sm pt-0 shadow-none"
data-toggle="tooltip" title="<?php echo GetBilingualLabels($_SESSION['$language'],"MODULEACCESS","MENUPERMISSION");?>">
<i class="fa fa-pencil-square-o"></i>
</a>
<?php endif;?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" name="updmodaccess" formnovalidate class="btn nc btn-primary btn-rounded">
<i class="fa fa-save"></i>
<?php echo GetBilingualLabels($_SESSION['$language'],"BUTTON","SAVE"); ?>
</button>
</div>
</div>
</div>
</div>
PHP code on updmodaccess button is
if (isset($_POST['updmodaccess'])) {
$keytoupdate=implode(',',$_POST['accessflag']);
$table="group_module_access"; $data=array("gma_access_flag"=>"Y", "gma_upd_dt"=>GetDateTime($_SESSION['$TimeZone']), "gma_upd_uid"=>"{$_SESSION['$userid']}");
UpdateData($table,$data,"gma_id in (".$keytoupdate.")",$Message,$flg);
$data=array("gma_access_flag"=>"N", "gma_upd_dt"=>GetDateTime($_SESSION['$TimeZone']), "gma_upd_uid"=>"{$_SESSION['$userid']}");
UpdateData($table,$data,"gma_id not in (".$keytoupdate.")",$Message,$flag);
}
you can try the following code. I hope it helps.
you need to get these values using ajax and then need to send this value to php using an ajax.
$(document).ready(function(){
var data = new Object();
var table = $('#addUsersToAboTable').DataTable();
$('#addUsersToAboTable').on('change', ':checkbox', function () {
data[table.row($(this).parents('tr').get(0)).index()] = this.checked;
});
$('#getDataBtn').on('click',function(){
console.log(data);
});
});
Here you can see the demo script as well jQuery Datatables, How to get all selected checkboxes from EVERY page

all subjects in same table in my sheetmark

What do I need to change from below code in order to get all the subjects in the same table?
<?php
include('grade.php');
$mysubject = $grade->getsubject();
?>
<p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<?php foreach($mysubject as $row): ?>
<div class="col-lg-4 gradeform">
<div class="form_hover " style="background-color: #428BCA;">
<p style="text-align: center; margin-top: 20px;">
<i class="fa fa-bar-chart-o" style="font-size: 147px;color:#fff;"></i>
</p>
<div class="header">
<div class="blur"></div>
<div class="header-text">
<div class="panel panel-success" style="height: 247px;">
<div class="panel-heading">
<h3 style="color: #428BCA;">Subject: <?php echo $row['subject'];?></h3>
</div>
<div class="panel-body">
<table class="table table-bordered">
<tr class="alert alert-danger">
<th>TD</th>
<th>Exam</th>
<th>catching</th>
<th>average</th>
</tr>
<?php $mygrade = $grade- >getgrade($row['id']); ?>
<tr>
<td><?php echo $mygrade['att1']; ?></td>
<td><?php echo $mygrade['exam1']; ?></td>
<td><?php echo $mygrade['quiz1']; ?></td>
<td><?php echo $mygrade['project1']; ?></td>
</tr>
</table>
<div class="form-group">
<?php $teacher = $grade->getteacher($row['id']); ?>
<label>Teacher: <?php echo $teacher;?></label><br />
<label>Semester: <?php echo $row['sem']?> Sem</label><br />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
i have every subject in différent table
The problem is, in each iteration of foreach loop you're creating a new table. If you want to display all the subjects under one table, just take the <table> outside of your foreach loop, like this:
// your code
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-lg-4 gradeform">
<div class="form_hover " style="background-color: #428BCA;">
<p style="text-align: center; margin-top: 20px;">
<i class="fa fa-bar-chart-o" style="font-size: 147px;color:#fff;"></i>
</p>
<div class="header">
<div class="blur"></div>
<div class="header-text">
<div class="panel panel-success" style="height: 247px;">
<table class="table table-bordered">
<?php foreach($mysubject as $row): ?>
<div class="panel-heading">
<h3 style="color: #428BCA;">Subject: <?php echo $row['subject'];?></h3>
</div>
<div class="panel-body">
<tr class="alert alert-danger">
<th>TD</th>
<th>Exam</th>
<th>catching</th>
<th>average</th>
</tr>
<?php $mygrade = $grade- >getgrade($row['id']); ?>
<tr>
<td><?php echo $mygrade['att1']; ?></td>
<td><?php echo $mygrade['exam1']; ?></td>
<td><?php echo $mygrade['quiz1']; ?></td>
<td><?php echo $mygrade['project1']; ?></td>
</tr>
<div class="form-group">
<?php $teacher = $grade->getteacher($row['id']); ?>
<label>Teacher: <?php echo $teacher;?></label><br />
<label>Semester: <?php echo $row['sem']?> Sem</label><br />
</div>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Display specific row data in bootstrap modal with edit button click

I am new to programming and trying to implement bootstrap modal to display row data from a mysql table into the modal window.
I have tried the solution found on stackoverflow "Pull information from mysql table to bootstrap modal to edit" by link. But could not able to display the particular row with the $row['SFID'].
I can pull table data but when I click the edit button in front of any row it always show the last row id
and doesn't display the data in the input box on the modal to edit the data???.
Here I am till now, Please help me out.
<table class="table table-bordered" width="100%">
<thead>
<tr>
<th>SFID</th>
<th>Company</th>
<th>Product</th>
<th>Product Line</th>
<th>Dealer Class</th>
<th>Status</th>
</tr>
</thead>
<?php
$query = "SELECT * FROM tblcustomer";
$stmt = $db->prepare($query);
$stmt->execute();
foreach ($stmt as $row): ?>
<tr>
<?php $rowID = $row['SFID']; ?>
<td><?php echo $row['SFID']; ?></td>
<td><?php echo $row['CompanyName']; ?></td>
<td><?php echo $row['Product']; ?></td>
<td><?php echo $row['ProductLine']; ?></td>
<td><?php echo $row['DealerClass']; ?></td>
<td><?php echo $row['RequestStatus']; ?></td>
<td style="text-align: center">
<div class="btn-toolbar">
<div class="btn-group">
<a class="btn btn-danger" href="#delModal" data-toggle="modal"><i class="icon-trash icon-white"></i> Delete</a>
<?php echo "<a class='btn update' href='#editModal' data-sfid='".$row['SFID']."' role='button' data-toggle='modal'>Edit</a>"; ?>
</div>
</div>
</td>
</tr>
<?php endforeach; ?>
</table>
<div id="editModal" class="modal hide fade in" style="display: none; ">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Edit Customer Details</h3>
</div>
<div>
<form class="contact">
<fieldset>
<div class="modal-body">
<?php echo $row['SFID']; ?>
<ul class="nav nav-list">
<li class="nav-header">SFID</li>
<li><input class="input-xlarge" type="text" name="mysfid" id="mysfid"></li>
<!--<li class="nav-header">Company</li>
<li><input class="input-xlarge" value=" " type="text" name="mycompany"></li>
<li class="nav-header">Dealer Class</li>
<li><input class="input-xlarge" value=" " type="text" name="mydealerclass"></li> -->
</ul>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-success" id="submit">Approved</button>
Close
</div>
</div>
<script>
$(document).ready(function(){
$('a.edit').click(function(){
var sfid = $(this).data('sfid');
var company = $(this).data('company');
var dealerclass = $(this).data('dealerclass');
$('#mysfid').val(sfid);
$('#mycompany').val(company);
$('#mydealerclass').val(dealerclass);
});
});
</script>
Thanks for your help.
<table class="table table-bordered" width="100%">
<thead>
<tr>
<th>SFID</th>
<th>Company</th>
<th>Product</th>
<th>Product Line</th>
<th>Dealer Class</th>
<th>Status</th>
</tr>
</thead>
<?php
$query = "SELECT * FROM tblcustomer";
$result = mysql_query($query);
$i=1;
while($row = mysql_fetch_assoc($result))
{
?>
<tr>
<?php $rowID = $row['SFID']; ?>
<td><?php echo $row['SFID']; ?></td>
<td><?php echo $row['CompanyName']; ?></td>
<td><?php echo $row['Product']; ?></td>
<td><?php echo $row['ProductLine']; ?></td>
<td><?php echo $row['DealerClass']; ?></td>
<td><?php echo $row['RequestStatus']; ?></td>
<td style="text-align: center">
<div class="btn-toolbar">
<div class="btn-group">
<a class="btn btn-danger" href="#delModal" data-toggle="modal"><i class="icon-trash icon-white"></i> Delete</a>
<a class="btn update" href="#editModal<?php echo$i?>" data-sfid='"<?php echo $row['SFID'];?>"' data-toggle="modal">Edit</a>
<!--Yor Edit Modal Goes Here-->
<div id="editModal<?php echo $i; ?>" class="modal hide fade in" role="dialog" ria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Edit Customer Details</h3>
</div>
<div>
<form class="contact">
<fieldset>
<div class="modal-body">
<?php echo $row['SFID']; ?>
<ul class="nav nav-list">
<li class="nav-header">SFID</li>
<li><input class="input-xlarge" type="text" name="mysfid" id="mysfid"></li>
<!--<li class="nav-header">Company</li>
<li><input class="input-xlarge" value=" " type="text" name="mycompany"></li>
<li class="nav-header">Dealer Class</li>
<li><input class="input-xlarge" value=" " type="text" name="mydealerclass"></li> -->
</ul>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-success" id="submit">Approved</button>
Close
</div>
</div>
</div>
</div>
</td>
</tr>
<?php $i++; } ?>
</table>
take $i = 1 above for loop and increament it in each iteration of for loop..so it will take each records
Your Form
<a class='btn update' href='#editModal<?php echo $i;?>' data-sfid='".$row['SFID']."' role='button' data-toggle='modal'>Edit</a>
Modal Window
<div id="editModal<?php echo $i;?>" class="modal hide fade in" style="display: none; ">
That's because you fill the edit modal with the $row data, which by then, is on the last item.
To get data for a specific row, you could create a javascript object/array and then fetch the data by making use of the data-rfid parameter in the "Edit" link. Or you can fetch the row with Ajax for example.

Categories