Show pop up on each table row - php

I want show a popup when I click the text "lihat" on the table row. The code I use is this:
<?php
$no=1;
while($result = mysql_fetch_array($query)){
echo"<tr>";
echo"<td align='center'>" .$no. "</td>";
echo"<td align='center'>" .$result[create_time]. "</td>";
echo"<td align='center'>" .$result[mesin]. "</td>";
echo"<td align='center'>" .$result[part]. "</td>";
echo"<td align='center'>" .$result[indikasi]. "</td>";
echo"<td align='center'>" .$result[pelapor]. "</td>";
if($result[status]=='BELUM DIKERJAKAN'){
echo'<td style="background-color:#ff0000; color:#ffffff" align="center">'.TUNGGU.'</td>';}
elseif($result[status]=='DIKERJAKAN'){
echo'<td style="background-color:#003cd4; color:#ffffff" align="center">'.DIKERJAKAN.'</td>';}
elseif($result[status]=='TUNDA'){
echo'<td style="background-color:#ffea00; color:#00000" align="center">'.DITUNDA.'</td>';}
else{
echo'<td style="background-color:#06ff00; color:#00000" align="center">'.SELESAI.'</td>';}
echo"<td align='center'><a class='update' href='#' value='Popup' onclick='window.open(\pltd-siantan/home_wo.php?cat=wo&page=rincian_wo&order_id={$result['order_id']}\',) >Lihat</a></td>";
echo"</tr>";
$no++;
}
Any solution?

The general solution would be to use ajax to send a request ( either get or post ) to your pltd-siantan/home_wo.php page and the callback assigned to the ajax function would then display the popup. You can get many different javascript routines to create the popup, probably the best known is Lightbox which you can find here

Related

contenteditable not working on Microsoft Edge

I've got a dynamically created table, that utilizes "contenteditable".
Recently, I've had a user try to use the webpage via Microsoft Edge and none of the fields work. I then tried it on my computer as well, and had the same issue.
I use Google Chrome to develop and that works perfectly fine, and on the documentation it says that Edge is supported.
Here is the code that generates my tables rows:
while($row = $ret->fetchArray(SQLITE3_ASSOC) ){
echo "<tr>";
echo "<td style='width:10%;overflow:auto;border-left:1px solid #ddd;'>
<div style='cursor:pointer' name='del' class='fa fa-times-circle fa-lg button2' aria-hidden='true'>
<div style='display:none'>
".$row['uniqueID']."
</div>
</div>
</td>";
echo "<td style='width:10%;overflow:auto;' id='Readable:".$row['uniqueID']."' contenteditable='true'>
".$row['Readable']."
</td>";
echo "<td style='width:10%;overflow:auto;' id='Type:".$row['uniqueID']."' contenteditable='true'>
".$row['Type']."
</td>";
echo "<td style='width:10%;overflow:auto;' id='Category:".$row['uniqueID']."' contenteditable='true'>
".$row['Category']."
</td>";
echo "<td style='width:10%;overflow:auto;' id='Status:".$row['uniqueID']."' contenteditable='true'>
".$row['Status']."
</td>";
echo "<td style='width:10%;overflow:auto;' id='ShelfID:".$row['uniqueID']."' contenteditable='true'>
".$row['ShelfID']."
</td>";
echo "<td style='width:10%;overflow:auto;' id='LocationID:".$row['uniqueID']."' contenteditable='true'>
".$row['LocationID']."
</td>";
echo "<td style='width:10%;overflow:auto;' id='Height:".$row['uniqueID']."' contenteditable='true'>
".$row['Height']."
</td>";
echo "<td style='width:10%;overflow:auto;' id='ListingStatus:".$row['uniqueID']."' contenteditable='true'>
".$row['ListingStatus']."
</td>";
echo "<td style='width:10%;overflow:auto;border-right:1px solid #ddd;' id='Sales:".$row['uniqueID']."' contenteditable='true'>
".$row['Sales']."
</td>";
echo "</tr>";
}
Is this some kind of incompatibility? What can I do to resolve this issue?
In order to avoid that kind of problems and maximize compatibility, it's better to use contentEditable only on a restricted number of tags like divs, if you use it in other elements like td then you might find problems like this one.
So the solution would be to include a div in each of those cells and make those divs the contentEditable elements

How to display and merge table from PostgreSQL using php?

