簡體   English   中英

如何在php的文本框中顯示數據庫中的數據

[英]how to show data from database in textbox in php

我是php編程的新手,我在此代碼中遇到問題,我想在按網格中的選擇按鈕時在文本框中顯示數據,但由於數據未顯示在文本框中且我的選擇按鈕也沒有顯示,所以我被卡在上面工作,我為此做的朋友,這是我的代碼 在此處輸入圖片說明

名中間名姓

**--//php code--//**

$qrydatabind='SELECT ecode, first_name, middle_name, last_name, father_name, mother_name,
          number_of_dependents, dob, gender, identification_mark, marital_status, spouse_name, mobile_number,
          email_id, adhar_id, pan_number, passport_number, tin_number, dl_number FROM USER_MASTER ORDER BY user_id DESC 
          LIMIT 1';
                  $results=  mysql_query($qrydatabind) or die(mysql_error());

                      while( $row =  mysql_fetch_array( $results ) ) {
                        echo
            "
                <div class='table-responsive'>
<table  border='1' style= 'background-color: #84ed86; color: #761a9b;  ' >
      <thead>
                <tr>
            <th></th>
              <th>Entity Code</th>
              <th>User Id</th> <th>User Name</th> <th>Father Name</th>  <th>Mother Name</th>  <th>No.Of Dependents</th>
              <th>D.O.B</th> <th>GENDER</th> <th>Id Mark</th> <th>MARITAL STATUS</th>  <th>SPOUSE NAME</th>
              <th>Mob. Number</th> <th>E-Id</th> <th>ADHAR-ID</th> <th>PAN-No.</th> <th>PASSPORT-No.</th>
               <th>TIN-NO.</th> <th>DL-No.</th>
            </tr>
                </thead>

                      <tr >        

                        <td><button type='submit' class='btn btn-primary' name='select_button'>Select</button> </td> 
                        <td>{$row['ecode']}</td> <td> echo $row[0];</td>
                        <td>{$row['first_name']} {$row['middle_name']} {$row['last_name']}</td>             
                        <td>{$row['father_name']}</td> <td>{$row['mother_name']}</td>
                        <td>{$row['number_of_dependents']}</td> <td>{$row['dob']}</td>
                        <td>{$row['gender']}</td> <td>{$row['identification_mark']}</td>
                        <td>{$row['marital_status']}</td> <td>{$row['spouse_name']}</td>
                        <td>{$row['mobile_number']}</td> <td>{$row['email_id']}</td>
                        <td>{$row['adhar_id']}</td>  <td>{$row['pan_number']}</td>
                        <td>{$row['passport_number']}</td> <td>{$row['tin_number']}</td>
                        <td>{$row['dl_number']}</td>

            </tr> </table>  
              </div>";
        }}

        if(isset($_POST['select_button']))
            {
             $qrydatabind1='SELECT ecode, first_name, middle_name, last_name, father_name, mother_name,
          number_of_dependents, dob, gender, identification_mark, marital_status, spouse_name, mobile_number,
          email_id, adhar_id, pan_number, passport_number, tin_number, dl_number FROM USER_MASTER';
                  $results1=  mysql_query($qrydatabind1) or die(mysql_error());

                      while( $row =  mysql_fetch_array( $results1 ) ) {
                          echo'
                        <tr >                   
                        <td> </td> 

                         <td><input  type="text" value="{$row["first_name"]}" ></td>

            </tr>';

            }
            }

這很簡單。 當您將數據放入時。

您的密碼

<td> echo $row[0];</td>

文字框代碼:

<input type="text" value="<?php echo $row[0];?>">

PHP變量將僅以雙引號引起來的字符串進行評估"

您應該添加一個字符串:

echo '<td><input type="text" value="' . $row["first_name"] . '" ></td>';

或者,使用<?php?>在腳本和標記之間切換

while( $row =  mysql_fetch_array( $results1 ) ) {

    ?><td><input type="text" value="<?php echo $row["first_name"]; ?>" ></td><?php

}

 You can also use this as echo'<tr><td><input type="text" value="'.$row["first_name"].'" ></td></tr>'; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM