[PHP] for loop and array

2002-09-24 Thread Chris Grigor

Good Morning all

I need some help as to how to print this array, its input name is labtype
and they all have differnet values.

Amylase
Cholesterol
CMV Ab IgM/G
GLUCOSE - Fasting
GLUCOSE - Random
Hepatitus B S Ag

On the page I created if the person selects any of these then it should
submit it as name=labtype and value="whatever is selected"

this works.

Now upon getting this info onto my php script how would I say something like

for each item in the array labtype, print its value?

Any help would be really appreciated, I have had a look at a for loop trying
to use the following

for ($a=1; $a<50; $a++) {
echo "$labtype[$a]";
}

but this is not working for me. Can anyone direct me in the right way ???


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




[PHP] printing an array

2002-10-24 Thread Chris Grigor
Hey there all


Im sure that someone out there can answer this question..

I have a problem, how can I print each element in an array so that is
returned into a table?


eg

Test1


Test3


Test4


$row->CDT_Routine_Count";<--- (This
value holds the Results of test1 test 2 etc
   
 that I need to print into the table)
}
mysql_free_result($result);

?>


Any help with this or direction would be appreciated !

Regards
Chris



------
Chris Grigor
--



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




[PHP] Genrate a graph

2002-11-12 Thread Chris Grigor
Howdi All 

Anyone know if there is a function in php that can take values and 
generate a graph ???

Thanks in advance

C

--
Chris Grigor
--



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




[PHP] Am stuck

2003-09-25 Thread Chris Grigor
Good day all

I have a txt file that has values from various strings written to it.

What Im looking for is the following

$name = "Chris';

I need to do a count on $name so that it returns 5 letters. Then before writing it to 
the output file I
know that it has to be 40 charecters long before it gets written.

So I know its 5 now I need automatically add another 35 empty spaces to it to make it 
40 so that it makes the 
$name like this 

$name = "Chris";   < if I do a count on 
this it should be 40 charecters long


Can anyone help out here???

Chris


[PHP] Fw: Am stuck

2003-09-25 Thread Chris Grigor
Sorry maybe I should elaborate




Good day all

I have a txt file that has values from various strings written to it.

What Im looking for is the following

$name = "Chris';

I need to do a count on $name so that it returns 5 letters. Then before writing it to 
the output file I
know that it has to be 40 charecters long before it gets written.

So I know its 5 now I need automatically add another 35 empty spaces to it to make it 
40 so that it makes the 
$name like this 

$name = "Chris";   < if I do a count on 
this it should be 40 charecters long


Can anyone help out here???

Chris


[PHP] fopen

2003-09-25 Thread Chris Grigor
Hi

I am writing to a file different sources.

The one writes the date and the next starts writing data.

The date writes fine. 

$header = "0$gpsdate";

echo $out_file; 

$fp = fopen($out_file, "a");

$write =  (fwrite($fp, "$header\n")); 
  fclose($fp);

Now I get to another batch process that inserts data into the same file but it starts 
on the same line the first time round, then carrys on to the next line..

So I end with this 

2003-09-25 data
data
data
data
 
anyone help out so I can get it to write like this 

2003-09-25
data
data
data

Thanks

Chris






[PHP] str_pad

2003-09-26 Thread Chris Grigor
This should be quite an easy task for some...

say for example $line->dbranch has a value of 3
I know that 3 spaces will be added on to the end of $dbranch


$dbranch = str_pad($line->dbranch_no, 6);

so the value of $dbranch should look like "3 " 

Is there anyway to right justify the 3 using str_pad .. example still put the 3 spaces 
in but at the beginning??? 
so it looks like " 3"


Chris




[PHP] really weird

2002-01-08 Thread Chris Grigor

Hello everyone my name is Chris and I have just subscribed to ask a question

Currently running Redhat 7.2, php4.0.6.7, apache 1.3.22-2, mysql3.23.41-1

Now I have a script that runs every 10 mins in the crontab, 
that checks to see if a file size is 0 or bigger.. if it is bigger then 
it mails me, heres a copy 

