0

I need to Query a database and then populate a textbox input with the result.

I'm trying

Date Called:

   <td>
      <?php 
         $selectedSPK=$_POST['SPKSelect'];
        $assigned = $_POST['Sales_Exec'];
        $date = $_POST['DateSelect'];

if ($selectedSPK)

{
    $Call1query = "SELECT  Call1 FROM Data WHERE SPKCustNo  = '$selectedSPK' ";

$Call1result = mysql_query($Call1query);


 while( $row = mysql_fetch_array($Call1result) ){
    $Call1 = $row["$Call1Result"];

    }

}
?>
    <input type="text" name="Call1" id="Call1" value="<?php echo( htmlspecialchars( $Call1) ); ?>"/></td>

But getting nothing out, where am I going wrong, Text inputs seem tricky to populate!

Thankyou!

1
  • You can't do this... $Call1 = $row["$Call1Result"];... Give the field names in $row Commented Oct 3, 2012 at 10:48

4 Answers 4

2

use instead

$Call1 = $row["Call1"];
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! Thankyou, will mark as answer as soon as the timer lets me.
1

Replace

$Call1 = $row["$Call1"];

with

$Call1 = $row["Call1"];

Comments

0

the problem is here change

$Call1 = $row["$Call1Result"];

to

$Call1 = $row['Call1'];   //here column name comes not variable name

Comments

0

try like this

<td>
  <?php 
     $selectedSPK=$_POST['SPKSelect'];
    $assigned = $_POST['Sales_Exec'];
    $date = $_POST['DateSelect'];

if ($selectedSPK)

{
 $Call1query = "SELECT  Call1 FROM Data WHERE SPKCustNo  = '$selectedSPK' ";

$Call1result = mysql_query($Call1query);


 while( $row = mysql_fetch_array($Call1result) ){
$Call1 = $row["Call1"];

}

}?>

<input type="text" name="Call1" id="Call1" value="<?php echo( htmlspecialchars( $Call1) ); ?>"/></td>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.