I am trying to display data from data base. I want to make it grouped. Here is the template
I made the code like this :
<?php
$queg=pg_query("SELECT agentgroup.leadername,agentgroup.reviewername, agentgroup.supervisorname, agent.onlinename from agentgroup left join agent on agentgroup.agentid=agent.agentid order by agentgroup.leadername");
echo "<td class=\"form1\" align=\"center\" > Number </td>";
echo "<td class=\"form1\" align=\"center\" > Agent Group </td>";
echo "<td class=\"form1\" align=\"center\" > Coach </td>";
echo "<td class=\"form1\" align=\"center\" > Supervisor </td>";
echo "<td class=\"form1\" align=\"center\" > Agent Online Name </td>";
echo "<td class=\"form1\" align=\"center\" ></td>";
$gcount=1;
while($grow=pg_fetch_array($queg)){
echo "<tr>";
echo "<td class=\"forma\" rowspan=\"8\" align=\"center\"> ".$gcount++."</td>";
echo "<td class=\"forma\" rowspan=\"8\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['leadername']." </td>";
echo "<td class=\"forma\" rowspan=\"8\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['reviewername']." </td>";
echo "<td class=\"forma\" rowspan=\"8\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['supervisorname']." </td>";
echo "<td class=\"forma\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['onlinename']." </td>";
echo "<td class=\"forma\" rowspan=\"4"align=\"center\"><a href=\"#\" >edit</a></td>
</tr>";}
?>
But I got chaos.this is the current output
Any help to display those data? Thank you :D
The database design was wrong I guess. In case its already happen, than u shouldnt display the data like that. try to pass the specified data to new page via url ( href ) and then display them one by one by specify the coach or agent group
<?php
$queg=pg_query("SELECT distinct leadername, reviewername, supervisorname from agentgroup order by leadername");
echo "<td class=\"form1\" align=\"center\" > Number </td>";
echo "<td class=\"form1\" align=\"center\" > Agent Group </td>";
echo "<td class=\"form1\" align=\"center\" > Coach </td>";
echo "<td class=\"form1\" align=\"center\" > Supervisor </td>";
echo "<td class=\"form1\" align=\"center\" ></td>";
echo "<td class=\"form1\" align=\"center\" ></td>";
$gcount=1;
while($grow=pg_fetch_array($queg))
{
echo "<tr>";
echo "<td class=\"forma\" align=\"center\"> ".$gcount++."</td>";
echo "<td class=\"forma\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['leadername']." </td>";
echo "<td class=\"forma\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['reviewername']." </td>";
echo "<td class=\"forma\" align=\"left\"style=\"padding-left:10%;\"> ".$grow['supervisorname']." </td>";
echo "<td class=\"form2\" align=\"center\"><a href=viewpergorup.php?viewnamegroup=".urlencode($grow['leadername'])."><img src=\"image\\view.png\" width=\"20px\" height=\"20px\" style=\"padding-left:22%;cursor:pointer;\"></td>";
}
make the page : view_agentgroup. There the details is displayed

delete row of database from a view list that displayed by looping

I have a view list that displayed through php
$quedchan=pg_query("SELECT agent.agentname, agent.onlinename, agent.channel, agentgroup.leadername FROM Agent LEFT JOIN agentgroup on agent.agentid=agentgroup.agentid where agent.channel like '%$DCH%'order by agent.channel");
echo "<td class=\"form1\" align=\"center\" > Number </td>";
echo "<td class=\"form1\" align=\"center\" > Agent Name </td>";
echo "<td class=\"form1\" align=\"center\"> Agent Online Name </td>";
echo "<td class=\"form1\" align=\"center\"> Agent Channel </td>";
echo "<td class=\"form1\" align=\"center\"> Agent Group </td>";
echo "<td class=\"form1\" align=\"center\"> </td>";
$counttttt=1;
While($row3=pg_fetch_array($quedchan))
echo "<tr>";
echo "<td class=\"forma\" align=\"center\"> ".$counttttt++." </td>";
echo "<td class=\"forma\"name=\"dement\" align=\"left\"style=\"padding-left:10%;\"> ".$row3['agentname']." </td>";
echo "<td class=\"forma\" align=\"left\"style=\"padding-left:8%;\"> ".$row3['onlinename']." </td>";
echo "<td class=\"forma\" align=\"left\"style=\"padding-left:8%;\"> ".$row3['channel']." </td>";
echo "<td class=\"forma\"align=\"left\"style=\"padding-left:6%;\"> ".$row3['leadername']." </td>";
echo "<td class=\"forma\" align=\"center\"><img src=\"image\\delete.png\" width=\"20px\" height=\"20px\" style=\"padding-left:22%;cursor:pointer;\"/></td>
</tr>";
And I want to make a delete function, so that the delete image of a row can delete its row. I made this by give a name for agentname row, name=\"dement\". in order to catch the value I want to delete. Im using php in another page called delete.php :
<?php
session_start();
include 'connect.php';
$dagname=$_GET['dement'];
$queda="DELETE FROM Agent where agentname='$dagname'";
$result=pg_query($queda);
if($result)
{
$_SESSION['delMessage11']='Selected Agent is successfully deleted!';
header('Location: Dagent.php');
}
else
{
echo "ERROR!";
}
?>
It doesnt work. I tried to use a reference from http://www.phpeasystep.com/mysql/7.html. it says I can get value of id (which I replace with agentname now) that sent from address bar. I implement it and become this
echo "<td class=\"form2\" align=\"center\">\"<img src=\"image\\delete.png\" onclick=\"dela();\" width=\"20px\" height=\"20px\" style=\"padding-left:22%;cursor:pointer;\"/></td>
</tr>";
But it doesnt work. Any help? Thank you
Why don't you use method ="get"? it's more simple. So when the button was clicked, 'something' (based on you need) would be save in a variable and directly move on into a new page which is filled by delete queries and use $_GET for catch the variable(filled by 'something') for support the queries and the attributes. when you are moving on into a new page then you will see the link, it would be like this
DATA_NAME.php?$something.
I Hope this can help you. :)

