在php mysql中检索数据 [英] data retrieving in php mysql

查看:77
本文介绍了在php mysql中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好PHP开发者..

我想从查询表中检索数据。

和第一页名称userform.php我有以下代码与$ refno =;在页面顶部用php标签定义:



Hi PHP Developers..
I wanted to retrieve data from table called enquiry.
and in 1st page by name userform.php i have below code with $refno = ""; defined at the top of the page with in php tag:

<form name="form1" method="post" action="fetchdata.php">
        <table width="auto" border="0" cellpadding="3" cellspacing="1" align="center" bgcolor="#FFFFFF">
        <tr>
            <td width="78">Ticket No.</td>
            <td width="6">:</td>
            <td width="78" class="float_left">
            <input name="refno" type="text" value="<?php echo $refno; ?>"/></td>
        </tr>
        </table>
        <input type='submit' value="Submit">
        </form>







我有fetchdata.php页面,我想检索数据并以表格格式显示,所以我做了如下代码:




and i have fetchdata.php page where i wanted to retrieve data and display in a table format so i did code as below:

<?php

        $dbhost = "localhost";

        $dbuser = "root";

        $dbpass = "";

        $conn = mysql_connect($dbhost, $dbuser, $dbpass);

        $refno = "";

        if(! $conn )

        {

        die('Could not connect: ' . mysql_error());

        }



        $strquery = "select * from enquiry where refno='$refno'";

        $result = mysql_query($strquery);



        ?>
        <table>
        <tr>
            <th>Results for Refno entry</th>
        </tr>
        </table>
        <table>
        <tr>
            <th>refno</th>
            <th>date</th>
            <th>agentname</th>
            <th>zcno</th>
            <th>callerid</th>
        </tr>
        <?php



        while($data = mysql_fetch_array($result))

        {

            $refno = $data["refno"];

            $date = $data["date"];

            $agentname = $data["agentname"];

            $zcno = $data["zcno"];

            $callerid = $data["callerid"];



            ?>


        <tr>
            <td><?php echo $refno; ?></td>
            <td><?php echo $date; ?></td>
            <td><?php echo $agentname; ?></td>
            <td><?php echo $zcno; ?></td>
            <td><?php echo $callerid; ?></td>
        </tr>

            <?php

        }

        echo("</table><br /><br />");





我收到的错误如下:

警告:mysql_fetch_array()期望参数1为资源,给定为null在C:\ xampp\htdocs\\\
ewcrm \ fetchdata.php第99行

refno date agentname zcno callerid



请请求你帮助我获取检索数据的代码,如果我以简单的形式获得代码将会非常有用,因为我认为我的代码非常复杂。



提前感谢并乐意成为这个论坛的一部分,因为我得到了很好的帮助,还有其他问题帮助我从这个论坛成长。



and i am getting error as:
Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\newcrm\fetchdata.php on line 99
refno date agentname zcno callerid

Please request you to help me getting code for retrieving data and it would be very helpful if i get code in simple form as i think i have did in very complex form.

Thanks in advance and happy to be a part of this forum as i get good help and also others questions help me grow from this forum.

推荐答案

refno =;在页面顶部用php标签定义:



refno = ""; defined at the top of the page with in php tag:

<form name="form1" method="post" action="fetchdata.php">
        <table width="auto" border="0" cellpadding="3" cellspacing="1" align="center" bgcolor="#FFFFFF">
        <tr>
            <td width="78">Ticket No.</td>
            <td width="6">:</td>
            <td width="78" class="float_left">
            <input name="refno" type="text" value="<?php echo


refno; ?>\"/></td>
</tr>
</table>
<input type='submit' value=\"Submit\">
</form>
refno; ?>"/></td> </tr> </table> <input type='submit' value="Submit"> </form>







and i have fetchdata.php page where i wanted to retrieve data and display in a table format so i did code as below:




and i have fetchdata.php page where i wanted to retrieve data and display in a table format so i did code as below:

<?php

        


dbhost = \"localhost\";

dbhost = "localhost";


这篇关于在php mysql中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