PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi all
I'm having problem with query retrieved from database.
this is query inserted into db with addslashes
[syntax="sql"]
SELECT
SUM(izostanci.neopravdano) AS neopravdano,
ucenici.prezime,
ucenici.ime
FROM
ucenici
INNER JOIN izostanci ON (ucenici.id = izostanci.ucenik)
WHERE
(izostanci.skola = '" . $_SESSION["odabrana_skola"] . "') AND
(izostanci.sk_god = '" . $_SESSION["odabrana_skolska_godina"] . "') AND
(ucenici.aktivan = '1')
GROUP BY
ucenici.prezime,
ucenici.ime
ORDER BY
neopravdano DESC
when I want to execute it it does nothing, and if I replace values that are in sessions
SELECT
SUM(izostanci.neopravdano) AS neopravdano,
ucenici.prezime,
ucenici.ime
FROM
ucenici
INNER JOIN izostanci ON (ucenici.id = izostanci.ucenik)
WHERE
(izostanci.skola = '1') AND
(izostanci.sk_god = '1') AND
(ucenici.aktivan = '1')
GROUP BY
ucenici.prezime,
ucenici.ime
ORDER BY
neopravdano DESC
it works perfectly.
How can I get it working retrieved from db with sessions inside query?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
$sql_upit = mysql_query("select * from statistike where id='$vrijednost'") or die (mysql_error());
$sql_rez = mysql_fetch_array($sql_upit);
$query = stripslashes($sql_rez['upit']); // here comes retrieved from db query shown in example 1
$result = mysql_query($query) or die( mysql_error() );
$number_cols = mysql_num_fields($result);
browser source of table where result should be shown is