So... in the sample login script when they used this line:Celauran wrote:I wasn't so much talking about assigning an array to the $_SESSION variable as I was pointing out that the $_SESSION variable is an array. Storing a user's ID in the $_SESSION array is common practice and a good way to keep track of your logged-in users.Pavilion wrote:About the $_SESSION variable, after submitting my last post I did figure out it is possible to declare an array with the $_SESSION variable. This makes sense, because if one has to consistently access the same table (UserTbl), then assigning a $_SESSION variable array to this table makes sense. But, if I assign an array to $_SESSION, is there a way to also assign a global variable to $row['user_id']?
Code: Select all
$_SESSION = mysqli_fetch_array($result_check_credentials, MYSQLI_ASSOC);In the end... is it better to assign an array of data to $_SESSION, or just one field (like "user_ID")? That is why I am curious about assigning a global variable to both the fetch_array and to one $row[user_id]. Or do you have to choose just one global variable to put in the <head>?
Well - this question goes to my classical database experience. In classical databases the one-to-many relationship is so much more flexible. In one form, I can give users the ability to add and edit data in multiple tables, Moving to php - html environment has been a challenge to me on many levels, but the biggest challenge is the way I think about one-to-many relationships in building forms.I'm not quite sure what you mean here. Can you provide a more specific/detailed example?Pavilion wrote:Also, if I assign an array to $_SESSION, then can I also query another table and set other arrays within page actions? For instance, if I want users to insert data into another table, can I write INSERT or SELECT queries on this other table and get arrays from those queries?
So... if it is possible to store an array of data in the global $_SESSION variable, is it also possible to use that variable for input?
In addition - can I create input MySQL statements on other tables within the same php document as well?
For the application I'm thinking of, my users (employees) will be requesting flex times from their employer. Since one employee can request multiple flex times, then the requests have to be stored in their own table. Of course, if $_SESSION is $row[user_id], then I'll be able to pass that value to the insert statement. But, if the employee has priority blocks of times stored in another table, then I may also have to access this data during the "request" process. So... for one request. I may have to pull data from the UserTbl, a PriorityTime Table, and AvailableTime table - all to create one request.
I can picture how to do this in a classical database, in fact it is already up and running in a classical database and has been for years. They just want to move the capability to the web (and they are willing to work with me as I learn php/html/css).
But... I cannot yet picture how I am going to pull all these different pieces of the puzzle together in a web environment.
Hope this explanation helps you understand my original question.
ThinSoldier - Thank you for your advice. I have taken it to heart. Since I am a newbie at all of this, I must accommodate for "even the slightest syntax error".Actually XHTML is not what should be used. If you're not sending xml headers along with that doctype the browser is really just interpreting it as tag soup. If you do send the xml headers IE will treat it as proper xml/xhtml and kill the entire page IF there's even the slightest syntax error in your markup.
Use the HTML5 doctype: <!DOCTYPE html>
Yes IE 6,7,8 & 9 lack many features from HTML5 and its related technologies (javascript, css3, etc) But they do switch to their most standards compliant rendering mode when they encounter the HTML5 doctype and that's really what the doctype is used for.
Thanks to both of you - your advice is appreciated.
Pavilion