Longtime reader of stackoverflow but second question.
This is what i am doing
echo "<td><a href = 'http://localhost/map/index.php'
value='$id' >Delete</a></td>";
This is what we do when we use submit button
<?php
echo "<body style='background-color:gray'>";
if (isset ($_POST['submit'])){
include("connection.php");
echo " <table id='t01' border='20px solid black' width='100%' >";
echo "<tr>";
echo "<th> DETAILS ABOUT DELETION</th>";
echo "<td>DELETED SUCCESSFULLY </td></tr>";
$id = $_POST["submit"];
$select1="DELETE FROM app where id='$id'";
$result = $conn->query($select1);
if ($conn->query($result)==true){
echo "<td>DELETED SUCCESSFULLY </td></tr>";
}
echo "</table>";
//echo "DELETED SUCCESSFULLY";
}
?>
I just want to do something like that * without using input type=submit* ..... But dont know how to do
Any advice will be appreciated ... Thanks in advance
firstly pass the id in the url like so:
echo "<td><a href = 'http://localhost/map/index.php?id=$id'>Delete</a><td>";
then check it with:
if (isset ($_GET['id'])){
...
you basically swapping POST for GET
Related
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.
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.
I am a newbie to PHP and MySQL, so please ignore my bad practice of coding :)
Ok, here's the scenario:
I have a page, checkin.php which has two forms;
Form 1: Takes some input and displays data from database along with multiple checkboxes.
Form 2: It is dynamically generated if any data is found above.
Here's the code:
//Echoing out the query results
echo "<form method='POST' action='checkin.php'>";
echo "<tbody>";
foreach ($checkin_status as $row) {
echo "$rowStart";
echo "$row[book_id]";
echo "$insertColumn";
echo "$row[branch_id]";
echo "$insertColumn";
echo "$row[card_no]";
echo "$insertColumn";
echo "$row[fname]" . " " . "$row[lname]";
echo "$insertColumn";
echo "$row[date_out]";
echo "$insertColumn";
echo "$row[due_date]";
echo "$insertColumn";
//Checkbox creation
$checkin_recall_value = "$row[book_id]" . " " . "$row[branch_id]" . " " . "$row[card_no]";
echo "<div style='text-align: center;'><input type='checkbox' name='checkin' value='$checkin_recall_value'></div>";
echo "$rowEnd";
}
echo "</tbody>";
//Checkin button in foot
echo "<tfoot>";
echo "<td colspan='7' style='text-align: center; padding-right: 20px;'><input id='checkin_button' type='submit' value='Check In' title='Click to check in!'></td>";
echo "</tfoot>";
echo "</form>";
The form is generated with checkboxes along side the returned tuples.
Now when I am selecting some checkboxes and trying to display, it WONT...
Here is the code:
if(!empty($_POST['checkin'])) {
//Retrieving the recall variables as an array from POST and assigning to $main_array
$main_array = array();
//echo "I am here";
if(is_array($_POST['checkin'])) {
foreach($_POST['checkin'] as $value)
{
$sub_array = explode(" ", $value);
array_push($main_array, $sub_array);
}
}
print_r($main_array);
}
Its returning an empty array...
Please help me fix this.
IF you want to have multiple html elements with the same name, you must define it as an array, adding []:
<input type='checkbox' name='checkin[]' value='$checkin_recall_value'>
I'm not sure about the title, I tried my best.
I have a table displayed with information from a database using this file
display.php
<?php
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("tournaments") or die(mysql_error());
$result = mysql_query("SELECT * FROM tournies")
or die(mysql_error());
echo '<table id="bets" class="tablesorter" cellspacing="0" summary="Datapass">
<thead>
<tr>
<th>Tournament <br> Name</th>
<th>Pot</th>
<th>Maximum <br> Players</th>
<th>Minimum <br> Players</th>
<th>Host</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>';
while($row = mysql_fetch_array( $result )) {
$i=0; if( $i % 2 == 0 ) {
$class = "";
} else {
$class = "";
}
echo "<tr" . $class . "><td>";
echo $row['tour_name'];
$tour_id = $row['tour_name'];
echo "</td><td>";
echo $row['pot']," Tokens";
echo "</td><td class=\"BR\">";
echo $row['max_players']," Players";
echo "</td><td class=\"BR\">";
echo $row['min_players']," Players";
echo "</td><td class=\"BR\">";
echo $row['host'];
echo "</td><td>";
echo "<input id=\"delete_button\" type=\"button\" value=\"Delete Row\" onClick=\"SomeDeleteRowFunction(this)\">";
echo "</td><td>";
echo "<form action=\"join.php?name=$name\" method=\"POST\" >";
echo "<input id=\"join_button\" type=\"submit\" value=\"Join\">";
echo "</td></tr>";
}
echo "</tbody></table>";
?>
Basically I want the user to press a button from a row of the table and they go to a new page called join.php. I need the persons username and the name of the tournament from the row the clicked.
For example here's my page:
When they click the join button at the end of row one it should send them to
'join.php?name=thierusernamehere&tourname=dfgdds'
Any help much appreciated. Thanks.
echo '<td>Join</td>'
There are many way to approach.
The easiest way is just echo 'JOIN';
or you can use a form with hidden input and submit button.
BUT
Your code is really a mess, try to make your code more maintainable and readable. And do NOT use any mysql_* functions, they are deprecated.
Read more about PDO:
http://php.net/manual/en/book.pdo.php
http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/
I am trying to get images from my server via php and I want to have onClick functionality but it is not working following is my code sample:
<?php
$conn = ftp_connect("myserver") or die("Could not connect");
ftp_login($conn,"username","password");
$images = ftp_nlist($conn,"folder");
$r = count($images);
for($i=0;$i<$r;$i++)
{
//echo " $images[$i] ";
echo"<img id= '$i' class = '' border='1' src='mysource' width='300' height='250'>";
echo "<button onClick= 'hide()'> Print </button>";
echo "<button> Email </button>";
echo "<button> Text Me </button>";
echo "</br>";
}
ftp_close($conn);
?>
and following is my javascript code
function hide()
{
var t = document.getElementById(x);
t.setAttribute(class, print);
}
when I click my print button it is not even calling that function by the way this all is in .php file. Thanks for ay help.
→ Try This:
echo "<script type='text/javascript'>function hide_it(){alert('Entering Function hide_it()?'); /*var t = document.getElementById(x); t.setAttribute(class, print);*/}</script>";
for($i=0;$i<$r;$i++)
{
//echo " $images[$i] ";
echo"<img id= '$i' class = '' border='1' src='mysource' width='300' height='250'>";
echo "<button type='button' onclick='javascript:hide_it()'> Print </button>";
echo "<button> Email </button>";
echo "<button> Text Me </button>";
echo "</br>";
}