- This topic is empty.
-
AuthorPosts
-
December 11, 2010 at 2:16 pm #30973
Hadley17
MemberHello,
this is the chunk of code i have so far,
//call the session variable from the registration page
$userNameLog = $_SESSION;
$query = "SELECT game_name, game_genre, company, system, bge, comments
FROM mylist
WHERE username = '" . $userNameLog. "'";
echo $query;
//submit query
$rs = mysqli_query($oConn, $query);
//create a variable to hold the array of data in your database
$myarray = mysqli_fetch_array($rs);
//create variables to hold the data in each field
$oldGameName = $myarray;
$oldGenre = $myarray;
$oldCompany = $myarray;
$oldSystem = $myarray;
$oldBGE = $myarray;
$oldComments = $myarray;
//add the session variable into a variable to be able to echo it out.
echo $myarray;Basically, the user that logged in, creates a random list(fills out my form) now i want them to see what is in the database, but for some reason this order isn’t working.. This basic format worked for displaying their profile but for the list it doesn’t work.
I’m sure it has something to do with the query and I dont know how to connect the logged in user and the mylist table in sql and then display the info..
Help or guidance would be sweet!
December 11, 2010 at 4:32 pm #70013TT_Mark
MemberHi Hadley,
You cannot ‘echo’ an array if that way. To write an array to the page you need to use
print_r($myarray)
However, what you need to do is write out the other variables that you have assigned your results to e.g.
echo $oldComments
December 12, 2010 at 7:18 pm #69942Hadley17
Memberi was just echoing the myarray to see if anything was actually present in it.. and second well, when i echo the variables that hold the certain parts of the DB, it doesn’t echo anything out…
December 13, 2010 at 12:35 pm #69966Rob MacKay
ParticipantWhat he means is you actually just can’t echo an array – as in it’s impossible it will show nothing. You have to echo specific values or dump the whole thing with print_r(). print_r(); will show you the keys and values of all your entries. If you wrap it in pre tags you will get a nicely formatted display too…
echo "";
print_r($myarray);
echo "";
December 13, 2010 at 5:57 pm #69979Hadley17
Memberok well, i still can get them to display and time is running short to get this done :(.. i dont even understand php.
im getting the values from my form inserted into my table, which is good.
next, they dont wanna display.. and how can we set this up so when I keep filling out this form, it keeps adding them to the page.. my while loop isnt working too too well :S
December 14, 2010 at 5:57 am #69896Rob MacKay
ParticipantWell you need to be using mysqli properly. Off the top of my head
$rs = new mysqli($HostName, $UserName, $Password, $DBName);
$query = "SELECT game_name, game_genre, company, system, bge, comments
FROM mylist
WHERE username = $userNameLog";
$result = $rs->query($query);
$myarray = $result->fetch_array(MYSQLI_ASSOC);
echo "";
print_r($myarray);
echo "";
If that dosen’t work or something around that, check the manual on the functions you are trying to use…
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.