yanviau
-
Posts
6 -
Joined
-
Last visited
Never
Posts posted by yanviau
-
-
Hello i try to explain my situation,
I have a dynamic table so i need to build a dynamic radiobutton list and build a dynamic sql req.
First of all i build my table with radio button in a while
So the radio button is named rdYanViau ( in the html it's working no prob with that )
$name = $row2['FirstName'].$row2['LastName'];<input type="radio" name="rd<?php echo $name; ?>" value="1"><input type="radio" name="rd<?php echo $name; ?>" value="2">And in the same while i build a portion of my dynamic sql like that
$valueDeclare .= $row2['FirstName'].$row2['LastName'].', ';So in my insert this variable give me the FieldName
and in the same while i build my $_POST variable for my sql sentence
$valueRadio .= "'".'".$_POST['."'".'rd'.$row2['FirstName'].$row2['LastName']."'".']."'."', ";This value is '".$_POST['rdYanViau']."'
After that i build my sql with those 2 variables, the problem is when i execute my sql insert where he's supose to insert my rdButton value ... it's insert the string '".$_POST['rdYanViau']."' who give me a 0 in the table, he's not getting the value of '".$_POST['rdYanViau']."' he's inserting the string in the table.
Here's the echo of my sql sentence :
INSERT INTO sondage (idSondage, username, idMatch, YanViau, YanViau2, YanViau3) VALUES (NULL , 'admin', '1', '".$_POST['YanViau']."', '".$_POST['YanViau2']."', '".$_POST['YanViau3']."')my echo should look like :
INSERT INTO sondage (idSondage, username, idMatch, YanViau, YanViau2, YanViau3) VALUES (NULL , 'admin', '1', '1', '2', '1')How i can build this dynamic sentence and have the radiobutton value and not the string value ...
I hope you can understand my problem.
Yan.
-
thx for your help
-
Sorry maybe some feedback from other language, im new with php
in my mind the easiest and normal thing is something like this but i know it's doesn't work.
include ('class/general.php');
global $instance = new General();
function something()
{
$instance->check()
}
-
Thanks a lot for your help !
im gonna read this
any other solution ?
i would like prefer to have a variable that i don't need to pass in the function if it's possible.
-
Hola to all php coder,
Probably an easy one for you.
Page.php
include ('class/general.php');
$instance = new General();
function something()
{
$instance->check()
}
general.php
<?php
class General
{
function check()
{
echo "world";
}
}
Why the call of my class function doesnt work ?
when my class declaration is outside the function = BOUM error
When my class declaration is inside my function = working
So i understand the fact than i need a global variable or something like that but i try to
include ('class/general.php');
global $instance;
$instance = new General();
And it's not the solution.
Someone have any tips ?
Sorry for my english.
Building an Dynamic SQL before POST
in PHP Coding Help
Posted
same problem as before, because i put de {} on my variable concatenation so the { is in the string and not a php code