I want to show a hidden div when I mouse over a link on my table cell. The event only fires up on the first row. This is what i did:
$(document).ready(function(){
$("#show_div").mouseover(function() {
$("#hello").css('visibility', 'visible');
});
$("#hello").mouseover(function() {
$("#hello").css('visibility', 'visible');
});
$("#hello").mouseout(function() {
$("#hello").css('visibility', 'hidden');
});
});
<form action="" method="post">
<table class="table table-bordered table-hover">
<div id="bulkOptionContainer" class="col-xs-4">
<select class="form-control" name="bulk_options" id="">
<option value="">Select Option</option>
<option value="publish">Publish</option>
<option value="draft">Draft</option>
<option value="delete">Delete</option>
</select>
</div>
<div class="col-xs-4">
<input class="btn btn-success" type="submit" name="submit" value="Apply"/>
<a class="btn btn-primary" href="posts.php?source=add_post">Add New</a>
</div>
<thead>
<tr>
<th><input type="checkbox" name="checkbox[]" id="selectAllCheckBoxes"></th>
<th>Id</th>
<th>Author</th>
<th scope="col">Title</th>
<th>Category</th>
<th>Status</th>
<th>Image</th>
<th>Tags</th>
<th>Comments</th>
<th>Date</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php $query = "SELECT * FROM post ORDER BY post_id DESC";
$result_set = mysqli_query($link, $query);
confirm_query($result_set);
while ($row = mysqli_fetch_assoc($result_set)):?>
<tr>
<td><label><input type="checkbox" class="checkBoxes" name="checkBoxArray[]"
value="<?php echo $row['post_id']; ?>"></label></td>
<td><?php echo $row['post_id'] ?></td>
<td><?php echo $row['post_author'] ?></td>
<td width="100%">
<!-- link to over-->
<a id="show_div"
href="../post.php?p_id=<?php echo $row['post_id'] ?>"><?php echo $row['post_title'] ?></a>
<!-- div to become visible on hover-->
<div id="hello" style="visibility:hidden;">
<p>post</p>
</div>
</td>
<td><?php echo sel_cat_byId($row['post_category_id']) ?></td>
<td><?php echo $row['post_status'] ?></td>
<td><img width="100" class="img-responsive" src="../images/<?php echo $row['post_image'] ?>"></td>
<td><?php echo $row['post_tag'] ?></td>
<td><?php echo $row['post_comment_count']; ?></td>
<td><?php echo $row['post_date'] ?></td>
<td><a class="btn btn-danger" href="posts.php?delete=<?php echo $row['post_id']; ?> "
onclick="alert('Are You Sure?')">Delete</a></td>
</td>
<td><a class="btn btn-success" href="posts.php?source=edit_post&edit=<?php echo $row['post_id']; ?>">Edit</a>
</td>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</form>
****the event only fires up on the first row.
Thanks
First replace your id with class and then try this
$(".show_div").mouseover(function() {
$(this).next(".hello").css('visibility', 'visible');
});
$(".show_div").mouseout(function() {
$(this).next(".hello").css('visibility', 'hidden');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<a class="show_div"
href="#">abc</a>
<!-- div to become visible on hover-->
<div class="hello" style="visibility:hidden;">
<p>post</p>
</div>
Related
I have a table reading out a few columns of a db, with an edit button in each row. All I am trying to do is, when the edit button is clicked, that row is displayed with all of its columns in another page. Any help would be great. I know it's simple, but I can get it to work. I am able to navigate to the next page, but not sure how to carry the id of the specific row and read that out. Thanks.
index. php
<form id="mainform" action="editFunding2.php">
<div class='row'>
<div class='col-12'>
<div class='table table-responsive'>
<table class='table table-striped table-bordered datatable active' id='grantTable'>
<thead>
<tr>
<th>FP ID</th>
<th>Short Title</th>
<th>PI</th>
<th>Department</th>
<th>Funding Type</th>
<th>Change Funding Type</th>
</tr>
</thead>
<tbody>
<?php
//Foreach loop iterates through each column of $getallrows function
foreach($allRows as $rowID => $rowInfo){ ?>
<tr>
<td><?php echo $rowInfo['fpID'];?></td>
<td><?php echo $rowInfo['shortTitle'];?></td>
<td><?php echo $rowInfo['PI'];?></td>
<td><?php echo $rowInfo['Department'];?></td>
<td><?php echo $rowInfo['fundingType'];?></td>
<!--Create dynamic id -->
<?php $rdDrop = "ddgrantType_".$rowInfo['fpID'];?>
<td>
<button type="submit" class="btn btn-danger" name="action" value='Change Funding Type'>Change Funding</button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</form>
My editFunding2.php page
<div class='row'>
<div class='col-12'>
<div class='table table-responsive'>
<table class='table table-striped table-bordered datatable active' id='grantTable'>
<thead>
<tr>
<th>FP ID</th>
<th>Short Title</th>
<th>PI</th>
<th>Department</th>
<th>Division</th>
<th>Sponsor Name</th>
<th>Project Start</th>
<th>Project End</th>
<th>Funding Type</th>
<th>Yes/No</th>
<th>Proper Type If No</th>
<!-- <th>Exclusions</th>
<th>FP Durtation</th> -->
<th>Comment</th>
</tr>
</thead>
<tbody>
<?php
session_start();
$editRow = $_REQUEST['fpID'];
$mssql = mysqli_query("SELECT * FROM spacing.METADATA_WEBFORM WHERE FUNDING_PROPOSAL_ID = $fpID' ") or die (mysqli_error());
while($rowInfo = mysqli_fetch_array($mssql)) {
?>
<tr>
<td><?php echo $rowInfo['fpID'];?></td>
<td><?php echo $rowInfo['shortTitle'];?></td>
<td><?php echo $rowInfo['PI'];?></td>
<td><?php echo $rowInfo['Department'];?></td>
<td><?php echo $rowInfo['Division'];?></td>
<td><?php echo $rowInfo['sponsorName'];?></td>
<td><?php echo $rowInfo['Date_Project_Start']->format('Y-m-d');?></td>
<td><?php echo $rowInfo['Date_Project_End']->format('Y-m-d');?></td>
<td><?php echo $rowInfo['fundingType'];?></td>
<?php } ?>
<!--Create dynamic id -->
<?php $rdDrop = "ddgrantType_".$rowInfo['fpID'];?>
<td>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class='form-check-input' name="rdGrant[<?php echo $rowInfo['fpID'];?>]" value="Yes" id="rdYes" onclick="disable('<?php echo $rdDrop;?>')" checked/> Yes
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class='form-check-input' type="radio" name="rdGrant[<?php echo $rowInfo['fpID'];?>]" value="No" id="rdNo" onclick="enable('<?php echo $rdDrop;?>')"/> No
</label>
</div>
</td>
<td>
<div class="dropdown">
<select class='form-control' name="ddgrantGroup[<?php echo $rowInfo['fpID'];?>]" id="<?php echo $rdDrop;?>" disabled>
<option value=''>Select Proper Funding Type</option>
<option value="Corporate Sponsor">Corporate Sponsor</option>
<option value="Federal">Federal</option>
<option value="Foundation Selected">Foundation Selected</option>
<option value="Internally Funded">Internally Funded</option>
<option value="State/Local">State/Local</option>
</select>
</div>
</td>
<td>
<div class="comment">
<textarea class="form-control" aria-label="With textarea" name="grantComment[<?php echo $rowInfo['fpID'];?>]" id="grantComment" placeholder="Comments"></textarea>
</div>
</td>
</tr>
</tbody>
</div>
</div>
</div>
<div class='row'>
<div class='col-12 text-right'>
<button type="submit" class="btn btn-secondary formsubmitbttn" name="action" value='save'>Save</button>
<button type="submit" class="btn btn-primary formsubmitbttn" name="action" value='complete'>Complete and Save</button>
</div>
</div>
</div>
Change your button to a
My Link to xx
In editFunding2.php :
$editRow = $_GET['id'];
I have a page where users can view the leave applications they submitted and they can also cancel the application, here's what it looks like:
I wanted to get rid of the cancel button after it was cancelled or after it was clicked. So I added a remove button script in the execution code. Apparently, it was wrong. Everything worked fine until I added the script in the execution code.
Here's my form:
HTML+PHP
<div class="container">
<div class="page-header">
<h3>My Leaves</h3>
<div class="table-responsive">
<table class="table">
<tr>
<th>Employee Name</th>
<th>Phone</th>
<th>Email</th>
<th>From</th>
<th>To</th>
<th>Reason</th>
<th>Type</th>
<th>Status</th>
</tr>
<?php
include ('database.php');
$result = $database->prepare ("SELECT leaves.* FROM leaves INNER JOIN employee ON employee.id = leaves.user_id WHERE employee.username = '".$_SESSION["VALID_USER_ID"]."'");
$result ->execute();
for ($count=0; $row_message = $result ->fetch(); $count++){
?>
<tr>
<td><?php echo $row_message['firstname']." " .$row_message['lastname']; ?></td>
<td><?php echo $row_message['phone']; ?></td>
<td><?php echo $row_message['email']; ?></td>
<td><?php echo $row_message['fromdate']; ?></td>
<td><?php echo $row_message['todate']; ?></td>
<td><?php echo $row_message['reason']; ?></td>
<td><?php echo $row_message['type']; ?></td>
<td><?php echo $row_message['status']; ?></td>
<td>
<form method="post" action="update-leave-status-emp.php">
<input type="hidden" name="leaveno" value="<?php echo $row_message['leaveno']; ?>" />
<input type="submit" value="Cancelled" class="removebtn" name="cancelled"></input>
</form>
</td>
</tr>
<?php }?>
</table>
<a href="employee_panel.php">
<button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-arrow-left"></i> Back</button>
</a>
</div>
</div>
</div>
Execution Code:
<?php
if(isset($_POST['cancelled'])){
$msg = "Cancelled";
$status=$_POST['cancelled'];
echo "<script>
$(document).ready(function(){
$(".removebtn").click(function(){
$(this).remove();
});
});
</script>";
}
$leaveno=$_POST['leaveno'];
$con = mysqli_connect('localhost', 'root', '');
mysqli_select_db($con, 'companydb');
$sql = "UPDATE leaves SET status = '$status' WHERE leaveno = '$leaveno'";
if(mysqli_query($con, $sql))header("refresh:1; url=view-leave-emp.php?msg=$msg");
else var_dump(mysqli_error($con));
?>
PS: I know my codes are vulnerable to injections, I will change it eventually, for now, I have to figure this out.
Enclosed cancelled button in an if statement that if the record is marked cancelled the button won't be shown anymore.
You can try this updated code:
<div class="container">
<div class="page-header">
<h3>My Leaves</h3>
<div class="table-responsive">
<table class="table">
<tr>
<th>Employee Name</th>
<th>Phone</th>
<th>Email</th>
<th>From</th>
<th>To</th>
<th>Reason</th>
<th>Type</th>
<th>Status</th>
</tr>
<?php
include ('database.php');
$result = $database->prepare ("SELECT leaves.* FROM leaves INNER JOIN employee ON employee.id = leaves.user_id WHERE employee.username = '".$_SESSION["VALID_USER_ID"]."'");
$result ->execute();
for ($count=0; $row_message = $result ->fetch(); $count++){
?>
<tr>
<td><?php echo $row_message['firstname']." " .$row_message['lastname']; ?></td>
<td><?php echo $row_message['phone']; ?></td>
<td><?php echo $row_message['email']; ?></td>
<td><?php echo $row_message['fromdate']; ?></td>
<td><?php echo $row_message['todate']; ?></td>
<td><?php echo $row_message['reason']; ?></td>
<td><?php echo $row_message['type']; ?></td>
<td><?php echo $row_message['status']; ?></td>
<td>
<form method="post" action="update-leave-status-emp.php">
<input type="hidden" name="leaveno" value="<?php echo $row_message['leaveno']; ?>" />
<?php if( $row_message['status'] != "Cancelled" ) {
<input type="submit" value="Cancelled" class="removebtn" name="cancelled"></input>
<?php } ?>
</form>
</td>
</tr>
<?php }?>
</table>
<a href="employee_panel.php">
<button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-arrow-left"></i> Back</button>
</a>
</div>
</div>
</div>
Our Wordpress site are infected and we are deleted all files. we have now only database and want to extract all information from db and afther this copy on other site.
so I am using this php class to connect db and call some information. I am calling now posts with data, but need categories also.
For example:
Post Title, Post Content, Post Category
here is my working code without category names
$posts = $db->get('c3624322676f_wp_posts');
but I have no idea how to call categories names here.
This is my html + foreach
<table class="table table-hover">
<thead class="thead-inverse">
<tr>
<th>#</th>
<th>Title</th>
<th>Type</th>
<th>Content</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $post) : ?>
<tr>
<th scope="row"><?php echo $count++; ?><a href=""></th>
<td><?php echo $post['post_title']; ?></td>
<td><?php echo $post['post_type']; ?></td>
<td><?php echo strip_tags ($post['post_content']); ?></td>
<td>
<form action="" method="post">
<input type="hidden" name="id" value="<?php echo $post['ID']; ?>" />
<input style="cursor:pointer;" type="submit" class="btn btn-primary" value="Delete" />
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
This should work
<table class="table table-hover">
<thead class="thead-inverse">
<tr>
<th>#</th>
<th>Title</th>
<th>Type</th>
<th>Content</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($posts as $post) : ?>
<tr>
<th scope="row"><?php echo $count++; ?><a href=""></th>
<td><?php echo $post['post_title']; ?></td>
<td><?php echo $post['post_type']; ?></td>
<td><?php echo strip_tags ($post['post_content']); ?></td>
<?php
$separator = ',';
$output = '';
$categories = get_the_category($post['post_title']);
if ($categories){
foreach($categories as $category) {
$output .= ''.$category->cat_name.''.$separator;
}
echo trim($output, $separator);
}
?>
<td>
<form action="" method="post">
<input type="hidden" name="id" value="<?php echo $post['ID']; ?>" />
<input style="cursor:pointer;" type="submit" class="btn btn-primary" value="Delete" />
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
First I will tell what I want to achieve, and then I will explain how I was trying to do it.
I have two tables, one stores type of vessels with a description and their own Id. Then I have another table in wich the vessel type has been stored as text. My goal is to select each one (both records in both tables) with a checkbox in both and store in the table 2 the Id from the table 1.
I will introduce data, to help.
Table 1
1|Balandra|Some description
2|Bergantin|Some description
3|Whatever |Whatever.....
Table2
Balandra
Bergantin
Whatever
Then, I have created a php page that shows both tables with the checkbox I mentioned above. Checkboxes store the Table1 Id and Table2 vesseltypename.
<table class="table table-striped table-bordered table-list">
<thead>
<tr>
<th><em class="fa fa-cog"></em></th>
<th class="hidden-xs">idtiponavio</th>
<th>Tipo de Navío</th>
<th>Descripción</th>
<th>Agrupar</th>
</tr>
</thead>
<tbody>
<?php foreach ($naviosdyncoop as $key => $navio) { ?>
<tr>
<td align="center">
<a href=<?php echo '../vista/modificar.php?id=' .
$navio['idtiponavio']; ?> class="btn btn-default"><em class="fa fa-
pencil"></em></a>
<a href=<?php echo '../datos/borrar.php?id=' .
$navio['idtiponavio']; ?> class="btn btn-default"><em class="fa fa-
trash"></em></a>
</td>
<td class="hidden-xs"><?php echo
$navio['idtiponavio']; ?></td>
<td><?php echo $navio['tiponavio']; ?></td>
<td><?php echo $navio['descripcion']; ?></td>
<td><input type="checkbox" name="agruparid" value=<?
php echo $navio['idtiponavio']; ?> /></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<div class="panel-body paneltodo">
<table class="table table-striped table-bordered table-list">
<thead>
<tr>
<th><em class="fa fa-cog"></em></th>
<th>Tipo de Navío</th>
<th>Agrupar</th>
</tr>
</thead>
<tbody>
<?php foreach ($naviosforsea as $key => $navio) { ?>
<tr>
<td align="center">
<em class="fa fa-arrow-circle-o-left"></em>
</td>
<td><?php echo $navio['typevessel']; ?></td>
<td><input type="checkbox" name="agruparvessel" value=<?php echo $navio['typevessel']; ?> /></td>
</tr>
<?php } ?>
</tbody>
</table>
So, I want to check both table records and store the table1 Id in the table2 idtypevessel field.
I thought that a php file could store both items and call the update function with those parameters, like this:
<?php
require './modelo.php';
$idnavio = $_GET['agruparid'];
$vessel = $_GET['agruparvessel'];
Any suggestions, because I think I have to do a button to submit this parameters, but it must be working on both tables, and I don't know how to access both foreach loop at the same time.
Thanks in advance.
E. Salas
review bellow reference code to submit multi selected checkbox values
for multi selected checkbox submission you must use [] operator after name attribute in html
index.php
<form action="/checkbox.php" method="post">
<strong>Cars:</strong><br>
<?php
$cars = array("Volvo", "BMW", "Toyota");
$colors = array("Red", "Green", "Black");
foreach($cars as $single){
?>
<input type="checkbox" name="cars[]" value="<?php echo $single; ?>">
<?php
}
<br>
<strong>colors:</strong><br>
foreach($colors as $single){
?>
<input type="checkbox" name="colors[]" value="<?php echo $single; ?>">
<?php
}
?>
<br>
<input type="submit" value="Submit!">
</form>
checkbox.php
<?php
echo "<pre>";
var_dump($_POST);
exit;
In your case:
<form action="/checkbox.php" method="post">
<div class="col-md-6">
<div class="panel-body">
<table class="table table-striped table-bordered table-list">
<thead>
<tr>
<th><em class="fa fa-cog"></em></th>
<th class="hidden-xs">idtiponavio</th>
<th>Tipo de Navío</th>
<th>Descripción</th>
<th>Agrupar</th>
</tr>
</thead>
<tbody>
<?php foreach ($naviosdyncoop as $key => $navio) { ?>
<tr>
<td align="center">
<em class="fa fa-pencil"></em>
<em class="fa fa-trash"></em>
</td>
<td class="hidden-xs"><?php echo $navio['idtiponavio']; ?></td>
<td><?php echo $navio['tiponavio']; ?></td>
<td><?php echo $navio['descripcion']; ?></td>
<td><input type="checkbox" name="agruparid[]" value=<?php echo $navio['idtiponavio']; ?> /></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<div class="panel-body">
<table class="table table-striped table-bordered table-list">
<thead>
<tr>
<th><em class="fa fa-cog"></em></th>
<th>Tipo de Navío</th>
<th>Agrupar</th>
</tr>
</thead>
<tbody>
<?php foreach ($naviosforsea as $key => $navio) { ?>
<tr>
<td align="center">
<em class="fa fa-arrow-circle-o-left"></em>
</td>
<td><?php echo $navio['typevessel']; ?></td>
<td><input type="checkbox" name="agruparvessel[]" value=<?php echo $navio['typevessel']; ?> /></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<input type="submit" value="Submit!">
</form>
Finally I solved this with Javascript. One of my partners helped me, I post this to help people in my situation.
I created a script, here is the code:
<script type="text/javascript">
function cogeNavioDyncoopnet(){
var checkedValueNavioD = null;
var inputElements = document.getElementsByClassName('checknaviod');
for(var i=0; inputElements[i]; ++i){
if(inputElements[i].checked){
checkedValueNavioD = inputElements[i].value;
break;
}
}//return checkedValueNavioD;
var input_nav_dyn = document.getElementById("nav_dyn");
input_nav_dyn.value = checkedValueNavioD;
}
function cogeNavioForSea(){
var checkedValueNavioFs = null;
var inputElements = document.getElementsByClassName('checknaviofs');
for(var i=0; inputElements[i]; ++i){
if(inputElements[i].checked){
checkedValueNavioFs = inputElements[i].value;
break;
}
}//return checkedValueNavioFs;
var input_nav_fs = document.getElementById("nav_fs");
input_nav_fs.value = checkedValueNavioFs;
}
</script>
Then I created a Form below, that collects values and sends them to my .php control file.
<div class="hidden-xs">
<form class="hidden-xs" method="POST"
action="../datos/actualizarnavios.php">
<input id="nav_dyn" type="text" name="idnaviodyncoop">
<input id="nav_fs" type="text" name="navioforsea" >
<input id="botonasignar" type="submit" name="enviardatosdynfs">
</form>
</div>
I hope this helps. Thanks for the feedback, as always.
I have a table that I have to populate him with a query result. One of the rows is the name of the group. My result3 inside the while is a query where I get the name of the group. I want to put that name in each row. But for some reason I can only get the first position of the query result. Can you help me?
This is my result3 variable query(in a resumed way):
$sql3 = "SELECT * from titulogrupo where idutilizador ={$_SESSION['id_utilizador']}";
$result3 = mysqli_query(mysqli_connect(", "u518178166_serra"), $sql3);...etc etc...
<table table id= "myTable" class="table table-hover"> <br>
<thead>
<tr>
<th>Os meus Chips</th>
<th>NIF</th>
<th>Marca de Exploracao</th>
<th>Marca do Auricular</th>
<th>Data de Nascimento</th>
<th>Observacoes</th>
<th>Estado</th>
<th>Data1</th>
<th>Data2</th>
<th>Data3</th>
</tr>
</thead>
<?php
while ($row = mysqli_fetch_array($result)){
?>
<tr>
<td><?php echo $row['numerochip'];?><input style="float: left; margin: 0 5px;" type="checkbox" value="<?php echo $row['numerochip']; ?>" name="numero[]" id="numero"></td>
<td><?php echo $row['NIF']; ?></td>
<td><?php echo $row['MarcaExploracao']; ?> </td>
<td><?php echo $row['MarcaAuricular']; ?> </td>
<td><?php echo $row['Data_Nascimento']; ?> </td>
<td><?php echo $row['observacoes'];?>
<div class="w3-container" id="....kli..">
<input style="display: none; type="text" id="numerochipescondido" name="numerochipescondido" value="<?php echo $row['numerochip']; ?>">
<input style="display: none; type="text" id="observacoesescondido" name="observacoesescondido" value="<?php echo $row['observacoes']; ?>">
<input style="display: none; type="text" id="idutilizadorescondido" name="idutilizadorescondido" value="<?php echo $_SESSION['id_utilizador']; ?>">
<center>
<button type="button" id="<?php echo $row['numerochip']; ?>" onclick="document.getElementById('id111').style.display='block'" class="glyphicon glyphicon-pencil changeobervations" width:50px height:50px;"></button>
</center>
</div>
</td>
<td>
<?php
if($row['velha']){
echo 'Velha ';
}
if($row['prenha']){
echo 'Prenha ';
}
if($row['refugo']){
echo 'Refugo ';
}
if($row['grupo4']){
while ($row = mysqli_fetch_array($result3)){
echo $row['titulogrupo'];
}
}
?>
</td>
<td><?php echo $row['Data1']; ?> </td>
<td><?php echo $row['Data2']; ?> </td>
<td><?php echo $row['Data3']; ?> </td>
</tr>
<?php } ?>
</table>
<br>
<input type="submit" class="btn btn-warning"name="submit_x" value="Submeter Lista de Animais a Encontrar(Individual)"> <br> <br>
<input type="submit" class="btn btn-danger"name="submit_y" value="Eliminar Animais Selecionados(Individual)"> <br> <br>
<form action="deletedb.php" method="post">
<input type="submit" class="btn btn-danger"name="submit_d" value="Apagar a minha lista total">
</form>
</form>
<br>
</br>
<table class="table table-hover" style="width:300px">
<thead>
<tr>
<th>Os meus Chips a encontrar</th>
</tr>
</thead>
<?php
while ($row = mysqli_fetch_array($result2)){
?>
<tr>
<td><?php echo $row['ovelhas'];?></td>
</tr>
<?php } ?>
<!-- Começa aqui o apagar -->
<form action="apagarOvelhasEncontrar2.php" method="post">
<br>
<tr>
<td>
<button type="submit" name="submit_x" class="btn btn-danger">Apagar Ovelhas a Encontrar</button>
</td>
</tr>
</form>
</table>
</br>
</div>
Use a different variable when fetching $result3 etc.
if($row['grupo4']){
while ($row3 = mysqli_fetch_array($result3)){
echo $row3['titulogrupo'];
}