Hey all.

I was under the impression that PHP processes all php code first before
handing HTML processing over to the browser.

It seems that if you call an external function that, say, queries your db
for data and spits out populated formfields, the function is processed
somehow simultaneously with staright HTML. The result in this case is that
my submit button appears above the formfields! Here's a quick example:

******* global_functions.php ********
<?
function make_form($sql) {

    dbConnect($sql); /* Runs db query */
    while ($q = mysql_fetch_array($result)) { $string = "<input type=text
name=test value=$q[0]>"; }
    return $string;

} ?>

******* print_form.php ********

<? include 'global_functions.php';
    $sql = "SELECT first_name FROM customers LIMIT 1"; ?>
    $display_form = make_form($sql);
?>

<form name=test>
    <? echo $display_form; ?>
    <input type=submit value=submit>
</form>

******* Result ********

Submit button on top
Formfields are below submit button

****************************

Any info much appreciated.  I'd like to avoid having to pop the submit
button in based on the number of records returned, or other workaround.

Thanks in advance,

--Noah





--




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to