Select command based in Post

QuestionsSelect command based in Post
C3media asked 4 years ago

Hi,

I have tried a query and works fine, I need to load grid based in post value from other page in comparison value into query. this is my query:
SELECT
`demo_candidatos`.`demo_eleccion_ideleccion` AS `Ideleccion`,
`demo_candidatos`.`idcandidatos` AS `Idcandidatos`,
`demo_candidatos`.`nombre` AS `Candidatos`,
`demo_candidatos`.`numero` AS `Numero_Tarjeton`,
`demo_candidatos`.`tarjeton` AS `tarjeton`
FROM
(`demo_candidatos`
JOIN `demo_eleccion`,`demo_voting`)
WHERE
((`demo_eleccion`.`ideleccion` = `demo_candidatos`.`demo_eleccion_ideleccion`)
AND (`demo_eleccion`.`estado` = 'Abierto') AND (`demo_eleccion`.`ideleccion` = `_POSTVAR`)AND
(`demo_eleccion`.`ideleccion` = `_POSTVAR`)AND
(`demo_eleccion`.`ideleccion` = `_POSTVAR`))
GROUP BY `demo_candidatos`.`idcandidatos`

Thanks!

1 Answers
Abu Ghufran answered 4 years ago

To use POST data in query, you need to persist them in session first.
e.g.

if (!empty($_POST["personid"]))
{
$_SESSION["personid"] = $_POST["personid"];
}
$pid = $_SESSION["personid"];

and use `$pid` in your SQL.

In case you are facing some query error after, you can send database test dump on [email protected] to regenerate case.

Your Answer

4 + 0 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?