I have a simple HTML file. In this HTML file I have a table with rows and columns. In another PHP file. I have a code that takes my bank info MYSQL information Now I am trying to send from the first HTML file to PHP. Every tag has an attribute. Home and guest. Send 2 VAR to PHP and then load the PHP page with the information I sent. Now I ask you. Is my method correct? Is there any other way to do it? Thank you very much to everyone who read all the code. And trying to help me.
HTML
$("th").click(function() {
var home = $(this).attr("home");
var guest = $(this).attr("guest");
$.post("getBetsTeam.php", {
home: home,
guest: guest
})
.done(function(response) {
$("#controler").html(response);
});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<table>
<tbody>
<tr>
<th class="without" home="Liverpool" guest="Bolton">Liverpool-Bolton</th>
<td>3.3</td>
<td>2.5</td>
<td>2.8</td>
</tr>
<tr>
<th class="without" home="manchster united" guest="newcasel">manchster united-newcasel</th>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</tbody>
</table>
PHP
<?php $link = mysqli_connect('localhost', 'root', '');
mysqli_select_db($link,'bet369');
if(!link){
//echo "connection to db feild!";
}else{
//echo "conection succesful!!! </br>";
}
if(mysqli_select_db($link,'bet369')){
//echo "db selected! <br>";
} ?>
<?php
$fr = 'Fulltime Result';
$home = $_POST['home'];
$guest = $_POST['guest'];
$res = mysqli_query($link,"select * from bets where line='$fr' and home='$home' and guest='$guest'");
$rows =mysqli_fetch_row($res);
if ($rows[0] == 0) {
die;
}
else{
$res = mysqli_query($link,"select * from bets where line='$fr'");
//if ($rows[0] == 1) {
echo '
<div class="headBets" style="color:white; with:100%; text-align: center; background-color: #0c15d2;">Fulltime Result</div>
<table>';
while($row=mysqli_fetch_array($res))
{
echo '<tr>';
//echo '<th class="without">'; echo $row[home] . '-' . $row[guest]; echo '</th>';
echo '<td class="with" cheak="0" idbet="'.$row[idbet].'"numid="'. $row[idbet].'AAbet" a="0" b="0" c="0" d="0" e="0" f="0" z="1" value="'.$row[bethome].'"'.'team="'.$row[home].' v '.$row[guest].'"choice="'.$row[home].'"liga="'.$row[liga].'"line="'.$row[line].'">'.$row[home]. " ".$row[bethome].'</td>';
echo '<td class="with" cheak="0" idbet="'.$row[idbet].'"numid="'. $row[idbet].'XXbet" a="0" b="0" c="0" d="0" e="0" f="0" z="x" value="'.$row[betdraw].'"'.'team="'.$row[home].' v '.$row[guest].'"choice="'.$row[draw].'"liga="'.$row[liga].'"line="'.$row[line].'">'.$row[draw]. " ".$row[betdraw].'</td>';
echo '<td class="with" cheak="0" idbet="'.$row[idbet].'"numid="'. $row[idbet].'BBbet" a="0" b="0" c="0" d="0" e="0" f="0" z="2" value="'.$row[betguest].'"'.'team="'.$row[home].' v '.$row[guest].'"choice="'.$row[guest].'"liga="'.$row[liga].'"line="'.$row[line].'">'.$row[guest]. " ".$row[betguest].'</td>';
echo '</tr>';
////////////////////////////////////////////////////////////////////////////////////
}
if(mysqli_query){
//echo "all data reload !";
}
echo '</table>';
// }
}
?>
</div>