confirm dialog box in php - php

I have this echo statement:
echo "<td align=center style=border:0>"."<a href='?delete=$row[id]'>Delete</a>"."</td>";
how am I able to make that when I press the 'Delete' a yes no dialog box will appear?
I've read somewhere that it can add some thing like this somewhere in the statement:
onClick="javascript:return confirm(\'Are you sure you want to delete this record?\')"
Any help would be appreciated.
thanks in advance.

Try this:
echo "<td align=center style=border:0><a onclick='return confirm(\"Are you sure you want to delete this record?\")' href='?delete=$row[id]'>Delete</a></td>";
I got rid of the unnecessary "." in your original code.

Just Use this
echo "<td align=center style=border:0><a onclick='return confirm(\"Are you sure you want to delete this record?\")' href='?delete=$row[id]'>Delete</a></td>";
Instead of
echo "<td align=center style=border:0>"."<a href='?delete=$row[id]'>Delete</a>"."</td>";

Related

I upload videos into into directory and i want them to display horizontall when i echo them

I have these codes and am not good at php please can someone help me on how to echo the videos to appear horizontall in my page thanks in advance
<?php
$h=2;
$k=mysql_query("SELECT * from aupload where type='audios' and view>='$h' order by view DESC");
while ($la=mysql_fetch_array($k)){
?>
<center>
<table width='100%'height=''>
<tr>
<?php echo"<td>" . "<a href='uploads/$la[filename]'><img src='uploads/$la[size]' width='180px' height='180px'>
<br><b>$la[filename]</b><br><a href='music1.php?id=".$la['id']."'><input type='button' value='DOWNLOAD'><input type='button' value='$la[view]'> </a></a>
"?></td>
</tr>
</table><br>
</center>
<?php }?>
<?php
include('connect.php');
$k=mysql_query("SELECT * from aupload where type='audios'");
#$la=mysql_fetch_array($k)
?>
<?php
$h=2;
$y=mysql_query("SELECT * from aupload where type='videos' and view>='$h' order by view DESC ");
?>
<table border='0' id='myTable'width='100%'>
<?php
while ($x=mysql_fetch_array($y)){
echo "<tr>";
echo "<td>" . "<video id='myVideo' onclick='message()' width='180px' height='180px' controls><source src='uploads/$x[filename]' '></video>" . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='' height=''>"."<a href='music2.php?id=$x[id]' > <b>$x[filename]</b><br><input type='button' value='DOWNLOAD'></a>" ."<input type='button' value='$x[view]'></a></a>". "</td>";
echo "</tr>";
}
echo "</table>"; echo"</center>";
?>
the problem is when I upload two or more videos they appear vertically but I just want them to appear horizontally when echo them please someone help and thanks
Use frames is the best way to display a video, try this code
This is actually a HTML question, not a PHP question. In HTML, designates a table row, and can contain many or table cell elements. So you want to have the a echoed before the while loop, then print just the elements in the while loop, then print the . This will put all the elements in a single table row.

Toggle rows of a table inside while loop

I have a table with several buttons with "SHOW" text. Everytime I click one of those buttons I'd like that rows with class ".infotr" appears and when I click again the same button those rows disappear. (I mean the ".infotr" rows of the same table of the clicked button.)
<?php
$sql="SELECT * FROM mytable WHERE ID='$id'";
$res=mysqli_query($db,$sql);
while($row = mysqli_fetch_array($res))
{
echo "<table id='tablemodificamobile'>";
echo "<tr id='firsttr'>";
echo "<td id='amid' class='modificatd'>".$myid."</td>";
echo "<td id='amtitle' class='modificatd'>".$row['Title']."</td>";
echo "<td id='amshow' class='modificatd'><input type='button' id='mostramodbtn' value='SHOW'></input></td>";
echo "</tr>";
echo "<tr class='infotr'><td class='addinfo'>New Price: ".$row['NewPrice']."</td></tr>";
echo "<tr class='infotr'><td class='addinfo'>Old Price: ".$row['OldPrice']."</td></tr>";
echo "<tr class='infotr'><td class='addinfo'><input type='button' value='SAVE' id='modit'></input></td></tr>";
echo "</table>";
}
?>
This is what I tried but it doesn't work:
$('#mostramodbtn').click(function() {
$(this).parents("tr").nextAll().show();
});
Use this:
$(document).on('click','#mostramodbtn',function() {
$(this).parents("tr").nextAll().toggle("slow");
});
You are creating the element dynamically so you need to bind the even on document with .on function.
Learn more about .on() function in jQuery here.

