-2

我需要在这个页面中输出一个 jpeg 图像。查看下面的代码,我设置了一个向用户显示数据的表单。在此表单内或表单下方,我需要输出图像。该代码作为 PHP 文件运行,因此普通的 HTML 标记不起作用。有任何想法吗?

<!DOCTYPE html>
    <?php
    session_start();
    ?>
    <html>
        <head>
            <meta charset="utf-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1" />
            <meta name="apple-mobile-web-app-capable" content="yes" />
            <meta name="apple-mobile-web-app-status-bar-style" content="black" />
            <title>
            </title>
            <link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
            <link rel="stylesheet" href="my.css" />
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
            </script>
            <script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js">
            </script>
            <script src="my.js">
            </script>
            <!-- User-generated css -->
            <style>
            </style>
            <!-- User-generated js -->
            <script>

                try {

        $(function() {

        });

      } catch (error) {
        console.error("Your javascript has an error: " + error);
      }
            </script>
         </head>
        <body>
            <!-- Home -->
            <div data-role="page" id="page1">
                <div data-theme="a" data-role="header">
                <a data-role="button" data-theme="d" href="login.html" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left">
                        Back
                    </a>
                    <a data-role="button" href="index.html" data-icon="home" data-iconpos="right" data-theme="d"class="ui-btn-right">
                     Home  
                    </a>
                    <h3>
                        Book Car
                    </h3>
               </div>

               <div data-role="content">
                    <h3>
                        Select the car to rent from the availability:
                    </h3>
                    <br />
            <?php
            {
                mysql_connect("localhost" , "" , "") or die (mysql_error());
                mysql_select_db("") or die(mysql_error());


                $pid=intval($_SESSION["User_id"]); 
                $query = "SELECT `car`, `details`, `price` FROM `Car`";

                //executes query on the database
                $result = mysql_query ($query) or die ("didn't query");

                //this selects the results as rows
                $num = mysql_num_rows ($result);    


                while($row=mysql_fetch_assoc($result))
                {

                    $_SESSION['car'] = $row['car'];
                    $_SESSION['details'] = $row['details'];
                    $_SESSION['price'] = $row['price'];
                }
            }
            ?>  

    <!DOCTYPE html>
    <html>
    <body>

    <form action="demo_form.asp">
     Car: <input type="text" name="country" value="<?php echo $_SESSION['car']; ?>" readonly><br>
     Details: <input type="text" name="country" value="<?php echo $_SESSION['details']; ?>" readonly><br>
     Price: <input type="text" name="country" value="<?php echo $_SESSION['price']; ?>" readonly><br>
      <input type="submit" value="Submit">

    </form>

    </body>
    </html>
4

2 回答 2

0

在您的 php 脚本中,在任何输出之前添加此内容,以便将 php 作为图像读取:

header("Content-Type: image/jpg"); //or image/gif or image/png ...

然后你可以在你的表单中添加这个:

<img src='my_php_script.php?image=1' />

您可以通过将参数传递给 php 脚本来识别您的图像。

头文件

于 2013-04-09T14:10:57.980 回答
0

你有这个两次:<!DOCTYPE html>。那是错误的。此外:标准 HTML<img src="yourimg.jpg" alt="this img" />在您的表单下方可以正常工作,并且完成了

于 2013-04-09T14:11:06.250 回答