Reputation: 69
i am new in php programming i have problem in this code, i want to show data in text box when i press select button which is in grid, but i am stuck on it because data not shown in text box and my select button also not working, what i do friends for this,
this is my code
FIRST NAME MIDDLE NAME LAST NAME
**--//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>';
}
}
Upvotes: 0
Views: 3388
Reputation: 11
You can also use this as
echo'<tr><td><input type="text" value="'.$row["first_name"].'" ></td></tr>';
Upvotes: 0
Reputation: 643
PHP Variables will only be evaluated in strings that are quoted in double quotes "
You should either concatinate a string:
echo '<td><input type="text" value="' . $row["first_name"] . '" ></td>';
Or, use <?php
and ?>
to switch between script and markup
while( $row = mysql_fetch_array( $results1 ) ) {
?><td><input type="text" value="<?php echo $row["first_name"]; ?>" ></td><?php
}
Upvotes: 1
Reputation: 1193
It is very simple. as you are putting data in .
Your code
<td> echo $row[0];</td>
Text box code:
<input type="text" value="<?php echo $row[0];?>">
Upvotes: 1