通过php post函数发送mysql查询结果

时间:2022-09-25 16:05:07

I am very inexperienced with PHP, just some basic understanding, and I am trying to send the results of a MySQL query via the post method to a specific URL. If I was displaying in a table on a web page then after the connection information I would have...

我对PHP非常缺乏经验,只是一些基本的理解,我试图通过post方法将MySQL查询的结果发送到特定的URL。如果我在网页上的表格中显示,那么在连接信息之后我会...

$result = mysql_query("select Selection, Date, Name from selectiontable order by Date");

echo "<table border='1'>
<tr>
<th>Selection</th>
<th>Race</th>
<th>Name</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Selection'] . "</td>";
echo "<td>" . $row['Date'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "</tr>";
}
echo "</table>";

Instead of printing to a table I want to send this information via Post to a URL. I have searched high and low and can only seem to find information about how to send information that is being entered through a form. This query produces about 200 rows. Someone sent me the script below to adapt but I can't work out how to put the results of the query into it.

我希望通过Post将此信息发送到URL,而不是打印到表格。我搜索了高低,似乎只能找到有关如何发送通过表单输入的信息的信息。此查询产生大约200行。有人发给我下面的脚本来适应,但我无法弄清楚如何将查询的结果放入其中。

<?php 

$entries=(isset($_GET['entries']) ? $_GET['entries'] : '1');

echo '<h2>Send</h2>';
echo '<style> .over{clear:both; margin:5px; border:1px solid #ccc; padding:10px;}               label{display:block;} input {display:block; margin:5px 0 0 0;}</style>';
echo'<form method="post" action="http://www.domain.com" id="" name="">';


for ($i=0; $i < $entries; $i++) { 

echo '
<div class="over">
<div class="proof_type">
<label for="selection_'.$i.'">Selection</label>
<input name="selection_'.$i.'" value="" type="text" >
</div>

<div class="proof_type">
<label for="date_'.$i.'">Date</label>
<input name="date_'.$i.'" value="" type="text" >
</div>

<div class="proof_type">
<label for="name_'.$i.'">Name</label>
<input name="name_'.$i.'" value="" type="text" >
</div>
</div>
';

}

echo '<input type="hidden" name="action" value="insert" />';
echo'<input type="submit" name="submit" value="submit" class="button" />';
echo'</form>';


?>

I would be very appreciative of any assistance. Thanks.

我非常感谢任何帮助。谢谢。

1 个解决方案

#1


0  

If you want to send information through a URL, it will be received through the GET method. Otherwise you will need a library like cURL to accomplish this.

如果您想通过URL发送信息,它将通过GET方法接收。否则你需要一个像cURL这样的库来完成这个任务。

#1


0  

If you want to send information through a URL, it will be received through the GET method. Otherwise you will need a library like cURL to accomplish this.

如果您想通过URL发送信息,它将通过GET方法接收。否则你需要一个像cURL这样的库来完成这个任务。