How to pass an array to a form which is above the part where the array is created
I have a php script with html in it. The page is divided into blocks using div tags. There is a form in a div tag which is at the top which needs id generated by a sql query in a div tag below it. Changing the positions of div tag will change the entire look of the page.
//gets input from a form submitted in another page
//Compares value in the database
while ($row = mysql_fetch_array($result))
array1 = //store each id in an array
I tried putting the php block on top and the part that generates and displays the result in the div tag.
Now result appear according to the css.
But there is an If condition that echo's 'Please enter something' if all form fields are emty.
This message is coming on a separate blank page. I would like it to come on the same page of the form or in the div tag. How do I manage that?
Initialize a variable that will hold the error message:
$error_msg = '';
On the beginning it will be an empty string. When checking form fields and if all are empty (or invalid values) assign an error message to the $error_msg variable. At hte end of the script (or anywhere else) place a condition that will display a div tand the contents of the $error_msg.