从在线视图的表单显示图像

时间:2015-07-25 02:36:51

标签: php database forms

我不是所有这一切的专家,所以如果这很简单,我道歉。

我有一个表格,可以将数据提交到数据库,发送电子邮件并在线存储,供用户查看。

前2个工作正常,第3个选项(在线观看)几乎是完美的。

作为调查的一部分,用户拥有一个星级评分系统,他们的评分为1 - 5.然后发送电子邮件作为他们的星级评分和数字的图像。我想在在线视图版本上显示相同的图像。目前,它确实出现但未显示其评级(它只是名为star.jpg的普通图像。)

以下是我的代码(如果您需要了解更多信息,请与我们联系):

<?php
class guestquestionnaireEntry {
    public $id, $date_submitted, $choice, $expectations, $res, $res_information,
        $entry;

public function __construct()
    {
        $img            =   "<img src='http://www.myURL.com/guestquestionnaire/images/star".$_POST['res'].".jpg'>";
        $img2           =   "<img src='http://www.myURL.com/guestquestionnaire/images/star".$_POST['res_information'].".jpg'>";
        $this->entry    =   "
        <table border='1' width='800px' align='center'>
            <tr>
                <td><b>{$this->date_submitted} </b></td>
            </tr>
            <BR>
            <tr>
                <td>What made you choose us for your recent stay? </td>
                <td>{$this->choice}</td>
            </tr>
            <BR>
            <tr>
                <td> Did our hotel meet your expectations as advertised? If no, please state why. </td>
                <td>{$this->expectations} </td>
            </tr>
            <BR>
            <tr style='background: #566890; font-size: 8pt; font-weight: bold; color: #000;'>
                <td colspan='3'>Making your Reservation</td>
            </tr>
            <BR>
            <tr style='font-size: 8pt;'>
                <td>Ease of making your reservation: </td>
                <td width='40%'>$img</td>
                <td width='5%'>{$this->res}</td>
            </tr>
            <tr style='font-size: 8pt;'>
                <td>Hotel information offered: </td>
                <td width='40%'>$img2</td>
                <td width='5%'>{$this->res_information}</td>
            </tr>...

以下是我使用它的方式:

try {
        $handler = new PDO('mysql:host=***;dbname=***', '***', '***');
        $handler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    } catch(PDOException $e) {
        echo $e->getMessage();
        die();
    }

 $query = $handler->query('SELECT * FROM guestquestionnaire');
 $query->setFetchMode(PDO::FETCH_CLASS, 'guestquestionnaireEntry');
 while($r = $query->fetch()) {
      echo $r->entry, '<br>';
}

?>

我的图片的名称为star.jpgstar1.jpgstar2.jpg等。

前端表单编码(如果您需要更多,请再次告诉我):

<div id="third_step">
    <div class="form">
        <div class="question">
            <h1>Making Your Reservation</h1>
            <p>When making your reservation, how would you rate the following?</p>
        </div>
        <BR />
        <div class="question-sub">
            <p>Ease of making your reservation</p>
        </div>
        <span class="rating">
            <input type="radio" class="rating-input" id="rating-input-1-1" name="res" value="5">
            <label for="rating-input-1-1" class="rating-star"></label>
            <input type="radio" class="rating-input" id="rating-input-1-2" name="res" value="4">
            <label for="rating-input-1-2" class="rating-star"></label>        
            <input type="radio" class="rating-input" id="rating-input-1-3" name="res" value="3">
            <label for="rating-input-1-3" class="rating-star"></label>        
            <input type="radio" class="rating-input" id="rating-input-1-4" name="res" value="2">
            <label for="rating-input-1-4" class="rating-star"></label>       
            <input type="radio" class="rating-input" id="rating-input-1-5" name="res" value="1">
            <label for="rating-input-1-5" class="rating-star"></label>
        </span>
        <br>
        <div class="question-sub">
            <BR />
            <p>Hotel information offered</p>
        </div>
        <span class="rating">
            <input type="radio" class="rating-input" id="rating-input-2-5" name="res_information" value="5">
            <label for="rating-input-2-5" class="rating-star"></label>
            <input type="radio" class="rating-input" id="rating-input-2-4" name="res_information" value="4">
            <label for="rating-input-2-4" class="rating-star"></label>
            <input type="radio" class="rating-input" id="rating-input-2-3" name="res_information" value="3">
            <label for="rating-input-2-3" class="rating-star"></label>
            <input type="radio" class="rating-input" id="rating-input-2-2" name="res_information" value="2">
            <label for="rating-input-2-2" class="rating-star"></label>
            <input type="radio" class="rating-input" id="rating-input-2-1" name="res_information" value="1">
            <label for="rating-input-2-1" class="rating-star"></label>
        </span>

我怀疑问题和(希望)简单修复是在前两行$img="<img src....内,因为这是似乎没有正确调用的部分。我怀疑显示信息的编码需要不同吗?

0 个答案:

没有答案