Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 加载页面时,我无法显示带有值的动态输入字段?_Php_Html_Jquery - Fatal编程技术网

Php 加载页面时,我无法显示带有值的动态输入字段?

Php 加载页面时,我无法显示带有值的动态输入字段?,php,html,jquery,Php,Html,Jquery,以下是我的php代码: <?php try{ //Need to make a connection $con=new PDO("mysql:host=localhost;dbname=courseraassignment","root",""); $statementUpdate=$con->prepare("select * from position where p

以下是我的php代码:

<?php
try{
//Need to make a connection
$con=new PDO("mysql:host=localhost;dbname=courseraassignment","root","");


$statementUpdate=$con->prepare("select * from position 
                   where profile_id=:profile_id");
$statementUpdate->execute(array(
    ':profile_id'=>$_REQUEST['profile_id']
));
foreach($statementUpdate as $row){
   echo $row['year'];
   echo $row['description'];
   echo "<br>";
}
}catch(PDOException $e){
echo "error".$e->getMessage();
}
?>

从这段PHP代码中,我想从数据库中获得包括年份和职位表描述在内的数据

以下是我的完整html代码:

<div class="container">
<h1>Ashiful Islam Prince's Resume Registry</h1>


<h1>Editing Profile for UMSI</h1>
<?php
if(isset($_SESSION['profile_error'])) {
    $error = $_SESSION['profile_error'];
    unset($_SESSION["profile_error"]);


    echo '<span class="text-danger">';


    echo $error;


    echo '</span>';
}
?>
<form method="post">
    <p>First Name:
        <input type="text" name="first_name" value="<?php
        echo $firstName;
        ?>"
        ></p><br>

    <p>Last Name:
        <input type="text" name="last_name" value="<?php
        echo $lastName;
        ?>"</p>

    <p>Email:
        <input type="text" name="email" value="<?php
        echo $Email;
        ?>"</p><br>
    <span class="text-danger">
<?php
if(isset($email_sign_error))
    echo $email_sign_error;

?>
</span>


    <p>Headline:<br/>
        <input type="text" name="headline" value="<?php
        echo $Headline;
        ?>"</p>


    <p>Summary:<br/>
        <textarea name="summary" rows="8" cols="80">
    <?php
    echo $Summary;

    ?>
</textarea>
    <p>Position : <input type="button"  class="add_position" id="add_position"
                         name="addPosition" value="+">
        <div class="position_fields" id="position_fields">

       </div>
    <p>
<input type="submit" value="Save" name="btn" class="btn btn-primary">
<input type="submit" name="cancel" value="Cancel">
 </p>
</form>
</div>
</div>
</div>

灰心的伊斯兰王子的简历登记册
UMSI的编辑配置文件
名字:

你必须使用你的foreach!你能提出一个答案吗?我没听清楚你的评论。老实说:没有!我刚刚发现了这个重大错误,必须检查你的整个脚本。但也许它更适合你!好的,请检查一下,如果可能的话,然后提出一个答案。我已经为你的问题提出了一个更合适的地方。您的脚本很可能存在各种问题。fetchAll()本身在文档中应该很简单。
<div class="position_fields" id="position_fields">

   </div>
   <script type="text/javascript">

    $(document).ready(function(){
    var countPos=0;
    var add_button=$('#add_position');
    var wrapper=$('#position_fields');
    window.console && console.log('Document ready called');
    //When the user clicks on the add button then It inserts these input fields
    function addField(event){

        if ( countPos >=9 ) {
            alert("Maximum of nine position entries exceeded");
            return;
        }
        countPos++;
        window.console && console.log("Adding position "+countPos);
        $(wrapper).append(
            '<div id="position'+countPos+'"> \
    <p>Year: <input type="text" name="year'+countPos+'" value="" /> \
    <input type="button" value="-" \
        onclick="$(\'#position'+countPos+'\').remove();return false;"></p> \
    <textarea name="desc'+countPos+'" rows="8" cols="80"></textarea>\
    </div>');
    }
    $(add_button).click(function(event){
        addField();
    });
    addField();



    });

   </script>