-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">        

2
  • how to set the values of the array to the fields of the form.. my friend. ? Commented May 1, 2017 at 2:28
  • Possible duplicate of putting a php variable in a HTML form value Commented May 1, 2017 at 2:59

1 Answer 1

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

Add them to "value" attribute of HTML tags.

value="<?=$myArray["lecturerName"]?>"
Sign up to request clarification or add additional context in comments.

1 Comment

$info=$_SESSION['supervisor_data']; I'm getting this array like this. your code not working properly my friend.

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.