Jump to content

Recommended Posts

<?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..  :o

 

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

 

Link to comment
https://forums.phpfreaks.com/topic/108198-cant-figure-this-out/
Share on other sites

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...

 

Link to comment
https://forums.phpfreaks.com/topic/108198-cant-figure-this-out/#findComment-554638
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/108198-cant-figure-this-out/#findComment-554643
Share on other sites

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!!

Link to comment
https://forums.phpfreaks.com/topic/108198-cant-figure-this-out/#findComment-554646
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.