-1

I want to set these array data for the form.

This is my array.

 Array
    (
        [studentId] => 1
        [lecturerId] => 1
        [lecturerName] => muni
        [studentName] => kali
        [studentUniversityId] => we140
    )

This is my html form. i want set array data as a value for this form.

<form action="" method="post">

        <label for="studentID">Student ID</label>
        <input type="text" name="studentUniversityId" id="studentID" placeholder="studentID">

        <label for="studentName">Student Name</label>
        <input type="text" id="studentName" value="" name="studentName" placeholder="Student Name"><br><br>

        <label for="supervisorName">Supervisor Name</label>
        <input type="text" id="supervisorName" name="lecturerName" placeholder="Supervisor Name"><br><br>   

        <input type="submit" id="Upload" name="submit" value="Upload">        

loke2
  • 35
  • 1
  • 8
  • how to set the values of the array to the fields of the form.. my friend. ? – loke2 May 01 '17 at 02:28
  • Possible duplicate of [putting a php variable in a HTML form value](http://stackoverflow.com/questions/3317730/putting-a-php-variable-in-a-html-form-value) –  May 01 '17 at 02:59

1 Answers1

0
$myArray = array(
    "studentId" => 1
    "lecturerId" => 1
    "lecturerName" => "muni" //add other values
)

Add them to "value" attribute of HTML tags.

value="<?=$myArray["lecturerName"]?>"
kodmanyagha
  • 932
  • 12
  • 20
  • `$info=$_SESSION['supervisor_data'];` I'm getting this array like this. your code not working properly my friend. – loke2 May 01 '17 at 02:35