PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > need using multi-dimensional arrays
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
need using multi-dimensional arrays

Réponse
 
LinkBack Outils de la discussion
Vieux 12/02/2008, 14h36   #1
sahm
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut need using multi-dimensional arrays

Hi every one
I'm try to use multi-dimensional arrays and store the data in Sessions
and every time I add new data to the same array
but I have problem ever time I try to add now data it's renew all
array
Please me

this is my code
///////////////////////////////
<?php
session_start();
require_once('user_session.php');

$fristName = $_GET["fName"];
$fatherName = $_GET["faName"];
$famliyName = $_GET["fmName"];

$userData = array();
$userData["frName"] = $fristName;
$userData["faName"] = $fatherName;
$userData["fmName"] = $famliyName;

$allData = array();
$allData[]= $userData;
session_register('allData');

$dataShow = null;

if($fristName != null)
{
if($fatherName != null)
{
if($famliyName != null)
{
$dataShow = <<<HERE
<table border='1' cellpadding='1' cellspacing='1'>
<tr>
<th>
NO
</th>
<th>
Frist Name
</th>
<th>
Fahter Name
</th>
<th>
Famliy Name
</th>
</tr>
<tr>
HERE;
foreach($_SESSION['allData'] as $ad)
{
$dataShow .="<strong>".$ad['frName']."</strong>";
$dataShow .="<strong>".$ad['faName']."</strong>";
$dataShow .="<strong>".$ad['fmName']."</strong>";
}
$dataShow .="<td>";
$dataShow .= "&nbsp;";
$dataShow .="</td>";
$dataShow .="<td>";
$dataShow .=$userData["frName"];
$dataShow .="</td>";
$dataShow .="<td>";
$dataShow .=$userData["faName"];
$dataShow .="</td>";
$dataShow .="<td>";
$dataShow .=$userData["fmName"];
$dataShow .="</td>";
$dataShow .="</tr>";
$dataShow .="</table>";

echo $dataShow;

}
}
}
?>

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
best
Salim
  Réponse avec citation
Vieux 12/02/2008, 15h14   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: need using multi-dimensional arrays

On Tue, 12 Feb 2008 15:36:01 +0100, sahm <sahm007@gmail.com> wrote:

> Hi every one
> I'm try to use multi-dimensional arrays and store the data in Sessions
> and every time I add new data to the same array
> but I have problem ever time I try to add now data it's renew all
> array
> Please me
>
> this is my code
> ///////////////////////////////
> <?php
> session_start();
> require_once('user_session.php');
>
> $fristName = $_GET["fName"];


I suppose you mean $firstName, not $firstName? Allthough, you are
consequent in this..

> $fatherName = $_GET["faName"];
> $famliyName = $_GET["fmName"];
>
> $userData = array();
> $userData["frName"] = $fristName;
> $userData["faName"] = $fatherName;
> $userData["fmName"] = $famliyName;


Snip this:

> $allData = array();
> $allData[]= $userData;
> session_register('allData');


Do this:

$_SESSION['allData'] = isset($_SESSION['allData']) ? $_SESSION['allData']:
array();
$_SESSION['allData'][] = $userdata;

(And forget about the session_register() function, it's kind of deprecated
as you don't want register globals on, and we have a convenient $_SESSION
array).

