cowboysdude Posted June 1, 2008 Share Posted June 1, 2008 <?php $sql = "SELECT DATE_FORMAT(registerDate, '%m/%d/%Y') as registerDate FROM jos_users"; $res = mysql_query($sql); while ($row = mysql_fetch_assoc($res)) { echo $row['registerDate'], '<br />'; } $sqlr = "SELECT userid FROM jos_session"; $resr = mysql_query($sqlr); while ($row = mysql_fetch_assoc($resr)) { echo $row['userid'], '<br />'; } ?> This is what I have.... I have the date format working as well as the user id [Thanks for the help ;-)] but now if I don't compare and make sure I have the right user this is what I get 05/05/2008 05/10/2008 05/12/2008 05/07/2008 05/07/2008 05/22/2008 05/08/2008 05/08/2008 05/08/2008 05/08/2008 05/22/2008 05/08/2008 05/16/2008 05/13/2008 05/09/2008 05/09/2008 05/09/2008 05/09/2008 05/09/2008 05/27/2008 05/10/2008 05/12/2008 05/12/2008 05/12/2008 05/31/2008 05/23/2008 05/19/2008 05/25/2008 05/20/2008 62 62 I get all the registerDates for ALL the users and ID twice.. Well what I need to do is compare the id to the RegisterDate and make sure they match so I can have my output say this: User Since: 05/20/2008 Thank you!! I swear after this I'm gonna go and take a class !!! lol Quote Link to comment Share on other sites More sharing options...
whizard Posted June 1, 2008 Share Posted June 1, 2008 how about $sql = "SELECT DATE_FORMAT(registerDate, '%m/%d/%Y') as registerDate FROM jos_users WHERE id = $id"; assuming $id holds the ID of the user you are looking up HTH Dan Quote Link to comment Share on other sites More sharing options...
cowboysdude Posted June 1, 2008 Author Share Posted June 1, 2008 how about $sql = "SELECT DATE_FORMAT(registerDate, '%m/%d/%Y') as registerDate FROM jos_users WHERE id = $id"; assuming $id holds the ID of the user you are looking up HTH Dan Well I've tried just about everything.. at this point I'm totally frustrated... Your line returned an error because I don't have $id defined... so I tried this.. $sql = "SELECT DATE_FORMAT(registerDate, '%d/%m/%Y') as registerDate FROM jos_users WHERE SELECT userid FROM jos_session"; and got this: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /public_html/modules/mod_euser/mod_euser.php on line 29 This can't be this hard... I think I'm just making it REALLY difficult.. after 3 days of this I think I've just grown to frustrated... Quote Link to comment Share on other sites More sharing options...
cowboysdude Posted June 1, 2008 Author Share Posted June 1, 2008 how about $sql = "SELECT DATE_FORMAT(registerDate, '%m/%d/%Y') as registerDate FROM jos_users WHERE id = $id"; assuming $id holds the ID of the user you are looking up HTH Dan Well I've tried just about everything.. at this point I'm totally frustrated... Your line returned an error because I don't have $id defined... so I tried this.. $sql = "SELECT DATE_FORMAT(registerDate, '%d/%m/%Y') as registerDate FROM jos_users WHERE SELECT userid FROM jos_session"; and got this: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /public_html/modules/mod_euser/mod_euser.php on line 29 This can't be this hard... I think I'm just making it REALLY difficult.. after 3 days of this I think I've just grown to frustrated... How about if I use an "IF" statement like this... <?php IF $registerDate!=$id THEN die( 'Direct Access to this location is not allowed.' ); [ELSEIF $sql = "SELECT DATE_FORMAT(registerDate, '%d/%m/%Y') as registerDate FROM jos_users"; $res = mysql_query($sql); while ($row = mysql_fetch_assoc($res)) { echo 'User Since: $row['registerDate']', '<br />'; }] END IF ?> I know the formatting is wrong becasue I get an error but ... It's the only thing I can think of to compare registerdate against userid to make sure the output is correct.. new error: Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /public_html/modules/mod_euser/mod_euser.php on line 27 Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted June 1, 2008 Share Posted June 1, 2008 well $sqlr = "SELECT userid FROM jos_session"; will grab all the ids in the table jos_session are you sure thats what you want? Quote Link to comment Share on other sites More sharing options...
cowboysdude Posted June 1, 2008 Author Share Posted June 1, 2008 well $sqlr = "SELECT userid FROM jos_session"; will grab all the ids in the table jos_session are you sure thats what you want? It would be easier to tell you what I"m trying to do here. I firstly grabbed the $registerDate and formatted it from 2008-05-31 to 05-31-2008..that worked but since my output was "User Since : $registerDate what I ended up with was All the register dates from all the users... basically a long list of RegisterDates. So I figured I had to compare it to something to get the out put for only the user who was logged in and viewing it on the page. Basically a personal touch thing. so if Bob where logged in and he registered on 05-12-2008 it would tell him that, if I were logged in and I registered on 05-05-2008 it would show me that.. SO far I've gotten the date formatted correctly but then it goes downhill from there... I cannot get it to show the user when he/she registered. Please, if I"m not being clear let me know. I'm trying to explain as much as I can... but I'm new.. SO.. I went to the userid field in the jos_session thinking it would be easy to compare the userid to the registerdate but thinking that maybe if I compare the userid to the username THEN pull the RegisterDate it may print out correctly. Next problem is how to write that to make it happen.. so there is my problem...lol I know... I make it sound like an easy problem but.. I'm thinking it can't be that hard to compare data to ensure the correct date is being pulled and formatted for display to the end user. Thanks!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.