contenteditable not working on Microsoft Edge - php

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

Related

PHP - How to change font size of HTML table?

I'm generating table in a foreach loop
echo "<tr>";
echo "<td align='left' bgcolor='$bgclr'>".$monthName."</td>";
echo "<td align='center' bgcolor='$bgclr'>".$id."</td>";
echo "<td align='center' bgcolor='$bgclr'>".$total."</td>"
echo "</tr>";
I need to increase font size of the table, but i'm not sure how. Does the html table has attribute to set font size or I should use CSS ?
Just use font style css in style attribute :
echo "<tr>";
echo "<td align='left' bgcolor='$bgclr' style='font-size:10px'>".$monthName."</td>";
echo "<td align='center' bgcolor='$bgclr' style='font-size:10px'>".$id."</td>";
echo "<td align='center' bgcolor='$bgclr' style='font-size:10px'>".$total."</td>"
echo "</tr>";
use the html styling on the echoed elements. For example echo '<table style="font-size: 100px">';
You need to define font size in one variable and then use in inline as below code:
foreach{
$fontsize = 'font-size: '.((isset(FONT_SIZE_IN_FOREACH))?FONT_SIZE_IN_FOREACH:12);
echo "<tr>";
echo "<td align='left' bgcolor='$bgclr' style='$fontsize'>".$monthName."</td>";
echo "<td align='center' bgcolor='$bgclr'>".$id."</td>";
echo "<td align='center' bgcolor='$bgclr'>".$total."</td>"
echo "</tr>";
}
You can add class to the table and write css for that class.
HTML:
<table class='fontsize'>
</table>
CSS:
.fontsize {
font-size:16px;
}

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. :)

Show pop up on each table row

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

Unique radio name in php while loop

Well, I've following Php code which generate a table with radio button so that user can select only one radio button in EVERY row. But to select only one radio button in Every row it's must be a unique name in EVERY row, Right ? But I can't get any idea how do i set a unique name in while loop. Can you guys give me any idea or solutions ?
Php code:
$action = htmlspecialchars($_SERVER['PHP_SELF'])."?class=$class_from";
echo "<form method='post' action='$action' name='attendence'/>";
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>";
echo "<tr>";
echo "<td class='tdhead' valign='top' width='200'><b>Student Name</b></td>";
echo "<td class='tdhead' valign='top' width='250'><b>Roll No</b>
</td>";
echo "<td class='tdhead' valign='top' width='250'><b>Class Name</b>
</td>";
echo "<td class='tdhead' valign='top' width='200'><b>Present / Not present</b>
</td>";
echo "<td class='tdhead' valign='top' width='200'>Check All <input type= 'checkbox'
onclick='checkAll(this)' /></td>";
echo "</tr>";
while($res2 = mysql_fetch_array($sql2))
{
$sname = inputvalid($res2['sname']);
$roll = inputvalid($res2['roll']);
$class = inputvalid($res2['class']);
echo "<tr>";
echo "<td class='tdhead2' valign='top'>$sname</td>";
echo "<td class='tdhead2' valign='top'>$roll</td>";
echo "<td class='tdhead2' valign='top'>$class</td>";
echo "<td class='tdhead2' valign='top'>
<input type='radio' name='ch[]' value='1' /> <input type='radio' name='ch[]'
value='1' />
</td>";
echo "<td class='tdhead2' valign='top'> </td>";
echo "</tr>";
}
echo "<tr>";
echo "<td class='tdhead2'> </td>";
echo "<td class='tdhead2'> </td>";
echo "<td class='tdhead2'> </td>";
echo "<td class='tdhead2'> </td>";
echo "<td class='tdhead2'><input type='submit' value='Record' name='Submit'
class='submit' /></td>";
echo "</tr>";
echo "</table>";
echo "</form>";
Thanks for your help.
Update:
echo "<td class='tdhead2' valign='top'>";
echo '<input type="radio" name="ch'.$counter++.'[]" value="1">';
echo " ";
echo '<input type="radio" name="ch'.$counter.'[]" value="0">';
echo "</td>";
you can set a variable counter:
$counter = 1;
while($res2 = mysql_fetch_array($sql2)){
echo '<input type="radio" name="ch'.$counter++.'[]" value="'.$counter++.'">';
}
Instead of making the name just ch[] you can make the name ch[SOME_UNIQUE_VALUE] for each row. Usually something like an id number is used. Perhaps $roll if that is unique to each student. That will also allow you to know which id the radio button pertains to. On form submit, you can foreach($_POST['ch'] as $id=>$value) and get the id out.
Edit:
Example code:
//start the counter variable
$counter = 1;
while($res2 = mysql_fetch_array($sql2))
{
$sname = inputvalid($res2['sname']);
$roll = inputvalid($res2['roll']);
$class = inputvalid($res2['class']);
echo "<tr>";
echo "<td class='tdhead2' valign='top'>$sname</td>";
echo "<td class='tdhead2' valign='top'>$roll</td>";
echo "<td class='tdhead2' valign='top'>$class</td>";
echo "<td class='tdhead2' valign='top'>";
//echo each radio with the counter for this row
echo "<input type='radio' name='ch_{$counter}[]' value='0' /> ";
echo "<input type='radio' name='ch_{$counter}[]' value='1' />";
echo "</td>";
echo "<td class='tdhead2' valign='top'> </td>";
echo "</tr>";
//add one to the counter
$counter++;
}
Please note, unless you do like I suggested above, you will not be able to know which student each radio group goes to. You can assume that the radio buttons on group row 1 belongs to the student in row 1, but you might not know which student is in row 1. Which is why I suggest you put a unique id that goes with each student with each radio button instead of a counter.
You can store a counter $count and increase it after each iteration. Or if you have some unique id from the database per row (for example the primary_key), you can use that instead.$id = $res['id']
Then concat that value to the name=ch".$id."...
you should use student name as an unique array and put that value in the name=""
and it will auto increment according to the name and you can only choose single option at single row.
try this :
<input type='radio' name='<?php echo $res2['sname'];?>' value='0' /> ";
<input type='radio' name='<?php echo $res2['sname'];?>' value='1' />";
this solutio will work.because it work's for me in an attendance system.

Categories