Jump to content


Photo

Cannot read variables with a counter


  • Please log in to reply
4 replies to this topic

#1 therif

therif
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 March 2006 - 09:24 AM

Hi,

I'm new to PhP, but I coded already a lot in C++, so PhP is quite similar

But thats not the point

I want to paste a countervariable to a $_GET

Well, this is the code :)

This here works fine:

<form id="add" name="add" method="get" action="BBCode.php">
<label></label>
<?php
while($teller <= $quantity)
{
echo "Omschrijving van object nummer ", $teller
?>
<p> </p>
<table width="250" border="9">
<tr>
<td>Verkoop van </td>
<td>
<select name="cmbType<?php echo $teller ?>" id="cmbType">
//... Some html form code

</p>

<?php
$teller++;
}
?>
<input type="hidden" name="txtQuantity"id="txtQuantity" value="<?php echo $quantity?>" />
<input type="submit" name="Submit" value="Submit" />
</form>

</body>
</html>
----------------------------------
As you can see, in another previous page i setted a quantity and here the counter(teller) is going to loop.
everytime I got a name, I add the number so I can process it on next page...
This code here is Ok, now I used the Get method, the next page have to take these, and for the moment only echo it, if I can echo, I can do everything else :)
---------------------------------
<body>
<?php
$Quantity = $_GET['txtQuantity'];

$teller = 1;
while ($teller < Quantity)
{
$Type = $_GET['cmbType'];//here, how do I add a counter so he can read the get with a counter next to it
$Model = $_GET['txtModel'];
$Description = $_GET['txtDescription'];
$Official_Link = $_GET['txtOfficial'];
$Directory_Link = $_GET['txtLinkDir'];
$Min_Price = $_GET['txtMinPrice'];
$Buy_It = $_GET['txtBuyIt'];
$Richtprijs = $_GET['txtDunno'];
$Introductie = $_GET['txtIntro'];
$Slot = $_GET['txtEnd'];



?>
<link href="topicgen.css" rel="stylesheet" type="text/css" />


<?php
echo "Hello World in while";
echo $Quantity;
echo $Type;
echo $Model;
echo $Description;
echo $Official_Link;
echo $Directory_Link;
echo $Min_Price;
echo $Buy_It;
echo $Richtprijs;
echo $Introductie;
echo $Slot;
$teller++;
}
echo $Type;
?>

</body>

Like this :) if you need more information, just PM me

Here is the test site [a href=\"http://therif.free.fr/testingtg/\" target=\"_blank\"]http://therif.free.fr/testingtg/[/a]
It is in dutch... but just write a quantity inferior to 10 in first page, and u can directly submit on next page

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 14 March 2006 - 09:49 AM

use sessions

[!--sizeo:6--][span style=\"font-size:24pt;line-height:100%\"][!--/sizeo--]
corrected post below[!--sizec--][/span][!--/sizec--]
good luck

page1.php
<?php
session_start();

$_SESSION['1'] = 1;
$_SESSION['2'] = 2;
$_SESSION['3'] = 3;

?>


page2.php
<?php
session_start();

echo ".$_SESSION['1'] .";
echo ".$_SESSION['2'] .";
echo ".$_SESSION['3'] .";

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 therif

therif
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 March 2006 - 09:55 AM

[!--quoteo(post=354821:date=Mar 14 2006, 10:49 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 14 2006, 10:49 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
use sessions

good luck

page1.php
<?php
session_start();

$_SESSION['1'] = 1;
$_SESSION['2'] = 2;
$_SESSION['3'] = 3;

?>


page2.php
<?php
session_start();

echo ".$_SESSION['1'] .";
echo ".$_SESSION['2'] .";
echo ".$_SESSION['3'] .";

?>
[/quote]

k, thx;) I'll try it

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 14 March 2006 - 09:58 AM

[!--quoteo(post=354823:date=Mar 14 2006, 09:55 AM:name=Rifton)--][div class=\'quotetop\']QUOTE(Rifton @ Mar 14 2006, 09:55 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
k, thx;) I'll try it
[/quote]
[a href=\"http://www.tizag.com/phpT/phpsessions.php\" target=\"_blank\"]http://www.tizag.com/phpT/phpsessions.php[/a]

everythink you need ok
good luck
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 14 March 2006 - 10:34 AM


sorry i made a makup sorry edited and corrected.

page1.php

<? session_start();


$_SESSION['john']='1';
$_SESSION['james']='2';
$_SESSION['lucky']='3';

echo"<a href='page2.php'>loaded session</a>";

?>


page2.php

<?php
session_start();

echo $_SESSION['john'];
echo $_SESSION['james'];
echo $_SESSION['lucky'];

?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users