Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z $_POST w petli for
slepy
post
Post #1





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 27.02.2003

Ostrzeżenie: (0%)
-----


Yo. Niby taki banalny problem a nie moge z nim dojsc do ladu
zrodlo wyglada tak:
[php:1:1526fb112b]<?php
for($a=0;$a<=10;$a++)
{
$link[$a]=$_POST['link$a']; // tu cos wlasnie nie gra sad.gif
echo("$link[$a]");
}

?>[/php:1:1526fb112b]
Problem z tym ze nie pobiera tego linka gdybym zamiasta
link$a
zastosowal
link1
To by bylo ok i pobiera tylko link1
Jak polaczyc te dwa "slowa"
Probowalem tez
link . $a
Gdzies tak widzialem ale tez zabardzo nie chce dzialac
Z Gory Dzieki za Pomoc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
Chewolf
post
Post #2





Grupa: Zarejestrowani
Postów: 335
Pomógł: 0
Dołączył: 15.11.2003

Ostrzeżenie: (0%)
-----


EDIT
Czyli trzeba :
[php:1:e8df47f4fe]<?php
$link[$a]=$_POST["link$a"];
?>[/php:1:e8df47f4fe]
Go to the top of the page
+Quote Post
slepy
post
Post #3





Grupa: Zarejestrowani
Postów: 70
Pomógł: 0
Dołączył: 27.02.2003

Ostrzeżenie: (0%)
-----


Niestety nie, dalej nie dziala :cry:
Go to the top of the page
+Quote Post
Liko
post
Post #4





Grupa: Zarejestrowani
Postów: 436
Pomógł: 6
Dołączył: 8.11.2003
Skąd: Szczecin

Ostrzeżenie: (0%)
-----


A nie możesz tak:
[php:1:5c41598413]
<?php

for($a=0;$a<=10;$a++)
{
$link[$a]=$_POST["link$a"]; // tu cos wlasnie nie gra
echo("$link[$a]");
}

?>
[/php:1:5c41598413]
Albo tak:
[php:1:5c41598413]
<?php

for($a=0;$a<=10;$a++)
{
$b = 'link'.$a;
$link[$a]=$_POST[$b]; // tu cos wlasnie nie gra
echo("$link[$a]");
}

?>[/php:1:5c41598413]
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #5





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


[quote="slepy"]
[php:1:95dabc9e62]<?php
for($a=0;$a<=10;$a++)
{
$link[$a]=$_POST['link$a']; // tu cos wlasnie nie gra :(
echo("$link[$a]");
}

?>[/php:1:95dabc9e62]
Jemu chyba chodzilo o cos takiego:
[php:1:95dabc9e62]
... $_POST['link1']
... $_POST['link2']
...

... $_POST['link10']
[/php:1:95dabc9e62]

czyli musisz poprawic na:

[php:1:95dabc9e62]<?php
for($a=0;$a<=10;$a++)
{
$link[$a]=$_POST["link$a"]; // <<<<<< PODWOJNE CUDZYSLOWIA (CUDZYSLOWY :P), w przeciwnym przypadku nie podstawi ci pod $a wartosti $a
echo($link[$a]); //<< TUTAJ CUDZYSL. SA NIEPOTRZEBNE
}

?>[/php:1:95dabc9e62]


--------------------
Nie lubię jednorożców.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 08:03