Issue including page.php on page

I am trying to include a vbijreizen_kaart.php within some code. When I put it outside of the echo, but within the loop (i think this is correct terminology). It will load my google map, however, it will not bring back the rest of the results in my (while) results. When I remove it, the results appear, so I'm doing something wrong but I just don't know what.
The bit of code that is where I am having problems is:
$result = mysql_query($sql);
echo "<br />"; ?>
<?php include('vbijreizen_kaart.php');?>
<?php
echo "<table border='0' cellspacing='0'>
<tr>
<th width='20' valign='top'><div align='left'> </div></th>
</tr>
<tr>
<th height='1' colspan='9' valign='top' bgcolor='#333333'></th>
</tr>";
while($row = mysql_fetch_array($result)){
$row_color = ($row_count % 2) ? $color1 : $color2;
echo "<td bgcolor='$row_color'>" .date("d-M-Y H:i",
strtotime($row['vertrekdatum2'])). "</td>";
echo "<td bgcolor='$row_color'><img src='../flags/".$row['countryflag']."'>
<abbr title=\"".htmlspecialchars($row['luchthavennaam'])."\">
".$row['luchthavencode']."</abbr></td>";
echo "<td bgcolor='$row_color'><img src='../flags/".$row['countryflagaankomst']."'>
<abbr title=\"".htmlspecialchars($row['aankomstnaam'])."\">
".$row['aankomstluchthaven']."</abbr></td>";
I have tried doing just
echo "<br />";
echo include('vbijreizen_kaart.php');
echo " blah blah blah
and I've tried as above, and nothing will let me display the map that exits on vbijreizen_kaart.php as well as the data that would display in the while results.
I can verify in Toad that I have the Query working as it should.
include is not a method, so syntax can look like: include 'vbijreizen_kaart.php';, but that's not the problem. include basically allows you to access the classes, functions, and variables that are on the included page. You don't echo or print the included page itself, but rather the classes, functions, and any variables on the included page. Also, the included page can echo or print to the page you include it into, so it could be a matter of position.

PHP table and code in echo <td>

At this moment I am working on a WordPress website. To get the title of the site I am using the next code:
<div class="site-title"><?php bloginfo( 'name' ); ?></div>
Now I want to put this code/ the result of it in a php table cell, so:
echo "<td align='center' width='50%'>SITENAME</td>";
How can I implement/ use that php bloginfo code at the place where currently SITENAME is written?
Try like
echo "<td align='center' width='50%'>".bloginfo( 'name' )."</td>";
Just echo it like this
echo "<td align='center' width='50%'>".bloginfo( 'name' )."</td>";

dynamically created button hide in php

I have created button using this:
$i=1;
while($row=mysql_fetch_array($e))
{
echo '<td><img src="'.$path.$row['photo'].'" border="0" width=100 height=50/></td>';
echo $row['fname'];
echo "<input type=\"button\" value=\"send request\" name=\"$i\" onclick=\"sendreq('".$row['uname']."')\"/>";
//echo $i;
echo "<br/>";
$i=$i+1;
}
and passing the username onclick of the button through sendreq() function.This is javascript function. I just want to hide this button when sendreq() job is done.
You could use the javascript to assign is the display:none; CSS attribute, though I am uncertain whether it would have to be applied to an encapsulating div or whether it would work directly on the image itself.
$i=1;
while($row=mysql_fetch_array($e))
{
echo '<td><img src="'.$path.$row['photo'].'" border="0" width=100 height=50/>
</td>';
echo $row['fname'];
echo "<input id='btnSubmit' type=\"button\" value=\"send request\" name=\"$i\"
onclick=\"sendreq('".$row['uname']."');
document.GetElementById('btnSubmit').hide(); \"/>";
//echo $i;
echo "<br/>";
$i=$i+1;
}
after the method is executed, the element will hide.
you can add this line at the end of the function.
<script>
jQuery("#btnSubmit").hide();
</script>
hope this helps...
edit your input button tag like this
assign a id to button (such as i used remove as id here) and add this code on last of the function sendreg
document.getElementById("remove").style.display='none';
or use jquery functions like
$("#remove").hide();
or $("#remove").fadeOut(3000);

Categories