[PHP-DB] making my own week? :)

2003-01-15 Thread Matthew Nock
Hi All,

I am currently building a website for a cinema - and a cinema week runs from Thursday, 
to Wednesday.

I need some help with how to get PHP to work with one week periods, but having the 
week starting on a Thursday, instead of Sunday, or Monday.


The week will be used to generate dynamic list boxes, and database queries...  

Anyone done anything like this before that may be able to shed a little light? 

If anyone is experienced with this sort of date manipulation let me know what info 
you need and I will provide it where possible.

Cheers,


Matt



[PHP-DB] Design suggestions - performance improvement

2003-01-09 Thread Matthew Nock
Hi all,

I am currently building a site for a cinema to display session times, film synopsis' 
etc...

I have built the database as follows:

TABLE:  film_detail
FilmID
FilmName
FilmRunTime
FilmRating
FilmSynopsis
etc...

TABLE  session_data
session_ID
session_filmID
session_StartTime
session_Date


The session_data table might contain a large number of records with the same film ID, 
and the same Start Date to cover a large number of sessions that we would have of the 
same film on the same day.

I want to know what is the best way to retrieve this joint info from the DB.

currently, I run a single select statement requesting the fields I want from both 
tables, where the session_Date equals a given date.  This returns x number of rows, 
depending on the number of sessions for all films for that given day.

However, this means that I am retrieving the Film Synopsis, cast, runtime etc multiple 
times...

The data will be returned to the user as below:

FILM TITLE (rating)
session_times--- will list all sessions - such as 8.45am, 10.15am, 12.00pm, 
2.00pm etc etc
FILM RUNTIME
FILM CAST
FILM SYNOPSIS

is this an effective way to return to he data?  or should I be using individual 
queries?

Any comments or suggestions would be most appreciated..

Cheers,


M@



[PHP-DB] Inserting records across multiple mySQL forms - tracking ID's?

2002-07-05 Thread Matthew Nock

I want to create a form that will input a number of records, into a number
of different tables.

The first part of the detail will need to create a new product record.
this will create Product ID.  the Product ID is required to insert the
features for this product ID into another table.

Is there any way that run determine the ProdID of the record I am inserting,
so that I can run the insert for the features?

or am I going to need to Insert the Product record (to get the Product ID),
and then query the product database, to get the new ID, then use the newly
gained ID, to add all the features to the feature table?


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Traversing an array usng for loops?

2002-06-29 Thread Matthew Nock

I have a query which returns a number of product details.

there may be one or more rows for each product category  for example:


prod_ID feature_ID  feature_cat_ID  feature_value .
1   2   1   10
1   1   2   100
1   4   6   4
1   87  1   500


how do I process this array so that all my results for each feature-category
are processed in their own for loops?

ie : I want to go through the array for feature-category 1, and create a row
in a HTML Table for each feature in category 1..  then move the category
two, then three and so on.

help! :)




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Whats more efficient....?

2002-06-23 Thread Matthew Nock

Is it more efficient to run a SELECT query on a MySQL database that
retrieves maybe 100 records from approximately 6 tables (based on one
result - such as a product ID) and then process these results using PHP

or is it more efficient to run say 6 SELECT statements that get the exact
details we want, and in the process returning a smaller number of results
over all?

If its the first of the two, then is it possible to use the MySQL Group by
structure to group the results, and store the results of each group (for
example a product category) in separate arrays?

ie;  array_prodcat1, array_prodcat2 etc etc?



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Re: Converting values from text to numerical

2002-06-21 Thread Matthew Nock

Hi All,

upon looking at the link Russ gave me earlier... the PHP site recommends the
use of is_numeric() function.

This does exactly what I want..  there will only be numbers of text in the
field.

I can quickly run this returned result from the record through this
function..  and if it is numeric, then I do one thing (the calc), if its
just text, I just echo it to screen.

I will be keeping any dates etc in separate fields.

So, the is_numeric() does what i need :)

Thanks everyone :)


-Original Message-
From: Andy [mailto:[EMAIL PROTECTED]]
Sent: Friday, 21 June 2002 4:22 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: Converting values from text to numerical


yes you can switch the type of var for examle with:

$number = (integer)$textvar;

But if you do store it as a textfield you want be able to do some special
sql stuff directly in mysql.

For example if you store the date as text in the db you want be able to
filter out entries which are between x and y.

Good luck,

Andy

--

http://www.globosapiens.net
Global Travellers Network!



Matthew Nock [EMAIL PROTECTED] schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I am about to build a database of products that will store features fore
ach
 product in a separate table.

 I need to be able to store both text and numeric values in this table, but
 be able to perform mathmatical functions on the numeric variables.

 is it possible to have PHP covert numbers that are stored as text strings
 back into values it can calculate with?




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Converting values from text to numerical

2002-06-20 Thread Matthew Nock

I am about to build a database of products that will store features fore ach
product in a separate table.

I need to be able to store both text and numeric values in this table, but
be able to perform mathmatical functions on the numeric variables.

is it possible to have PHP covert numbers that are stored as text strings
back into values it can calculate with?


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Converting values from text to numerical

2002-06-20 Thread Matthew Nock

Hi Russ,

Thanks for the reply.

I was looking more along the lines of having one field, that might store
either a text value (such as the words Not included), or a numeric value,
such as 10.

The using PHP to determine if the value is numeric, perform a function on it
(such as a calculation) then display the result, otherwise, just display the
text.



-Original Message-
From: Russ [mailto:[EMAIL PROTECTED]]
Sent: Friday, 21 June 2002 2:53 PM
To: Matthew Nock; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Converting values from text to numerical


is it possible to have PHP covert numbers that are stored as text
strings
back into values it can calculate with?