> $dataShow = null;
>
> if($fristName != null)
> {
> if($fatherName != null)
> {
> if($famliyName != null)
> {


if(!empty($firstname) && !empty($fatherName) && !empty($familyName)){
--
Rik Wasmus
  Réponse avec citation
Vieux 12/02/2008, 16h36   #3
sahm
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: need using multi-dimensional arrays

On Feb 12, 6:14 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Tue, 12 Feb 2008 15:36:01 +0100, sahm <sahm...@gmail.com> wrote:
> > Hi every one
> > I'm try to use multi-dimensional arrays and store the data in Sessions
> > and every time I add new data to the same array
> > but I have problem ever time I try to add now data it's renew all
> > array
> > Please me

>
> > this is my code
> > ///////////////////////////////
> > <?php
> > session_start();
> > require_once('user_session.php');

>
> > $fristName = $_GET["fName"];

>
> I suppose you mean $firstName, not $firstName? Allthough, you are
> consequent in this..
>
> > $fatherName = $_GET["faName"];
> > $famliyName = $_GET["fmName"];

>
> > $userData = array();
> > $userData["frName"] = $fristName;
> > $userData["faName"] = $fatherName;
> > $userData["fmName"] = $famliyName;

>
> Snip this:
>
> > $allData = array();
> > $allData[]= $userData;
> > session_register('allData');

>
> Do this:
>
> $_SESSION['allData'] = isset($_SESSION['allData']) ? $_SESSION['allData']:
> array();
> $_SESSION['allData'][] = $userdata;
>
> (And forget about the session_register() function, it's kind of deprecated
> as you don't want register globals on, and we have a convenient $_SESSION
> array).
>
> > $dataShow = null;

>
> > if($fristName != null)
> > {
> > if($fatherName != null)
> > {
> > if($famliyName != null)
> > {

>
> if(!empty($firstname) && !empty($fatherName) && !empty($familyName)){
> --
> Rik Wasmus



Dear Rik Wasmus
Thank you vary much for your
it's me a lot
Best
Salim
  Réponse avec citation
Vieux 16/02/2008, 15h17   #4
sahm
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: need using multi-dimensional arrays

On Feb 12, 7:36 pm, sahm <sahm...@gmail.com> wrote:
> On Feb 12, 6:14 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>
>
>
> > On Tue, 12 Feb 2008 15:36:01 +0100, sahm <sahm...@gmail.com> wrote:
> > > Hi every one
> > > I'm try to use multi-dimensional arrays and store the data in Sessions
> > > and every time I add new data to the same array
> > > but I have problem ever time I try to add now data it's renew all
> > > array
> > > Please me

>
> > > this is my code
> > > ///////////////////////////////
> > > <?php
> > > session_start();
> > > require_once('user_session.php');

>
> > > $fristName = $_GET["fName"];

>
> > I suppose you mean $firstName, not $firstName? Allthough, you are
> > consequent in this..

>
> > > $fatherName = $_GET["faName"];
> > > $famliyName = $_GET["fmName"];

>
> > > $userData = array();
> > > $userData["frName"] = $fristName;
> > > $userData["faName"] = $fatherName;
> > > $userData["fmName"] = $famliyName;

>
> > Snip this:

>
> > > $allData = array();
> > > $allData[]= $userData;
> > > session_register('allData');

>
> > Do this:

>
> > $_SESSION['allData'] = isset($_SESSION['allData']) ? $_SESSION['allData']:
> > array();
> > $_SESSION['allData'][] = $userdata;

>
> > (And forget about the session_register() function, it's kind of deprecated
> > as you don't want register globals on, and we have a convenient $_SESSION
> > array).

>
> > > $dataShow = null;

>
> > > if($fristName != null)
> > > {
> > > if($fatherName != null)
> > > {
> > > if($famliyName != null)
> > > {

>
> > if(!empty($firstname) && !empty($fatherName) && !empty($familyName)){
> > --
> > Rik Wasmus

>
> Dear Rik Wasmus
> Thank you vary much for your
> it's me a lot
> Best
> Salim



Dear Mr. Rik Wasmus
Thank for your
I have one more problem
How can I make ($_SESSION['allData']) available for all my php file or
function in another file

and I will be Thank full for your

Best Salim
  Réponse avec citation
Vieux 16/02/2008, 15h24   #5
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: need using multi-dimensional arrays

On Sat, 16 Feb 2008 16:17:09 +0100, sahm <sahm007@gmail.com> wrote:

> On Feb 12, 7:36 pm, sahm <sahm...@gmail.com> wrote:
>> On Feb 12, 6:14 pm, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>>
>>
>>
>> > On Tue, 12 Feb 2008 15:36:01 +0100, sahm <sahm...@gmail.com> wrote:
>> > > Hi every one
>> > > I'm try to use multi-dimensional arrays and store the data in

>> Sessions
>> > > and every time I add new data to the same array
>> > > but I have problem ever time I try to add now data it's renew all
>> > > array
>> > > Please me

>>
>> > > this is my code
>> > > ///////////////////////////////
>> > > <?php
>> > > session_start();
>> > > require_once('user_session.php');

>>
>> > > $fristName = $_GET["fName"];

>>
>> > I suppose you mean $firstName, not $firstName? Allthough, you are
>> > consequent in this..

>>
>> > > $fatherName = $_GET["faName"];
>> > > $famliyName = $_GET["fmName"];

>>
>> > > $userData = array();
>> > > $userData["frName"] = $fristName;
>> > > $userData["faName"] = $fatherName;
>> > > $userData["fmName"] = $famliyName;

>>
>> > Snip this:

>>
>> > > $allData = array();
>> > > $allData[]= $userData;
>> > > session_register('allData');

>>
>> > Do this:

>>
>> > $_SESSION['allData'] = isset($_SESSION['allData']) ?

>> $_SESSION['allData']:
>> > array();
>> > $_SESSION['allData'][] = $userdata;

>>
>> > (And forget about the session_register() function, it's kind of

>> deprecated
>> > as you don't want register globals on, and we have a convenient

>> $_SESSION
>> > array).

>>
>> > > $dataShow = null;

>>
>> > > if($fristName != null)
>> > > {
>> > > if($fatherName != null)
>> > > {
>> > > if($famliyName != null)
>> > > {

>>
>> > if(!empty($firstname) && !empty($fatherName) && !empty($familyName)){


> How can I make ($_SESSION['allData']) available for all my php file or
> function in another file


$_SESSION is a superglobal, so it will be available anywhere in the
script, provided you have called session_start(). This should be done on
every request you want to use the $_SESSION array in.


--
Rik Wasmus
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h55.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,21697 seconds with 13 queries