How to Show Popup window on clicking dynamically generated link

T have one page on which results are get created dynamically. And I
want to display popup window on clicking image named view.jpg. The
image is hyperlink. So please tell me how should i do it. I am showing
my code as follows.
code :
echo "<table width='' height='' border='1' align='center'>
<tr><td>Title</td>
<td >Type</td>
<td >Date</td>
<td>Expiry Date</td>";
if($typeofuser=='admin' || $typeofuser=='Accountant' || $typeofuser=='secretary')
{
echo "<td>View</td>
<td>Edit</td>
<td>Delete</td>";
}
echo "</tr>";
$qry2 = mysqli_query($con,"SELECT nId,nTitle,nDescription,nDate,nExpiryDate FROM tblnoticemanager where Society_id = '$socId' and category='General'") or die(mysqli_error($con));
while($NoticeData = mysqli_fetch_array($qry2))
{
echo "<tr>";
echo "<td align='center' class='tdletter' style='text-transform:capitalize;'>" .$NoticeData['nTitle']. "</td>";
echo "<td align='center' class='tdletter' ><div class='overflowDiv'>" . $NoticeData['nDescription']."</div></td>";
echo "<td align='center' class='tdletter'>" . $NoticeData['nDate'] ."</td>";
echo "<td align='center' class='tdletter'>" . $NoticeData['nExpiryDate'] ."</td>";
if($typeofuser=='admin' || $typeofuser=='Accountant' || $typeofuser=='secretary')
{
echo "<td align='center' class='tdletter'><div><a href='?id=".urlencode(base64_encode($NoticeData['nId']))."'><img src='images/view.png' width='30' height='30' align='center' /></a></div></td>";
echo "<td align='center' class='tdletter'><div><a href='?id=".urlencode(base64_encode($NoticeData['nId']))."' ><img src='images/edit.jpg' width='30' height='30' align='center'/></a></div></td>";
echo "<td align='center' class='tdletter'><span id='".$NoticeData['nId']."' class='trash'><img src='images/delete1.jpg' width='30' height='30' align='center' /></span></td>";
}
echo "</tr>";
}
echo "</table>";
You can use attribute selector [attribute='value']
$("[src='images/view.png']").click(function(){
alert("clicked");
});

MySql, PHP display Picture on HTml

im trying to display the picture saved in the database using Php, but what i get is Url link which was saved in the database and not the picture, i think the syntax is wrong.
<?php
echo "<table border=\"1\" align=\"center\">";
echo "<tr>
<th>Name</th>
<th>Description</th>
<th>Price</th>
<th>Manufacturer</th>
<th>Image</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" .$row['Name']."</td>";
echo "<td>" .$row['Description'] ."</td>";
echo "<td>" .$row['Price'] ."</td>";
echo "<td>" .$row['Manufacturer'] ."</td>";
echo "<td>" .$row['ImageURL'] ."</td>";
echo "</tr>";
}
echo "</table>";
?>
</p>
<?php
You need to construct an <img> element, not just output the image URL.
Try replacing this: $row['ImageURL']
With this: "<img src='".$row['ImageURL']."' />
On this line:
echo "<td>" .$row['ImageURL'] ."</td>";
it looks like you'll want that to be:
echo "<td><img src='" .$row['ImageURL'] ."' /></td>";
Change
echo "<td>" .$row['ImageURL'] ."</td>";
to
echo "<td><img src='" .$row['ImageURL'] ."' style='width: 200px; height: 350px;' /></td>";
Modify the values 200px and 350px to whatever you want, just keep the 'px' suffix.

Categories