RE: [PHP-DB] Photo Album Schema

2001-08-21 Thread Tyrone Mills

I think this idea is an excellent one, if your going for 1 huge directory.
Store the original filename in the DB and the uniquely generated filename,
so that you know what file to load and can display a meaningful filename to
the viewer. Personally I'd go with seperate directories, but that's just
personal preference...

-Original Message-
From: Paul Burney [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 10:04 AM
To: php mailing list
Subject: Re: [PHP-DB] Photo Album Schema


on 8/21/01 9:58 AM, Sheridan Saint-Michel ([EMAIL PROTECTED]) wrote:

 If you are going to use a single directory with a filename
 convention I would suggest something simple, yet unique
 like

 id . filename

 Where id is the unique userid from the DB and filename
 is the original name of the file.

 This would avoid conflicts (which is the point of a naming convention)
 and be fairly easy to implement.

Be careful for bad characters in filenames.  You should probably
preg_replace a few things in the filename first (*/;).  You may also need
to code something warning the user if they are about to overwrite a file
whose name already exists.

I usually just name a file based on the timestamp, i.e.,

$parts = explode(' ',microtime());
$parts[0] = substr($parts[0],2);
$file_name = $parts[1] . $parts[0] . $file_extension;

You should also look at using the GetImageSize function to determine whether
or not the file is really an image.

Good luck.

Sincerely,

Paul Burney

+-+-+
| Paul Burney | P: 310.825.8365 |
| Webmaster  Programmer | E: [EMAIL PROTECTED]   |
| UCLA - GSEIS - ETU   | W: http://www.gseis.ucla.edu/ |
+-+-+


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Trying to pull a weeks worth of data of a DATE entry

2001-05-15 Thread Tyrone Mills

Hi Marc,

If I understand your question correctly, the SQL Syntax you might want to
try would be:

SELECT col_1, col_2 FROM table_name WHERE date_col = $from_date AND
date_col = $to_date

Or if you want to get each days results individually, you could do something
like this in a loop, where $loop starts at 0 and is incremented and
$from_date is the date you wish to start out with:

SELECT col_1, col_2 FROM table_name WHERE date_col = DATE_ADD($from_date,
INTERVAL $loop DAY)

I'm sure there are at least a dozen other ways to attack this, hopefully
these will give you something to work with and are perhaps helpful.

Enjoy!

Tyrone

-Original Message-
From: Marc Johnson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 4:19 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Trying to pull a weeks worth of data of a DATE entry


I am trying to pull a weeks worth of data from MySQL from a DATE var field.
Which in turn I can seperate to each days 'entries' sorted by date AND time.
Basically trying to set up a page to pull 'news entry date' sorted by date
and time, with each
day having its own header (like you see on so many websites) and having that
header appear
only once per days worth of 'news'.

Not really sure where to start considering I have only been at this for two
days. My scripting skills
are limited so far so I am sure that the approach I am taking is the hard
way.

Can anyone provide me with a link to examples of this code (the actual code)
so I can see how it has been done?
Or perhaps if its a easy solution (i.e. SELECT date (from date to date)
type command). I have seen examples of
sorting by date and munipulation of the date via SELECT, but cant seem to
pinpoint how to extract only from-to dates.
Even if I can use a SELECT command where date = x would work.

Any help, or pointing in the right direction would be greatly appreciated
(and probably save money on my Rogain bills).

Thanks,

Seriously Confused in Seattle,
Marc



I have tried multiple attempts at some variation of:

   $week_var = 7;
   $tdate = getdate();
   $yday_var = $tdate['yday'];
   $wdate = $yday + $week_var;


Granted



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Can't get my head around this problem...

2001-04-24 Thread Tyrone Mills

That will zero fill any elements that don't have data, but it won't move the
data in the elements to the right positions. Each element is supposed to
represent a day of the week, starting at Sunday. So if I have data
representing calls that came in on Tuesday and Thursday, I need that data in
elements 2 and 4. The way it comes from my query, the data is at elements 0
and 1. So yes, I do need to add the zero's to the other 5 days, which your
code does (much neater than any of my attempts as well), but it doesn't
arrange the data the way I need.

Thanks for taking a shot at it though, I appreciate it!

-Original Message-
From: Szii [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 6:27 PM
To: Tyrone Mills; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Can't get my head around this problem...


Perhaps...?

$x = 0;
while ($x  7)
{
  if (!isset($myArray[$x]))
  {
 $myArray[$x] =0;
  }
}

-Szii

- Original Message -
From: Tyrone Mills [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 24, 2001 3:58 PM
Subject: [PHP-DB] Can't get my head around this problem...


 Hello all...

 I've got what is probably a stupid question, it's a problem I can't seem
to
 get my head around it. Any help will be greatly appreciated.

 I'm pulling a count of connections from a MySQL database and the day of
the
 week it occurred on. Now the result set doesn't include empty values, so
if
 there were connections on only 2 days, I only get 2 rows returned, if
there
 were connections on 4 days, I get 4 rows returned. You get the idea...

 Here is the PHP code I am using the get the data:

 $sql = SELECT COUNT(*), (DAYOFWEEK(dialer_login_date) -1) AS DAYOFWEEK
FROM
 dialer_login WHERE dialer_id = $dialer_id AND
 WEEK(date_format(dialer_login_date, '%Y-%m-%d'),0) = WEEK('$last_week',0)
 GROUP BY DAYOFWEEK;

 $result = db_query($sql);

 while ($daily_count = db_fetch_array($result))
 {

 $lastweek[] = $daily_count[COUNT(*)];
 $day[] = $daily_count[DAYOFWEEK];

 }

 For the sake of this question, let's say that there were connections on
only
 2 days, so we get a result set with 2 rows. Something like this:

 COUNT(*) DAYOFWEEK
 8 2
 3 4

 That's great, but I need the array $lastweek to have the value 8 in
element
 2 and the value 3 in element 4 and all other elements (0,1,3,5,6) as zero.
 As it sits, they are in elements 0 and 1 respectively.

 I get this:

 $lastweek[] = 8,3

 I need this:

 $lastweek[] = 0,0,8,0,3,0,0

 Now I've written all manner of wild and wonderful loops that iterate
through
 either $lastweek or $day and try and build a proper array. Invariably
 something doesn't work right. I'm sure I'm grossly over complicating this,
 but I am at my wits end. Any thoughts or ideas are most welcome.

 Thanks!!

 Tyrone Mills
 
 UNIX is user-friendly, it's just picky about who its friends are...





 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Can't get my head around this problem...

2001-04-24 Thread Tyrone Mills

Thanks Alex!! I'll give that a go!

-Original Message-
From: Alexander Fordyce [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 8:07 PM
To: Tyrone Mills; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Can't get my head around this problem...


Looks to me like you'd be better off using an associative array, since
associating the count with the day of the week is the whole point.  How
about...

while (list($count, $day) = db_fetch_row($result))
$lastweek[$day] = $count;

You'd have to tweak the logic of the rest of the script to use the hash, but
it's a more natural way to do it.  Just a suggestion...

-Alex


 -Original Message-
 From: Tyrone Mills [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 24, 2001 3:58 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Can't get my head around this problem...


 Hello all...

 I've got what is probably a stupid question, it's a problem I can't seem
to
 get my head around it. Any help will be greatly appreciated.

 I'm pulling a count of connections from a MySQL database and the day of
the
 week it occurred on. Now the result set doesn't include empty values, so
if
 there were connections on only 2 days, I only get 2 rows returned, if
there
 were connections on 4 days, I get 4 rows returned. You get the idea...

 Here is the PHP code I am using the get the data:

 $sql = SELECT COUNT(*), (DAYOFWEEK(dialer_login_date) -1) AS DAYOFWEEK
FROM
 dialer_login WHERE dialer_id = $dialer_id AND
 WEEK(date_format(dialer_login_date, '%Y-%m-%d'),0) = WEEK('$last_week',0)
 GROUP BY DAYOFWEEK;

 $result = db_query($sql);

 while ($daily_count = db_fetch_array($result))
 {
   $lastweek[] = $daily_count[COUNT(*)];
   $day[] = $daily_count[DAYOFWEEK];
 }

 For the sake of this question, let's say that there were connections on
only
 2 days, so we get a result set with 2 rows. Something like this:

 COUNT(*)  DAYOFWEEK
 8 2
 3 4

 That's great, but I need the array $lastweek to have the value 8 in
element
 2 and the value 3 in element 4 and all other elements (0,1,3,5,6) as zero.
 As it sits, they are in elements 0 and 1 respectively.

 I get this:

 $lastweek[] = 8,3

 I need this:

 $lastweek[] = 0,0,8,0,3,0,0

 Now I've written all manner of wild and wonderful loops that iterate
through
 either $lastweek or $day and try and build a proper array. Invariably
 something doesn't work right. I'm sure I'm grossly over complicating this,
 but I am at my wits end. Any thoughts or ideas are most welcome.

 Thanks!!

 Tyrone Mills
 
 UNIX is user-friendly, it's just picky about who its friends are...





 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Creating tables

2001-04-24 Thread Tyrone Mills

Hi Herman,

Try something like this...

$dbname = my_db;
$tablename = my_table;

$table_def = item_id MEDIUMINT DEFAULT '0' NOT NULL AUTO_INCREMENT,;
$table_def .= item_name VARCHAR(50) BINARY NOT NULL,;
$table_def .= lastaccessed TIMESTAMP(14),;
$table_def .= PRIMARY KEY (item_id),;
$table_def .= UNIQUE item_id (item_id);

if(!mysql_select_db($dbname)) die;

if(!mysql_query(CREATE TABLE $tablename ($table_def))) die;

It's not the prettiest code in the world, I am sure of that. But it should
give you a start.

I hope this helps!

-Original Message-
From: Herman Wapenaar [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 11:00 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Creating tables


Hi everyone

I am using a website based in the states to which is PHP enabled. I am using
MySQL.

Is there a way to create a table with PHP? I do not see any command for
that.

I have loaded MySQL for Windows but the server runs MySQL on Unix. I don't
know if the file structure is different. Maybe that is why I can not read
it?

Thanks
Herman Wapenaar



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]