[PHP-DB] array manipulation with foreach

2003-03-26 Thread David Rice
I am trying to make a bit of code that takes values from 2 arrays, one array has a list of all the date's of this week starting from sunday, $arraydate[$n] = "the date" where $n is an integer between 0+6 the other is a multidimensional array composition as such; $rota[$staffid][$x] = "date sta

[PHP-DB] date to Y-M-D

2003-03-25 Thread David Rice
a function to convert any date to ymd... function datetoymd($date){ $dateymd = date('Y-m-d',$date); return $dateymd; } this function when output gives me the date 1970-01-01 (date of the unix timestamp start) so, ehm, why!? cheers, dave ___

[PHP-DB] creating a date array

2003-03-25 Thread David Rice
trying to make an array with every date (in -MM-DD format) of the current week in it... the below code ain't working, any ideas?! cheers, dave function createdatearray($sunday){ $date = date('Ymd',strtotime($date)); for($x=0; $x<=7; $x++){ $y = $x + 1;

[PHP-DB] finding out the date of the first day of the current week

2003-03-23 Thread David Rice
I am trying to make a small function that will me the date in Y-m-d of the start of the current week (the sunday) I have only the idea of doing it by making a long drawn out script with if, elseif clauses for every day of the week... and then doing something like if ( date('D') = "mon" ) { $

[PHP-DB] adding to an array variable using a loop...?

2003-03-10 Thread David Rice
I want to create an array from results returned from a mysql query. I want it to go through each row in the returned result, and if the variable in the array staff exists add 1 to the total, if it doesnt exist, set it as one and carry on. But when i run this and do var_dump, it just returns "1"

Fwd: Re: [PHP-DB] need help with foreach()

2003-03-10 Thread David Rice
Here is the complete function I am using. I returned, for testing i commented out the foreach loop and returned $staff, then $tips both arrays returned NULL when i did a var_dump(pointvalue($startdate)); can anyone see how this could be solved? Cheers, dave =

Re: [PHP-DB] need help with foreach()

2003-03-09 Thread David Rice
Hey thank's for the ideas but neither of them work, doh... Okay fredrik I know your idea won't work cos list only works with numericaly indexed arrays, both the arrays that i am using are indexed by date. (it produces a parse error when run) = while(list($d, $t) = each($tips)

[PHP-DB] need help with foreach()

2003-03-09 Thread David Rice
Okay, i have two arrays, $tips and $staff $tips has a key "date" (which is the date of the first day of the week, the second result in the array has the key of the second day of the week etc... ) and the value is a floating point decimal. $staff also has a key "date" and the value is an integer

[PHP-DB] Multidimensional arrays / Dynamic variables

2003-03-09 Thread David Rice
Okay the problem is adding another result to the multi-dimensional array When i perform var_dump on the returned varialbe $tips i get array(1) { [2]=> array(1) { [0]=> string(10) "2003-03-07" } } I know that there are 2 results missing here for when the key of the array is 1 ($sta

[PHP-DB] Dynamic Variable names

2003-03-09 Thread David Rice
Just a quick question about dynamic variables would like to end up with a variable called $tips_1 $tips_2 ... $tips_n where "n" is the value of the variable $sid i have tried $tips . '$sid'; and other variants, but i can't get one that doesn't return a parse error or T_VARIABLE error. ___

Re: [PHP-DB] Re: subtracting times (solution)

2003-03-08 Thread David Rice
It took me about 30 mins but after 2 attempts i came up with a function that subtracts 2 times to give an answer in hours, to two decimal places. thanks for your help the two people who responded when i posted the question, your suggestions were a bit out on a tangent from what i wanted. But th

[PHP-DB] subtracting times

2003-03-08 Thread David Rice
I know I asked this before buy no-one gave me an answer i was looking for, I want to subtract two times and the ammount of hours worked to 2decimal places (3.41 hours) cheers, dave _ Use MSN Messenger to send music and pics to you

[PHP-DB] Subtraction of two units of time.

2003-03-06 Thread David Rice
I want to take away two times stored in the format "00:00:00" in a mysql database, i retrieve the times and take them away by using the following $total = $time1 - $time2 ; when i echo the total it is a whole number of the hours.. and does not take the minutes into account, anyone have an ide

Re: [PHP-DB] date functions (generates parse error)

2003-03-05 Thread David Rice
Sorry, I forgot to add the part at the bottom where I am calling the function = $start = date('Ymd',strtotime($weekstart));   $query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start + INTERVAL 6 DAY) ORDER BY staff

Re: [PHP-DB] date functions (generates parse error)

2003-03-04 Thread David Rice
Here is the whole code of my function Whenever i run it, it say's there is a parse error on line 6, can't see what is the problem the format of $weekstart (as it is stored in the Database) is -MM-DD = $start = date('Ymd',strto

[PHP-DB] date functions

2003-03-04 Thread David Rice
I want to use it in this function that i am creating (it's for a resteraunt automated tips system, to work out how much tips each staff member is entitled to. function tips($weekstart){ /* JUST BELOW HERE IS WHE

[PHP-DB] date functions

2003-03-04 Thread David Rice
I am looking for a way to take a date stored in a mysql database... and find out the date seven days later. how would i do this?! cheers, dave _ Chat online in real time with MSN Messenger http://messenger.msn.co.uk -- PHP Data

Re: [PHP-DB] need help with fetching a result using a function

2003-03-02 Thread David Rice
mation. I have tested it with other queries that work... and there is no problem, i am definately connected to the database From: Koleszár Tibor <[EMAIL PROTECTED]> To: "David Rice" <[EMAIL PROTECTED]> Subject: Re: [PHP-DB] need help with fetching a result using a function

[PHP-DB] need help with fetching a result using a function

2003-03-02 Thread David Rice
I am trying to write a few functions for a project i need to do for school, this function should return all the inactive, or active users (1 or 0 staffstatusid) as an array for creating a drop down menu. Now when i perform the following code (yes it is included in a script that connects to the

[PHP-DB] Session troubles, could this be my isp's fault?

2003-02-25 Thread David Rice
I Have made two pages, "sess2.php" and "sess3.php" trying to create a session variable then access it in the other page. now when i try and call the session in the second page i get no value, and i have tried var_dump, and it gives me "NULL" anyone know if there is a reason for this?! page 1

[PHP-DB] SESSIONS

2003-02-25 Thread David Rice
Here's something i can't get working it won't go to the last clause of this page i don't think it can set the session variable anyone see what im doing wrong? i need more caffeine to get my brain fired up today lol.. ===

[PHP-DB] PHP session problems

2003-02-25 Thread David Rice
I have been having trouble with PHP sessions, the session variables are not able to be called through the script. If have commented the area at the bottome where the session variable is NULL when var dump is called to check it (about 20 lines from the bottom... depending on if the text is wrapp

RE: [PHP-DB] need help spotting this php parse error

2003-01-23 Thread David Rice
It Does have a closing Brace, just check my second email it contains the FULL code.. i missed the last few lines copying it the first time somehow. From: "Andreas Sheriff" <[EMAIL PROTECTED]> To: "David Rice" <[EMAIL PROTECTED]> Subject: RE: [PHP-DB] need he

[PHP-DB] Re. Need help spotting PHP parse error

2003-01-23 Thread David Rice
"Parse error: parse error in /home/filterseveuk/public_html/project/login.php on line 34" That is the exact error message, Cheers, Dave session_start(); if(!$HTTP_COOKIE_VARS["username"]) { /* The Cookie is not set, so load the page as if it is the first time */ require("library/in

[PHP-DB] need help spotting this php parse error

2003-01-23 Thread David Rice
When i run this script it tells me that I have a parse error on line 34? I really can't see it anyhelp (please!) would be much appreciated Cheers, Dave session_start(); if(!$HTTP_COOKIE_VARS["username"]) { /* The Cookie is not set, so load the page as if it is the first time */ inclu

Re: [PHP-DB] build menu with mysql data

2003-01-21 Thread David Rice
Rite marc, this is what your gonna have to do, in a new table like this lets say we call it "MAINSUB" MAINMENU ID SUBMENU ID it only contains those 2 fields to show that there is a link between the two okay? now to the actual menu < for($x=2, $x < 4, $x++ < SELECT * FROM MAINSUB WHERE MAINME

[PHP-DB] MySql DB, help, sql error and i don't know why

2003-01-21 Thread David Rice
SQL-query : CREATE TABLE `staff` ( `StaffId` INT( 4 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `Name` VARCHAR( 30 ) NOT NULL , `Surname` VARCHAR( 30 ) NOT NULL , `Address` TEXT( 225 ) NOT NULL , `JobId` SMALLINT( 2 ) NOT NULL , `PermissionId` SMALLINT( 2 ) NOT NULL , `HomePhone` INT( 11 ) NOT NULL

[PHP-DB] php -> excel

2003-01-19 Thread David Rice
Just a question, is it possible to dynamically create an excel spreadsheet from data in a mysql database the excel sheet does not have to be displayed, just to be sent to print, to give better print quality than a webpage tables equivalent. Or is there another way of doing this? __

[PHP-DB] MySql Update.

2002-11-12 Thread David Rice
Making an update query that adapts to the number of fields that are to be updated Is there anyway to do like a for loop to create the values part of the query then combine it with the first part of the string. something like what i have below... although something that works correctly as thi

[PHP-DB] Dynamic MySql Update Query

2002-11-12 Thread David Rice
co.uk/admin/index.php and if you check a table, and choose an edit query on one of the records to see what i am trying to do. thank's for your time! cheers, David Rice _ The new MSN 8: smart spam protection and 2 months

[PHP-DB] retrieving data from mysql table

2002-11-10 Thread David Rice
okay thank's for the help on my previous question. I've got it to retrieve a list of column headers now, i want it to retrieve all the records from the table and print them underneath. the code i have is ** /* get a list of

[PHP-DB] Extracting column names from a db

2002-11-10 Thread David Rice
I need to write a script that will extract the names of the columns in my database eg. "user_id, username" can anyone help as to how to do this! I have tried ** *** mysql_select_db("filterseveuk") or die(mysql_error()); $query = "SHOW CO

[PHP-DB] need help with SHOW COLUMNS

2002-11-05 Thread David Rice
I am tryin to create a DBMS, the part of my code that is currently causing a problem is mysql_select_db("filterseveuk") or die(mysql_error()); $query = "SHOW COLUMNS FROM " .$table. ""; $result = mysql_query ( $query ) or die( mysql_error () ); $numrows = mysql_num_rows ($result); $r

[PHP-DB] need help with "SHOW Colums"

2002-10-31 Thread David Rice
mysql_select_db("filterseveuk"); $query = ( " SHOW COLUMNS FROM user "); $result =  mysql_query ( $query ) or die( mysql_error () ); while ( $row = mysql_fetch_array ($result) ){ $x = 0 ; echo $row[$x] ; $x++ ; } I would like to replace the table name "user"