N30Cr0n Posted August 8, 2006 Share Posted August 8, 2006 Hi, i have been building a football prediction website, found here [url=http://premscore.smokingunz.co.uk]http://premscore.smokingunz.co.uk[/url], and i have run into a problem with part of the design.what i would like to happen, is that when a user logs in, the username is stored somehow, and then i can reference that username in a generic select statement, so i can create one page, but it will show different data depending on the username.i know this is done with sessions, and i am using php-nuke, which has a table called [b]nuke_sessions[/b], and this stores the username of all currently logged in users. so thats that session part covered, i can use that, but what i want is this,on a page called, say predicta.php, i want to start by pulling the session data for username from nuke_sessions, and then form a new query based on this, e.g.[code]<?php ....start of page code$sql = "SELECT uname FROM ".$prefix."_session WHERE uname='$username'"; //query to SELECT username data from session table$result = $db->sql_query($sql);$row2 = $db->sql_fetchrow($result);$entrant = $row2[uname];$aug01 = $db->sql_query("SELECT id, team_a, team_b, date, time, score_a, score_b FROM predictions_".$entrant." WHERE date = '2006-08-19' ORDER BY date ASC"); //query to SELECT data from specific table based on session data selected above....rest of page code below?>[/code]so from that i would expect that it pick the username data from nuke_session, and store it for use in the select query to pick the data up from predictions_(username from session table) e.g. predictions_johnsmith, because johnsmith is the username logged in the session table.what i get, is the framework of the page, but no data, and when i [color=blue][b]echo[/b][/color] the sql queries, the output to the page is an empty line, so i am missing something, as the request is not being processed. can anybody spot it and help out/ solve it?thanks a million Link to comment https://forums.phpfreaks.com/topic/16884-using-session-data-to-form-a-new-select-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.