Mathew:

You can use PHP to convert these - dependant upon the way you store them
in your DB.
Foe example I sometimes need to store different types of data in the
same field (I suppose you need to do this to, othewise you'd store your
numerical data in another column) like so:

Russ|27|6|Michell (stored as a single string in your table)

This is my first name, age, height, and surname respectively.

You could then just use the explode() function to remove the pipes, and
pick out the values (integers in this case) from the resultant array
that explode() provides you with.

Hope this helps you out some.
Russ

-Original Message-
From: Matthew Nock [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 21, 2002 12:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Converting values from text to numerical


I am about to build a database of products that will store features fore
ach
product in a separate table.

I need to be able to store both text and numeric values in this table,
but
be able to perform mathmatical functions on the numeric variables.

is it possible to have PHP covert numbers that are stored as text
strings
back into values it can calculate with?


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Converting values from text to numerical

2002-06-20 Thread Matthew Nock

Hi Russ,

thanks for the reply ...  if that will evaluate whether a (in this case) a
text string is an integer or not, then its exactly what I need! :)

if it doesnt work, I will post a more detailed example to the list and see
what we can come up with! :)

-Original Message-
From: Russ [mailto:[EMAIL PROTECTED]]
Sent: Friday, 21 June 2002 3:04 PM
To: Matthew Nock; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Converting values from text to numerical


Matthew:

um how about using the is_int() function to decide if the value from
your DB is a number or not?

http://www.php.net/manual/en/function.is-int.php

//Do DB extraction stuff to get $val/$vals from DB

if(is_int($val))
{
echo This is a number so do numbery type things with it..;
}
else
{
echo This aint a number so it must be a string, so do stringy
things with it...;
}

Any good?
Russ

-Original Message-
From: Matthew Nock [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 21, 2002 1:00 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Converting values from text to numerical


Hi Russ,

Thanks for the reply.

I was looking more along the lines of having one field, that might store
either a text value (such as the words Not included), or a numeric
value,
such as 10.

The using PHP to determine if the value is numeric, perform a function
on it
(such as a calculation) then display the result, otherwise, just display
the
text.



-Original Message-
From: Russ [mailto:[EMAIL PROTECTED]]
Sent: Friday, 21 June 2002 2:53 PM
To: Matthew Nock; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Converting values from text to numerical


is it possible to have PHP covert numbers that are stored as text
strings
back into values it can calculate with?

Mathew:

You can use PHP to convert these - dependant upon the way you store them
in your DB.
Foe example I sometimes need to store different types of data in the
same field (I suppose you need to do this to, othewise you'd store your
numerical data in another column) like so:

Russ|27|6|Michell (stored as a single string in your table)

This is my first name, age, height, and surname respectively.

You could then just use the explode() function to remove the pipes, and
pick out the values (integers in this case) from the resultant array
that explode() provides you with.

Hope this helps you out some.
Russ

-Original Message-
From: Matthew Nock [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 21, 2002 12:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Converting values from text to numerical


I am about to build a database of products that will store features fore
ach
product in a separate table.

I need to be able to store both text and numeric values in this table,
but
be able to perform mathmatical functions on the numeric variables.

is it possible to have PHP covert numbers that are stored as text
strings
back into values it can calculate with?


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] PHP/MySQL to generate colums with results

2002-06-14 Thread Matthew Nock

Hi all,

I have seen queries of this nature before, but they never seem to get a
thorough answer - and that maybe because the issue isnt explained properly..

okay, so here is the scenario.

I have a database which features the following tables:

hst_category
hst_product

hst_category features the following fields and (sample) data:

hst_Cat_ID  hst_Cat_Namehst_Cat_Desc

---
1   starter Description of this category goes here.  blah 
blah.
2   businessDescription of business packages would 
go here.  blah.
3   enterprise  Description of enterprise packages 
would be here blah.

the idea is to build a query, based in a value passed on the URL to
determine which category of product we want.  so for example:

?
$colname_QRY_hstPkgSummary = 1;
if (isset($HTTP_GET_VARS['category'])) {
  $colname_QRY_hstPkgSummary = (get_magic_quotes_gpc()) ?
$HTTP_GET_VARS['category'] : addslashes ($HTTP_GET_VARS['category']);
}

mysql_select_db($database_DB_hstProducts, $DB_hstProducts);
$query_QRY_hstPkgSummary = sprintf(SELECT * FROM hst_categories WHERE
hst_Cat_Name = '%s',   $colname_QRY_hstPkgSummary);
$QRY_hstPkgSummary = mysql_query($query_QRY_hstPkgSummary, $DB_hstProducts)
or die(mysql_error());
$row_QRY_hstPkgSummary = mysql_fetch_assoc($QRY_hstPkgSummary);
$totalRows_QRY_hstPkgSummary = mysql_num_rows($QRY_hstPkgSummary);
?

So using the above, if the url featured file.php?category=starter then any
the details regarding the category description for starter would be
returned.

We then need to use this information to generate a table further down the
page (see below).

This table contains information that categorises each of the products in
the hst_product table.

(so using the above example, the table would return all products who's
product category is starter (or 1))

I need to create a HTML table that contains the following: (items with #in
front of name will be dynamic, based in the results)

+---+-+--+...
|   | #Product_1  |  #Product_2  |...
+---+-+--+...
| Field 1   | #PID1_fld1  | #PID2_fld1   |...
+---+-+--+...
| Field 2   | #PID1_fld2  | #PID2_fld2   |...
+---+-+--+...
| Field 3   | #PID1_fld3  | #PID2_fld3   |...
+---+-+--+...

any suggestions?

I know how to create a row for each product, with the columns for each
field, but I want to work the other way.

help!

Thanks,


Matt.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php