0

我有一个网站,显示来自存储在数据库中的用户的按摩。我想要的是当我单击每条消息旁边的回复链接时,必须加载一个新页面,并且必须填写每条消息的详细信息以及如何在循环后获取特定行的特定数据。

<?php 
$dbcon=mysqli_connect("localhost","root","","technoage");

// Check connection
if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_select_db($dbcon,"technoage") or die ("database not found!!!");

$r = mysqli_query($dbcon,"SELECT * FROM messages LIMIT $startrow,10 "); // Run the query.
if($r) { // If it ran OK, display the Table header.
    echo '<table class="table"> <tr><td><b>Name of sender</b></td><td><b>Senders Details</b></td><td><b>Message</b></td><td><b>Reply To Massage</b><td/></tr>';

    while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) 
    { 
        echo'<tr><td>'.'Name: '.$row['name'].'</td><td> '.'Email: '.$row['email_address'] .'<br>Subject: '.$row['message_subject'].'<br>Phone: '.$row['phone'].'<br>Date Sent: '.$row['date_sent']. '</td><td>'.'Message: '.$row['message'].'</td><td><a     href="#">Reply</a></td></tr>';
    }
    echo '</table>';
}

当点击回复链接时,页面必须加载点击按摩的详细信息。

回复文件是

<?php 
    $dbcon=mysqli_connect("localhost","root","","technoage");
    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    mysqli_select_db($dbcon,"technoage") or die ("database not found!!!");

    // Run the query.

    echo'<form method="post" action="includes/insert.php">';
    echo'<label for="name">Name:</label><br>';
    echo'<input type="text" class="text" name="name" id="name" /><br>';
    echo'<label for="email">E-mail Address:</label><br>';
    echo'<input type="text" class="text" name="email" id="email" /><br>';
    echo'<label for="phone">Phone:</label><br>';
    echo'<input type="text" class="text" name="phone" id="phone" /><br>';
    echo'<label for="text">Message Subject:</label><br>';
    echo'<input type="text" class="text" name="message_subject" id="message_subject"></textarea><br>';
    echo'<label for="text">Message:</label><br>';
    echo'<textarea class="text" name="message" id="text"></textarea><br>';
    echo'<input type="submit" class="submit" value="Send" />';
    echo'</form>';
?>

Matlab中带有误差条的直方图

我想将误差条放在条形图中(每个条形上方)。我试过了

bincentres = -85:10:85;
nelements = [1,4,14,24,46,57,63,63,174,147,69,49,22,9,4,2,1,0];
err = sqrt(nelements);
bar(bincentres, nelements);
hold on
errorbar(bincentres,nelements, err);
hold off

以前我没有收到错误栏,因为我在上面的代码中的“错误栏”中缺少“bincentres”。感谢@Shai 指出这一点。但是除了错误栏之外,现在我得到了一条连接每个错误栏中间的线。我想跳过那条蓝线。

4

3 回答 3

2

第一件事:请不要使用SELECT *. 更好的SELECT id, name, phone.... FROM ...

您可以使用数据库表的主键生成回复链接。(例如身份证)

echo '<a href="reply.php?id=' . $row['id'] . '">Reply</a>';

确保它id始终是一个整数,而不是可能生成错误链接的用户输入。

于 2014-05-09T07:16:34.940 回答
0

像这样为表单字段添加值属性

echo'<input type="text" class="text" name="name" id="name" value="'.$row['name'].'" /><br>';

并相应地为其他字段添加相同的属性。

于 2013-11-06T11:19:19.253 回答
-1

看一下这个。

第 1 页遗漏点: 1. 未申报表格

修改代码:

<?php 
$dbcon=mysqli_connect("localhost","root","","technoage");

// Check connection
if (mysqli_connect_errno())
{
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_select_db($dbcon,"technoage") or die ("database not found!!!");
}

$r = mysqli_query($dbcon,"SELECT * FROM messages LIMIT $startrow,10 "); // Run the query.
if($r) { // If it ran OK, display the Table header.
echo "<form method='post' action='target_pagelink.php' target='_blank'>";
echo '<table class="table"> 
        <tr>
            <td><b>Name of sender</b></td>
            <td><b>Senders Details</b></td>
            <td><b>Message</b></td>
            <td><b>Reply To Massage</b><td/>
        </tr>';

while ($row = mysqli_fetch_array($r,MYSQLI_ASSOC)) 
{ 
echo'<tr><td>'.'Name: '.$row['name'].
    '</td><td> '.'Email: '.$row['email_address'] .
    '<br>Subject: '.$row['message_subject'].
    '<br>Phone: '.$row['phone'].
    '<br>Date Sent: '.$row['date_sent']. 
    '</td><td>'.'Message: '.$row['message'].
    '</td><td>'."
    <input type='hidden' name='Name' value=".$row['name']." >
    <input type='hidden' name='Email' value=".$row['email_address']." >
    <input type='hidden' name='Subject' value=".$row['message_subject']." >
    <input type='hidden' name='Phone' value=".$row['phone']." >
    <input type='hidden' name='DateS' value=".$row['date_sent']." >
    <input type='hidden' name='Message' value=".$row['message']." >
    <input type='submit' value='Reply' >
    </td>
    </tr>
    ";
}
echo '</table>';
echo '</form>';

?>

2nd(Reply File)页面缺失点:1.没有声明接受输入参数的元素

<?php 
    $dbcon=mysqli_connect("localhost","root","","technoage");
    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    mysqli_select_db($dbcon,"technoage") or die ("database not found!!!");

    // Run the query.

    if(
        isset($_POST['name']) &&
        isset($_POST['email_address']) &&
        isset($_POST['message_subject']) &&
        isset($_POST['phone']) &&
        isset($_POST['date_sent']) &&
        isset($_POST['message']) 
    ){
    echo'<form method="post" action="includes/insert.php">';
    echo'<label for="name">Name:</label><br>';
    echo'<input type="text" class="text" name="name" id="name" value='.$_POST['name'].'/><br>';
    echo'<label for="email">E-mail Address:</label><br>';
    echo'<input type="text" class="text" name="email" id="email" value='.$_POST['email_address'].' /><br>';
    echo'<label for="phone">Phone:</label><br>';
    echo'<input type="text" class="text" name="phone" id="phone" value='.$_POST['phone'].' /><br>';
    echo'<label for="text">Message Subject:</label><br>';
    echo'<input type="text" class="text" name="message_subject" id="message_subject" value='.$_POST['message_subject'].' ></textarea><br>';
    echo'<label for="text">Message:</label><br>';
    echo'<textarea class="text" name="message" id="text" >'.$_POST['message'].'</textarea><br>';
    echo'<input type="submit" class="submit" value="Send" />';
    echo'</form>';
    }
?>
于 2013-11-06T11:26:49.623 回答