sending code from php to text field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tejasadmin
Forum Newbie
Posts: 4
Joined: Fri Mar 28, 2008 12:44 pm

sending code from php to text field

Post by tejasadmin »

I am trying to run an sql statement to retrieve F_name and L_name from the sql filed where uniqid = 'buttons'

I am not sure how to take the individual fields aka F_name and L_name and send the information back to my form to the specific text fields they need to be attached to.

here is what I have been trying

First i create a dynamic button that will run this sql

it will generate the following
NOTE: (button("select") refers to a button that is created with a dynamic name and a value = 'select'
(Button("select") firstname lastname

Code: Select all

 
    foreach ($line as $col_value) {
    
    if ($count == 0){
     echo "<input type = 'submit' name = 'buttons[$curr_id]' value = 'Select' />";
    $count ++;
    }else{
    $nameval = ($col_value . " ");
    echo "$nameval";
    
       //echo "$col_value ";
    }
    
    }
    $count = 0;
    echo "<p>";
 
now when i click (button("select") it will call the php again and do the following

Code: Select all

 
} else if (isset($_POST['buttons'])) {
$query = mysql_query(
"SELECT `F_Name`,
`L_Name`
FROM `people`
Where uniqid = 'buttons'"
) or die (mysql_error());
//process 
$col = mysql_fetch_array($query, MYSQL_ASSOC);
}
//I dont know what to put here
} 
 
any help would be much apprediated

Also the code for my fisrt and last name fields are as follows

<form action="<?php print strip_tags($_SERVER['php_SELF']);?>" method="post">
<fieldset>
<legend>Customer Information</legend>
<table width="249" border="0">
<tr>
<td><div align="left">First Name </div></td>
<td> Name: <input tabindex="1" name="name" type="text" id="name" value="<?php print $name;?>" /></td>
</tr>
<tr>
<td width="95"><div align="left">Last Name </div></td>
<td width="144"><input tabindex="1" name="lname" type="text" id="lname" /></td>
</tr>
<tr>
AMCH
Forum Commoner
Posts: 31
Joined: Sun Mar 30, 2008 4:39 pm

Re: sending code from php to text field

Post by AMCH »

Hi there,

I am not sure exactly what you are trying to do here to be honest, it all looks rather overcomplicated.

I would consider keeping your form and your handler on seperate files and/or consider using AJAX.

Hope this helps

Kind Regards
AMCH
Post Reply