Anyone good with PHP ? Need some help!!!
#1
Scooby Regular
Thread Starter
Join Date: Apr 2002
Location: Birmingham
Posts: 9,196
Likes: 0
Received 0 Likes
on
0 Posts
Anyone good with PHP ? Need some help!!!
I cannot get it to detect whether a checkbox on my form was ticked or not.
The problem i think is that there are a number of checkboxes, which are numbered according to the id of that row of data in the database - i.e. chk1, chk2 etc. The row number on the processing page is held in the $tmpid variable.
Currently I have:
Which obviously doesn;t work, but how do i get it to work?
Andy
The problem i think is that there are a number of checkboxes, which are numbered according to the id of that row of data in the database - i.e. chk1, chk2 etc. The row number on the processing page is held in the $tmpid variable.
Currently I have:
Code:
if ( $debug == '1' ) { echo("<i>$tmpid - ". $_POST['chk$tmpid' ] ."</i>\n"); }
Andy
Last edited by SiDHEaD; 11 March 2004 at 12:09 PM.
#2
Not knowing PHP yet (my books are at home), it would seem you're trying to get the values out of the variable chk$tmpid rather than chk1 chk2 etc.
Try
['chk'.$tmpid]
So you're appending tmpid to the string chk. Not sure if thats the right syntax.
J
Try
['chk'.$tmpid]
So you're appending tmpid to the string chk. Not sure if thats the right syntax.
J
#3
Scooby Regular
Thread Starter
Join Date: Apr 2002
Location: Birmingham
Posts: 9,196
Likes: 0
Received 0 Likes
on
0 Posts
I tried that, but i changed it a bit for this page so that it was easier to see what vars i was working with.
I had
Doesnt work!
Now, i will want to be using the checkbox as an if using isset() , but i need to know it is reading the checkbox first!
Edit: tmpid definately contains a var, as it prints the number out before the hyphen!
I had
Code:
$tmpid - ". $_POST['chk' .$tmpid ] ."</i>
Now, i will want to be using the checkbox as an if using isset() , but i need to know it is reading the checkbox first!
Edit: tmpid definately contains a var, as it prints the number out before the hyphen!
Last edited by SiDHEaD; 11 March 2004 at 12:33 PM.
#4
You need to create a new variable to concatenate (spelling) the two variables:
$newvariable = "chk"."$tmpid";
If say the value of $tmpid is 1 then when you echo $newvariable you should see chk1
Not sure if this is want you mean but......
Chump
$newvariable = "chk"."$tmpid";
If say the value of $tmpid is 1 then when you echo $newvariable you should see chk1
Not sure if this is want you mean but......
Chump
#6
Scooby Regular
Thread Starter
Join Date: Apr 2002
Location: Birmingham
Posts: 9,196
Likes: 0
Received 0 Likes
on
0 Posts
Ooo i've done it. Stuck the string of the checkbox value's variable name 'chk1' etc into a variable called $tmpchk and gave it directly to the post bit. A bit bodge but it works. Its only for our intranet so i don't care overly!
Andy
Andy
#7
Hmm interesting, mine worked:
index.htm
a.php
index.htm
Code:
<html> <head> </head> <body> <form action="a.php" method="post" name="wib"> <input name="chk1" value="ace"> <input name="submit" value="submit" type="submit"> </form> </body> </html>
Code:
<? $tmpid = 1; echo("<i>$tmpid - ". $_POST['chk'.$tmpid ] ."</i>\n"); ?>
Last edited by judgejules; 11 March 2004 at 12:54 PM.
Thread
Thread Starter
Forum
Replies
Last Post