#!/usr/bin/php -q

 result");

$fs = filesize(result);

if ($fs > 0){

$jobfood_list = "email.txt";
$emails = file($list);

for ($i=0; $i < count($emails); $i++) $emails[$i] =
trim($emails[$i]);
$recipient = implode(",", $emails);


$mail_subject="mail notification";
$mail_body="The users mailbox has mail.\n\n";
mail($recipient, $mail_subject, $mail_body);
print "mail sent";
}
else
{
die();
}
?>

Right now your in the picture this is okay to check if the mailbox is above
the size of 0. But what I really need help with is, say for instance I get 1
message into the mailbox and the script runs, I only want it to run once for
that message, however if another message comes in I need it to notify me...
at the moment it runs every 10 mins and just keeps notifying me over & over.

Any Help would be cool ...please !!!

C-Ya 

Chris

Chris Grigor

--
Client Services
Call Center: 0860 100 154
Fax: +27 11 340 7345
E-Mail: [EMAIL PROTECTED]

--
M-WEB Business Solutions
Making it happen.

Go shopping @ http://shopping.mweb.co.za 
Get your business online @ http://business.mweb.com 

"We all know Linux is great...it does infinite loops in 5 seconds."
- Linus Torvalds

-- 
PHP General 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] foreach statement

2002-01-08 Thread Chris Grigor

Okay lets see who has there thinking caps on today (cos I really dont)

I have a list of email addresses stored in a text file.

I am able to run the script and get all the mail addresses in the list
mailed but 
thats all in one mail. I want to be able to open the file, chop each line
and send 
individual messages to each address.. okay who is confused as Im not giving
you much 
description here, well okay heres what the script looks like

#!/usr/bin/php -q




Im just thinking(trying to at least) I need some sort of foreach statement
like in perl, right? 
so that it would say 

foreach($recipient)
{ 
send mail 
}


anyone that could maybe guide me? 

Thanks in advance

C-Ya

Chris Grigor

--
Client Services
Call Center: 0860 100 154
Fax: +27 11 340 7345
E-Mail: [EMAIL PROTECTED]

--
M-WEB Business Solutions
Making it happen.

Go shopping @ http://shopping.mweb.co.za 
Get your business online @ http://business.mweb.com 

"We all know Linux is great...it does infinite loops in 5 seconds."
- Linus Torvalds

-- 
PHP General 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] foreach statement

2002-01-08 Thread Chris Grigor

Hey Niklas

yea thats what I want, just one thing 

foreach($emails as $this_is_one_address) {

would it be 

foreach($emails) {   

or am I missing something in there ?

?





mailto:[EMAIL PROTECTED]] 
Sent: 9. tammikuuta 2002 8:59
To: 'Php-General-List (E-mail)'
Subject: [PHP] foreach statement 


Okay lets see who has there thinking caps on today (cos I really dont)

I have a list of email addresses stored in a text file.

I am able to run the script and get all the mail addresses in the list
mailed but 
thats all in one mail. I want to be able to open the file, chop each
line and send 
individual messages to each address.. okay who is confused as Im not
giving you much 
description here, well okay heres what the script looks like

#!/usr/bin/php -q




Im just thinking(trying to at least) I need some sort of foreach
statement like in perl, right? 
so that it would say 

foreach($recipient)
{ 
send mail 
}


anyone that could maybe guide me? 

Thanks in advance

C-Ya

Chris Grigor


--
Client Services
Call Center: 0860 100 154
Fax: +27 11 340 7345
E-Mail: [EMAIL PROTECTED]


--
M-WEB Business Solutions
Making it happen.

Go shopping @ http://shopping.mweb.co.za 
Get your business online @ http://business.mweb.com 

"We all know Linux is great...it does infinite loops in 5 seconds."
- Linus Torvalds

-- 
PHP General 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 General 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 General 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] foreach statement

2002-01-09 Thread Chris Grigor

Thanks!! its working !!! 

