douye8500
douye8500
2013-03-12 08:43

如何通过包含在php [关闭]中获取并传递数据库值

已采纳

I'm having a problem. here is my code.

$_GET['id']=2;
include 'operation/visual_console/render_view.php';

this code is ok. it gives the correct page with having the id=2. but i want is , to get that id value from the database. not by the hard-code it.

thank you.

EDIT

sorry for the poor coding.my data base connection is ok.i'll did it correctly.but the thing is this is my 1st post and i made some mistakes.so sorry for that again.and my question is solved by my self here is the new code and the above missing parts.

    <?php
    function map()
    {
    $con=mysql_connect("localhost","root","abc123@#");
    mysql_select_db("pandora", $con);

    // Check connection
    if (mysqli_connect_errno($con))
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    $idAgent = (int)get_parameter('id_agente', 0);
    $lidAgent = db_get_value('id_layout', 'tlayout_data', 'id_agent', $idAgent);
    $_GET['id']=$lidAgent;

    include 'operation/visual_console/render_view.php';

    }
    mysqli_close($con);
    ?>

so now it's ok.thank you for bothering about me.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • drby30217 drby30217 8年前

    mysql_connect(host,username,password,dbname);

    $result=mysql_query($con,"select * from pages where ...");

    $result contain your ID value......

    点赞 评论 复制链接分享

相关推荐