Как передать кнопку HTML / PHP для выполнения запроса MYSQL

Привет, ребята, извините, если мои предыдущие вопросы недостаточно ясны, но мне пришло в голову, что моя настоящая проблема в том, что я не могу пропустить событие нажатия кнопки, чтобы выполнить запрос MYSQL.

Вот моя кнопка, которая должна быть нажата, чтобы выполнить запрос

<form action="invoice.php" method="post">
<input type='submit' name='hehe' />
</form>

Затем рассмотрите, я установил соединение с базой данных, вот код, который я хочу сделать, но он ничего не делает, когда нажимается кнопка хе-хе

if(isset($_POST['hehe'])){
$result=mysql_query("SELECT a.id, a.name, s.descc, a.phone, a.start, a.end, a.price
from wp_app_appointments a
LEFT JOIN wp_app_services s
ON a.id=s.id
WHERE a.status ='confirmed'
order by a.name
");
}

Тогда я хочу, чтобы это отображалось здесь.

while($test = mysql_fetch_array($result))

{
if (mysql_num_rows($result)!=0)
{
$id = $test['id'];
echo "<tr align='center'>";
/*echo"<td><font color='black'>" .$test['id']."</font></td>";*/
echo"<td style='width:200px'></td>";
echo"<td style='width:500px'>" .$test['name']."</td>";
echo"<td style='width:200px'>". $test['descc']. "</td>";
echo"<td style='width:200px'>". $test['phone']. "</td>";
echo"<td style='width:200px'>". $test['start']. "</td>";
echo"<td style='width:200px'>". $test['end']. "</td>";
echo"<td style='width:200px'>". $test['price']. "</td>";
echo"<td style='width:200px'> <a href ='print.php.?id=$id' target=_blank >Print</a>";
echo"<td style='width:100px'></td>";
echo "</tr>";

}
}

Извините за предыдущие вопросы.

0

Решение

<form action="invoice.php" method="post">
<input type='submit' name='hehe' />
</form>
<?php
if(isset($_POST['hehe']))
{
$result=mysqli_query($con, "SELECT a.id, a.name, s.descc, a.phone, a.start, a.end, a.price
from wp_app_appointments a
LEFT JOIN wp_app_services s
ON a.id=s.id
WHERE a.status ='confirmed'
order by a.name
");
if(mysqli_num_rows($result)!=0)
{
while($test = mysqli_fetch_array($result))
{
$id = $test['id'];
echo "<tr align='center'>";
echo "<td style='width:200px'></td>";
echo "<td style='width:500px'>".$test['name']."</td>";
echo "<td style='width:200px'>". $test['descc']. "</td>";
echo "<td style='width:200px'>". $test['phone']. "</td>";
echo "<td style='width:200px'>". $test['start']. "</td>";
echo "<td style='width:200px'>". $test['end']. "</td>";
echo "<td style='width:200px'>". $test['price']. "</td>";
echo "<td style='width:200px'> <a href ='print.php.?id=$id' target=_blank >Print</a>";
echo "<td style='width:100px'></td>";
echo "</tr>";
}
}
}

* он должен быть сохранен как invoice.php

* соединение с БД должно быть mysqli

например:

<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");

// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector