LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   defining an array in html template to be used by php (https://www.linuxquestions.org/questions/programming-9/defining-an-array-in-html-template-to-be-used-by-php-408953/)

mohtasham1983 01-28-2006 10:48 AM

defining an array in html template to be used by php
 
I have a form in my html template file which uses POST method.
In order to use this template I call this template's variables in a loop. So I need to define an array in my html template.

my template form varaibles are defined like this:
<form method="POST" action="gamble.php" name="form1">
<table>
<!-- BEGIN input -->
<tr>
<td><b>{f_team}</b></td>
<td><input type="text" size="4" name="first_team" value="{first_value}"></td>
<td><input type="text" size="4" name="second_team" value="{second_value}" ></td>
<td><b>{s_team}</b></td>
<td><font color="red"><b>Deadline:{deadline}</b></td>
</tr>
<!-- END input -->
<tr>
<Td><input type="submit" value="insert"></td>
</tr>
</table>
</form>

I save {f_team} and {s_team} variables in an array when I assign them a new value in each loop. then I store this array in a $_SESSION["somearray"] which works fine.

I did the same thing for {first_team} and {second_team} but it doesn't work.

Is it possible to define an array in my template? if yes how can I get the this array values using post method?

I use
$first_value = mysqlclean($_POST, "first_team", 5, $connection);
$second_value = mysqlclean($_POST, "second_team", 5, $connection);

to get the value when my array's length is only 1.

mohtasham1983 01-28-2006 01:32 PM

I use HTML_Template_ITX pear in order to make my template

mohtasham1983 01-28-2006 04:23 PM

Hello,
I am designing my first serious web database application using php and mysql.
I have the following problem:
I have made a form inside a loop using POST method:
PHP Code:

print "<form method='POST' action='gamble.php' name='form1'>";
    print 
"<table>";
    
$t=array();
    while (
$row = @ mysql_fetch_row($result))
    {            
        
$i=0;
        foreach (
$row as $data)
        {     
            
$t[$i]=$data;        
            
$i++;
        }
        print 
"<tr>";
            
            print 
"<td>\n<b>{$t[0]}</b></td>";
            print 
"<td><input type='text' size='4' name='first_team'                     value='{$first_value}'></td>";
            
            print 
"<td><input type='text' size='4' name='second_team'                     value='{$second_value}'></td>";
            print 
"<td>\n<b>{$t[1]}</b></td>";

            print 
"<td><font color='red'><b>Deadline:{$t[2]}</b></td>";
            
        print 
"</tr>";    
        
$h=array_merge($h,$t);
    }
    print 
"<tr>";
            print 
"<Td><input type='submit' value='insert'></td>";
    print 
"</tr>";
    print 
"</table>";
    print 
"</form>"

and in gamble.php file i use following method to get "first_team" and "second_team" from bet.php

PHP Code:

$first_value $_POST['first_team'];
$second_value $_POST['second_team']; 

and ir only returns one value for each variable which is expectable. I want to define "first_team" and "second_team" variables in bet.php like an array so that I won't have any problem fo retrieving them.

I would br glad if you help me.


All times are GMT -5. The time now is 05:37 AM.