***BIG SMILE

Niklas you genious 



-Original Message-
From: Niklas Lampén [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 09, 2002 10:15 AM
To: Php-General
Subject: RE: [PHP] foreach statement 


Foreach works in PHP just like I told.

foreach($emails as $this_is_one_address) is the correct form where
$emails is an array and $this_is_one_address gets one element from
$emails.

This is similar to this (technically):

for ($i = 0; $i < count($emails); ++$i)
{
$this_is_one_address = $emails[$i];
// Do anything you want with $this_is_one_address
};

I suggest that you use the for-loop if $emails array is big. Takes less
memory.


Niklas



-Original Message-
From: Chris Grigor [mailto:[EMAIL PROTECTED]] 
Sent: 9. tammikuuta 2002 9:44
To: '[EMAIL PROTECTED]'; Php-General
Subject: RE: [PHP] foreach statement 


Hey Niklas

yea thats what I want, just one thing 

foreach($emails as $this_is_one_address) {

would it be 

foreach($emails) {   

or am I missing something in there ?

?





mailto:[EMAIL PROTECTED]] 
Sent: 9. tammikuuta 2002 8:59
To: 'Php-General-List (E-mail)'
Subject: [PHP] foreach statement 


Okay lets see who has there thinking caps on today (cos I really dont)

I have a list of email addresses stored in a text file.

I am able to run the script and get all the mail addresses in the list
mailed but 
thats all in one mail. I want to be able to open the file, chop each
line and send 
individual messages to each address.. okay who is confused as Im not
giving you much 
description here, well okay heres what the script looks like

#!/usr/bin/php -q




Im just thinking(trying to at least) I need some sort of foreach
statement like in perl, right? 
so that it would say 

foreach($recipient)
{ 
send mail 
}


anyone that could maybe guide me? 

Thanks in advance

C-Ya

Chris Grigor


--
Client Services
Call Center: 0860 100 154
Fax: +27 11 340 7345
E-Mail: [EMAIL PROTECTED]


--
M-WEB Business Solutions
Making it happen.

Go shopping @ http://shopping.mweb.co.za 
Get your business online @ http://business.mweb.com 

"We all know Linux is great...it does infinite loops in 5 seconds."
- Linus Torvalds

-- 
PHP General 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 General 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 General 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 General 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 General 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] weird fopen problem

2002-01-10 Thread Chris Grigor

I copied you script and ran it no probelm. 

are you sure that apache is running as nobody? 

run 
ps -aux | grep httpd

mine is like this  
apache6320  0.0  5.8 49120 7248 ?S10:54   0:00
/usr/sbin/httpd -

but yours might say 
nobody6320  0.0  5.8 49120 7248 ?S10:54   0:00
/usr/sbin/httpd -

Can you run the script as root? if not do you get the same errors?




-Original Message-
From: Jon Farmer [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 10, 2002 11:08 AM
To: PHP General Mailing List
Subject: [PHP] weird fopen problem


I am getting a  the follwing error:

Warning: fopen("/home/jon/pgpfiles/sgsdgsdg","w") - Permission denied in
/home/ethiorg/public_html/test.php on line 2

Warning: Supplied argument is not a valid File-Handle resource in
/home/ethiorg/public_html/test.php on line 3

Warning: Supplied argument is not a valid File-Handle resource in
/home/ethiorg/public_html/test.php on line 4

from the following script:



the directory /home/jon/pgpfiles has mode 777 and is owned by nobody and
group is nobody. Apache runs under user nobody.

Any ideas?



--
Jon Farmer
Systems Programmer, Entanet www.enta.net
Tel 01952 428969 Mob 07763 620378
PGP Key available, send email with subject: Send PGP Key



-- 
PHP General 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 General 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] Mysql Connection

2002-01-28 Thread Chris Grigor

Hey Uma

call to undefined function, well thats exactly what it means (it doesnt like
the function specified eg mysql_connect)this  means that your php
installation does not have support for mysql. 

You can check this with the following



run this via a browser and check the config of php... it should say
--with-mysql 
heres an examle of the config section it gives

Configure Command  

'./configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr'
'--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
'--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib'
'--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc'
'--disable-debug' '--enable-pic' '--disable-rpath'
'--enable-inline-optimization' '--with-apxs=/usr/sbin/apxs' '--with-bz2'
'--with-curl' '--with-db3' '--with-dom' '--with-exec-dir=/usr/bin'
'--with-gd' '--with-gdbm' '--with-gettext' '--with-jpeg-dir=/usr'
'--with-mm' '--with-openssl' '--with-png' '--with-regex=system' '--with-ttf'
'--with-zlib' '--with-layout=GNU' '--enable-debugger' '--enable-ftp'
'--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-yp'
'--enable-wddx' '--with-mysql' '--without-unixODBC' '--without-oracle'
'--without-oci8' '--with-pspell' '--with-xml' 

You will need to recompile php to use mysql 

Hope this answers your question, and once recompiled your mysql_connect()
function should work like a charm...


C-Ya

Chris








-Original Message-
From: Uma Shankari T. [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 8:33 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Mysql Connection



Hello,


  I have installed php3 in my system.I want to connect with mysql.I have
given this code

$link=mysql_connect("localhost","username","password") or die("could not
connect");


but it is giving Fatal error: Call to undefined function: mysql_connect()


Why it is showing like.

Mysql is also running


 Any one came to know this tell me as soon as possible


Regards,
Uma 


-- 
PHP General 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 General 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] output problem

2002-05-23 Thread Chris Grigor

Howdi Alll 

some of you might laugh at this but I cant get this to work
Im doing a count on a field and want to diplay the result here is an 
example...


");
print (" $line->user\n");
print ("");
}
?>



what am I missing as it returns no value at all from $line->user, should I be 
doing this differently??

Thankyou 

Chris

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




[PHP] time

2002-05-27 Thread Chris Grigor

howdi all 

anyone know how to get a simple time print ? all the functions I have 
looked at gmtime() time() dont give the right thing ... all I want
is a simple time print e.g 17:51

I know that there is an easy way, Im just missing it somewhere ...

Chris

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




[PHP] ping

2002-03-27 Thread Chris Grigor

Hey all 
 
has anyone written a script to check if a host is alive - like a ping script ?
 

Chris Grigor

2nd Line Support
Tel : +27 11 340 7390
Fax : +27 11 340 7345 E-Mail : [EMAIL PROTECTED]

 
M-WEB BUSINESS SOLUTIONS
Making it happen
Go shopping @ < http://shopping.mweb.co.za/>
Get your business online @ < http://business.mweb.com/> 

 



RE: [PHP] ping

2002-03-27 Thread Chris Grigor

Hey Christoph

Thanks for your script, Ive just finished this one, its not that good but it works








body, td { font-family: Verdana, Arial, Helvetica, Geneva, sans-serif; font-size: 8pt; 
color: black; font-weight: normal;
}
h1  { font-family: Verdana, Arial, sans-serif; font-size: 14pt; font-weight: bold; 
color: #006699; }
h2  { font-family: Verdana, Arial, sans-serif; font-size: 12pt; font-weight: bold; 
}
th  { font-family: Verdana, Arial, sans-serif; font-size: 10pt; font-weight: bold; 
text-align: center; }
.h1 { font-family: Arial, sans-serif; font-size: 14pt; font-weight: bold; }
.h2 { font-family: Arial, sans-serif; font-size: 12pt; font-weight: bold; }
.label  { font-family: Arial, sans-serif; font-size: 10pt; font-weight: bold; }
.normal { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; }
.small  { font-family: Arial, sans-serif; font-size: 8pt; color: black; font-weight: 
bold;}
a   { color: #f79700; }
a:visited { color: #00; }









%s", $array[$index]);

}





?>





--

Now remember to create an html page that submits to a script called ping.php
add the following to the ping.html page for example








   





--





-Original Message-
From: Christoph Starkmann [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 27, 2002 6:04 PM
To: Chris Grigor; Php-General-List (E-mail)
Subject: RE: [PHP] ping 


Hi CHris!

> has anyone written a script to check if a host is alive - 
> like a ping script ?

Something like this?

BTW, any hints to weak or wrong code are welcome, I'm not
this experienced with PHP ;)

Cheers, Kiko
P.S.: There are some formatting strings and some variables
stored in constants.php and a simple error function in
functions.php, but that's all, I guess anyone can change
this... ;)




.o0o.linktest.o0o.

http://";, "", $url);
$tempUrl = str_replace("/", "", $tempUrl);

$fp = fsockopen ($tempUrl, $tempPort, &$errno, &$errstr, 30);

if (!$fp)
{
echo "" . $f1 . "Link fehlerhaft: " . $url . $f1_e .
"\n";
}
else
{
fputs ($fp, "GET / HTTP/1.0\r\n\r\n");
$code = fgets($fp,1024);
$code = str_replace("HTTP/1.1 ", "", $code);
$code = (int)$code;
if ($code == 200) echo $f1 . "Link okay ($code)" .
$f1_e;
else
{
while ($code = fgets($fp, 2048))
{
echo $f1 . ">>" . $code . "" . $f1_e;
}
}
fclose($fp);
}
echo "" . $f_link . $tempName . $f_linke .
"";
}
?>
















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




[PHP] Difference between 2 time entries

2006-07-20 Thread Chris Grigor
Morning all,


I am looking to get the differnce in hours / minutes between 2 values.

Currently I have 2 time entries being retruned from mysql, one which is a
start time and
the other which is a finish time.

So

$start = '13:12:17';
$finish = '23:12:17';

How would one get the differnce between these 2 times??

I have looked at using the following but am not to sure



function timeDiff($firstTime,$lastTime)
{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}

//Usage :
echo timeDiff("$start","$finish");

Thanks

Chris

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



[PHP] Difference between 2 time entries

2006-07-20 Thread Chris Grigor
Morning all,


I am looking to get the differnce in hours / minutes between 2 values.

Currently I have 2 time entries being retruned from mysql, one which is a
start time and
the other which is a finish time.

So

$start = '13:12:17';
$finish = '23:12:17';

How would one get the differnce between these 2 times??

I have looked at using the following but am not to sure



function timeDiff($firstTime,$lastTime)
{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}

//Usage :
echo timeDiff("$start","$finish");

Thanks

Chris

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



[PHP] Help with dynamic radio buttons

2006-07-22 Thread Chris Grigor
Afternoon all

I need some help here with a problem on dynamic radio buttons.

I have a script that calls a database for a list of questions. The questions
are returned and each question needs to have 5
radio buttons assigned to it. The radio buttons are a score of 1 - 5 (1
being bad, 5 being good)

For example

1 . How would you rate your vacation?1 2 3 4 5 <--- those are the radio
buttons.
2. How would you rate your dining at the resort? 1 2 3 4 5


Ok so I have all the questions being returned, I was thinking when creating
the radio buttons as follows







The input name for each radio group is the questions id from the database.
If there are 50 questions you would have 50 radio button answers submitted.
How are you going to identify the radio buttons being submitted as they are
dynamic? and also I would need to be stored in the
session data as they might want to go back / forward a page.

So basically I need to go through each $_GET item, identify it as a radio
submission and put it into an array.

Has anyone done anything similar before / or can point me in the right
direction??

Kind regards
Chris




[PHP] Checking $_POST var and stripping

2006-07-24 Thread Chris Grigor
Hi

Can anyone help with this ? its checking the $_POST and seeing if any of the
items begin with answer_,
if the do it should remove it from the beginning and place it into
$value_new.. does not seem to work though...



foreach($_POST as $qid => $value) {

$findme = 'answer_';
 if(stripos($value, $findme)) {
 $value_new = ltrim($value);
 print "$value_new";
 }

}

Thanks

Chris


[PHP] Nested foreach statement

2006-07-31 Thread Chris Grigor
Have been wondering if this is possible

Basically I have 3 posted arrays,
$_POST['reporton_company']  (this can be various company id's. ie 3,6,7)
$_POST['report_period'] (this can be various periods but a max of 4
submitted. ie 3,4,5)
$_POST['questions_groups'] (this can be various - starting from 1- whatever
(usually a max of 10 or 11). ie 1,2,3,4,5,6,7,8,9,10)

So the select should work as

1. for each company listed go through the loop
2. for each report period listed go through loop for each company
3. for each questions group go through the loop for each report period and
each company..

So I came up with this - will it work??


foreach($_POST['reporton_company'] as $cmp_ind =>$arrayd_cmp_id) {
foreach($_POST['report_period'] as $rep_ind =>$arrayd_per_id) {
foreach($_POST['questions_groups'] as $group_ind => 
$arrayd_group_no) {
mysql_select_db($database_name, $dname);

$query_get_list_of_answers = "SELECT * FROM answers 
LEFT JOIN (questions,
period) ON (questions.id=answers.ans_l_question_id  AND
period.per_id=ans_l_period_id) where ans_l_company_id = '$arrayd_cmp_id' AND
per_id = '$arrayd_per_id' AND group_no =
'$arrayd_group_no';";

$get_list_of_answers = mysql_query($query_get_list_of_answers, $antiva) or
die(mysql_error());
$row_get_list_of_answers = mysql_fetch_assoc($get_list_of_answers);
$totalRows_get_list_of_answers = mysql_num_rows($get_list_of_answers);
}

}
}

Anyone suggest an easier way?

Cheers
Chris

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



[PHP] Pushing Vars into $_SESSION

2006-04-18 Thread Chris Grigor

Afternoon

Was wondering if there is an easier way to get returned variables into 
the $_SESSION rather than going through each one??


eg

$link_id = mysql_connect($dbhost, $dbuser, $dbpass)
   or die("Connection to $dbhost failed on verification 
section");


mysql_select_db($logindb, $link_id)
   or die("Selection of database failed on verification section");

$query = "SELECT * FROM blah where blah = 'blah'";

$result = mysql_query($query) or die ("Query failed: " . mysql_error());

   while ($line = mysql_fetch_object($result, MYSQL_ASSOC)) {
   $id = $line->id;
   $firstname = $line->firstname;
   $surname = $line->surname;
   $email = $line->email;
  


   }
mysql_close($link_id);

$_SESSION["id"] = "$id";
$_SESSION["firstname"] = $firstname;
$_SESSION["surname"] = $surname;
$_SESSION["email"] = $email;

Any help here is appreciated

Chris

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



Re: [PHP] Pushing Vars into $_SESSION

2006-04-20 Thread Chris Grigor

Richard Lynch wrote:


On Wed, April 19, 2006 1:36 am, Chris Grigor wrote:
 


Richard Lynch wrote:

   


On Tue, April 18, 2006 10:05 am, Chris Grigor wrote:
 


Was wondering if there is an easier way to get returned variables
into
the $_SESSION rather than going through each one??
   



 


foreach($line as $key => $value) $_SESSION[$key] = $value;
 



 


Why do this?
Is it really going to help you to have the data stored in TWO
places?
I predict that if you really think about what you are doing, you
won't
want to do this.  There are simply too many pitfalls for this to be a
 



 


The point of me doing this is that I will be pulling menu flags from a
database on a user level.
   



 


in the db I will have menu items 1 to 20 turned on or off. When a user
logs in these flags are pulled
and depending if they are truned on or off, the menu will display.
Catch my drift??
   



Tell us the part about where having them copied into $_SESSION makes
your software better... :-)

Database -> Menu is a very simple and common web design.

Database -> $_SESSION -> Menu only adds an extra step, AFAICT.

Are you able to completely avoid connecting to the database on many
subsequent pages this way?  That could be Good Code.

Or are you just avoiding a single simple query that, with indexed
fields, should run in a splintered second?  That's probably Bad Code.

$_SESSION data is not free.

It's not even cheaper than MySQL data, as a general rule -- though it
might be in specific cases.

Simplify, grasshopper.
:-)

 

The method behind the madness here, is that I am only pulling the data 
once from the db throughout the whole session. This means that all the 
user info is available on every page they visit. I can also
then identify on each page that loads if a user has signed in and a 
session is present. Do you think I am going about this in the wrong way? 
What would you suggest is a better idea???


Chris

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



[PHP] Is there an easier way of doing this?

2006-05-10 Thread Chris Grigor

morning all,

Is there an easier way of doing the following??

form1 submitting to form1.php


failed:" . mysql_error());


mysql_select_db('yourdbname', $link) or die ("selection failed: " . 
mysql_error());


if(isset($_POST[1])) {
   mysql_query("INSERT INTO menu (label) VALUES ('item 1 selected')");
   }
else {
   mysql_query("INSERT INTO menu (label) VALUES ('item 1 not selected')");
   }
if(isset($_POST[2])) {
   mysql_query("INSERT INTO menu (label) VALUES ('item 2 selected')");
   }
else {
   mysql_query("INSERT INTO menu (label) VALUES ('item 2 not selected')");
   }

mysql_close($link);
?>

So my question is, if I have a form with 20 + items which can be 
checkboxes, when submitted do I need to go through each one and add it 
to the datasbase or maybe some kind of loop?.


Thank you

Chris

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



[PHP] Views on e-commerce download tracking

2006-05-15 Thread Chris Grigor

Hey all

Was just wondering what others have used on there e-commerce sites to 
manage digital downloads, for instance how to track if a user 
succesfully downloaded a complete file from you (what happens if there 
connection drops halfway through a download)


Is there something in php / javascript that could do this - 
javascript:oncomplete_ofdownloadfile send response to server

Anyone have any ideas?

Your views / suggestions are appreciated.
Chris

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



[PHP] Files

2005-06-28 Thread Chris Grigor
Hey all,

I am having a bash at working with flat files.

What I am trying to achieve is the following

There are 2 files with info in them, 
file1 has
id,email

and file2 has 
id,filename

what I am trying to achieve is open up file1 get the id and email then
open file2 and match the id of file1 to id of file2, then if succesful
send a mail with the filename in file2.

Maybe have a look at the code...

$recp_list = fopen("mail_group_list.txt", "r");

while(!feof($recp_list))
{

$line = fgets($recp_list, 255);

$line = chop($line);

$split = explode(",", $line);

$id = $split[0];
$email = $split[1];

// time to mail.

if ($email != "") {



$group_list = fopen("file_group_list.txt", "r");

while(!feof($group_list))
{
$groupline = fgets($group_list, 255);

$groupline = chop($groupline);

$groupsplit = explode(",", $groupline);

$groupid = $groupsplit[0];
$groupFileName = $groupsplit[1];

if($groupid = $id)
{


// start mailing
$fromname = "Test Mailer";
$fromaddress = "[EMAIL PROTECTED]"; 
$subject = "Test mail";
$message = "Test message $groupFileName";
$headers = "From: \"".$fromname."\" <".$fromaddress.">\n";
   
   // Notify the user on screen if the send was succesfull
   if(mail($email, $subject, $message, $headers))

{ 
print "Mail sent successfully to $email";
}
else
{
print "Mail not sent to $email";
}


}#end if groupid = id
}#end while group list
}#end if email


}#end while email !=""
?>


So thats the mail.php

mail_list_group.txt looks like this 

1,test@test.com
5,[EMAIL PROTECTED]
7,test@test.com

file_group_list.txt looks like this 

2,filename1.doc
3,filename2.doc
4,filename3.doc

Any help on this would be great !

Cheers
Chris

PS the formatting might come out all wrong as its mailed from a web account.
-- 


Anyone can give up smoking, but it takes a man to face cancer.

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