LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-28-2006, 10:48 AM   #1
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
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.
 
Old 01-28-2006, 01:32 PM   #2
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
I use HTML_Template_ITX pear in order to make my template
 
Old 01-28-2006, 04:23 PM   #3
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
passing an array from html-forms to php prabhatsoni Linux - Software 2 06-04-2005 12:11 AM
Looking for a documentation database template (PHP/mySQL) davee Linux - Software 1 05-11-2005 08:39 AM
Template class with a template member... Nicholas Bishop Programming 3 02-21-2005 08:27 PM
php array gui10 Programming 2 03-26-2002 02:07 AM
HTML::Template smalter Programming 0 06-14-2001 10:41 AM


All times are GMT -5. The time now is 01:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration