
dgiberson
Members-
Posts
87 -
Joined
-
Last visited
Never
Everything posted by dgiberson
-
How I handle timeouts is this... In my activeUsers table I store their ID, IP Address, Last Active (TimeStamp), Expires (TimeStamp). This way I can query the db to prevent multiple instances, it updates the table (last active & expires) when they move around the site. So if they don't explicitly logout and just walk away from their computer when an attempt to login/move around the site using that username occurs, I can check against the user to see if their session has expired and force them to login again.
-
np, anytime
-
Robin's code will work, here is an alternative: SELECT * FROM table WHERE < condition statements here> ORDER BY <whatever> LIMIT 1229, 5
-
find the last entry in a table by a specified user
dgiberson replied to goatboy's topic in PHP Coding Help
no problem -
to me it appears your while loop is before where you attain the information from the database.
-
find the last entry in a table by a specified user
dgiberson replied to goatboy's topic in PHP Coding Help
SELECT * FROM table WHERE userid = $userid ORDER BY date_time DESC LIMIT 1 -
change the line $_SESSION['login'] == $Username; to $_SESSION['login'] = $Username;
-
Just a suggestion, you might want to switch over to POST, although I am not sure at what your goal is for this specific page.
-
yeah whatever you want the logged in user to see
-
on whatever page just use: if (isset($_SESSION['login']) { // displaying information to logged in user } else { echo "You must be logged in to view this page."; }
-
1. The checkboxes will always be returned as an array. How are you handling the best day of the week information in your database? 2. My error on the select box last time. Should be: <td class="body" align="center"><select name="appt_for"> <option value="myself">Myself</option> <option value="son">My Son</option> <option value="daughter">My Daughter</option> <option value="Other">Other</option> </select></td> $appt_for = $_POST['appt_for];
-
Use Array or Database? Which way to go from here
dgiberson replied to MikeDizzle's topic in PHP Coding Help
no problemo, anytime -
Are you using the GET/REQUEST or POST method?
-
could you maybe explain this a bit more? do you mean like? | Col 1 | Col 2 | Col 3 | | $var1 | $var2 | $var3 | or Row 1 | $var 1 Row 2 | $var2 Row 3 | $var3 ?
-
Use Array or Database? Which way to go from here
dgiberson replied to MikeDizzle's topic in PHP Coding Help
in the foreach() loop $my_array[$i][0] = $ns_g->year; $my_array[$i][1] = $ns_g->make; etc... $my_array[$i][5] = $ns_g->price; $i++ some people like to use keys for their arrays, personally i don't care.... -
[code]<tr> <td class="body" align="left">Best Days For You (select all that apply):</td> <td class="body" align="center"><input type="checkbox" name="best_days[]" value="best_days">Monday <input type="checkbox" name="best_days[]" value="best_days">Tuesday <br> <input type="checkbox" name="best_days[]" value="best_days">Wednesday <input type="checkbox" name="best_days[]" value="best_days">Thursday <br> <input type="checkbox" name="best_days[]" value="best_days">Friday <input type="checkbox" name="best_days[]" value="best_days">Saturday </td> </tr>[/code] Then the drop down selectors, here's the snippet for that: [code]<tr> <td class="body" align="left">Appointment is for:</td> <td class="body" align="center"><select name="appt_for"> <option value="appt_for">Myself</option> <option value="appt_for">My Son</option> <option value="appt_for">My Daughter</option> <option value="Other">Other</option> </select></td> </tr>[/code] Then where ever the form directs to : [code] if (isset($_POST['best_days')) { $best_days = $_POST['best_days']; // $best_days will now be an array. } else { //check box has not been selected, do whatever you need to here } $appt_for = $_POST['appt_for']; [/code]
-
Use Array or Database? Which way to go from here
dgiberson replied to MikeDizzle's topic in PHP Coding Help
I guess it all depends how far down the line you want to access this information... if it's a one time thing go with an array, otherwise setup a table to store the information. -
You also do not require the [] on the appt_for select box, unless you making it into a multiple selection box.
-
the issue is with the for loop. for ($cnt=1;$cnt<$var;$cnt++){ // echo table rows here }
-
can't compare a blank var with a blank $_POST var
dgiberson replied to charmquark's topic in PHP Coding Help
if (isset($_POST['coef']) { if ($_POST['coef'] == $coef) { //do something } } -
can't compare a blank var with a blank $_POST var
dgiberson replied to charmquark's topic in PHP Coding Help
if (isset($_POST['coef'])){ echo "variable is set"; }else{ echo "variable is not set"; } -
SELECT * FROM table1 WHERE timestamp <= '$user_timestamp' ORDER BY id LIMIT 1,10 // return 1st 10 records SELECT * FROM table1 WHERE timestamp <= '$user_timestamp' ORDER BY id LIMIT 11,10 // return 11-20 SELECT * FROM table1 WHERE timestamp <= '$user_timestamp' ORDER BY id LIMIT 21,10 // return 21-30 etc.... The query returns on this should be extremely fast no matter the table size
-
Newbie question on date formatting
dgiberson replied to Unprepared for PHP's topic in PHP Coding Help
$date = query field from database. echo date("%y-%m-%d", $date); -
What db are you using? mysql, oracle? Is it setup for table or row locking?
-
So you're querying for the entire recordset on every pagination then? Why not limit the query to 10 results, specifying which start / end point for the resultset to return? I'm a missing something here, is this what you are already doing?