Re: [PHP] Stuffing code into variable

2007-02-03 Thread Albert Padley


On Feb 3, 2007, at 10:04 PM, Paul Novitski wrote:




On Feb 3, 2007, at 9:09 PM, Albert Padley wrote:
I have an echo statement that I use in conjunction with a MySQL  
query.


echo "\n" . $row['time'] . "\nclass=\"tabletext\">" . $row['field'] . "\n\"tabletext\">" . $row['division'] . "\n";


This works perfectly fine. However, I will be using the same code
numerous times on the page and wanted to stuff it all into a
variable. At this point I can't remember the proper syntax and
quoting to get this right. Any takers?



At 2/3/2007 08:09 PM, Christopher Weldon wrote:

You could always make it a function...ie:

function drawTableRow($sqlRow) {
return "\n". $sqlRow['time'] ."td> \n".$row['field'].""; //  
Simplified for

time purposes.
}


Good suggestion.  I like heredoc's clean presentation:
__

function drawTableRow($sqlrow)
{
return <<<_

{$sqlrow['time']}
{$sqlrow['field']}
{$sqlrow['division']}


_;
}
__

By the way, if every cell in every row is class "tabletext" why  
have a class at all?  You could simply apply the desired styles to  
the td element.


Regards,

Paul

I'm using heredoc elsewhere on the page so that's a good idea.

As far as the CSS on the , other cells in the table have  
different styling.


Al

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



Re: [PHP] Stuffing code into variable

2007-02-03 Thread Albert Padley


On Feb 3, 2007, at 9:09 PM, Christopher Weldon wrote:



On Feb 3, 2007, at 9:09 PM, Albert Padley wrote:

It's late and I've been at this a long time today so I throw  
myself on the mercy of the list.


I have an echo statement that I use in conjunction with a MySQL  
query.


echo "\n" . $row['time'] . "\nclass=\"tabletext\">" . $row['field'] . "\n\"tabletext\">" . $row['division'] . "\n";


This works perfectly fine. However, I will be using the same code  
numerous times on the page and wanted to stuff it all into a  
variable. At this point I can't remember the proper syntax and  
quoting to get this right. Any takers?


Thanks.

Al Padley

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




You could always make it a function...ie:

function drawTableRow($sqlRow) {
return "\n". $sqlRow['time'] ." 
\n".$row['field'].""; // Simplified  
for time purposes.

}

// Execute the query
foreach ($row = mysql_fetch_array($query)) {
echo drawTableRow($row);
}


That's perfect. I should of thought of using a function.

Thanks.

Al

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



[PHP] Stuffing code into variable

2007-02-03 Thread Albert Padley
It's late and I've been at this a long time today so I throw myself  
on the mercy of the list.


I have an echo statement that I use in conjunction with a MySQL query.

echo "\n" . $row['time'] . "\nclass=\"tabletext\">" . $row['field'] . "\n\">" . $row['division'] . "\n";


This works perfectly fine. However, I will be using the same code  
numerous times on the page and wanted to stuff it all into a  
variable. At this point I can't remember the proper syntax and  
quoting to get this right. Any takers?


Thanks.

Al Padley

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



Re: [PHP] Uninitialized string offset: 0

2007-01-06 Thread Albert Padley

Ah, of course.

Thanks.

Al


On Jan 6, 2007, at 12:57 PM, Robert Cummings wrote:


On Sat, 2007-01-06 at 12:43 -0700, Albert Padley wrote:

Sure.

$myFilter = new InputFilter('','',0,0);


The first two parameters should be arrays (not strings as you have
above).

Cheers,
Rob.
--
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



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



Re: [PHP] Uninitialized string offset: 0

2007-01-06 Thread Albert Padley

Sure.

$myFilter = new InputFilter('','',0,0);
$_POST = $myFilter->process($_POST);

BTW - for what I'm trying to do at the moment, if I change the first  
line to:


$myFilter = new InputFilter();

it takes care of the Notice problem.

Thanks.

Al

On Jan 6, 2007, at 12:36 PM, Dave Goodchild wrote:


Can you show us what you're calling it with?



Al Padley

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




--
http://www.web-buddha.co.uk




[PHP] Uninitialized string offset: 0

2007-01-06 Thread Albert Padley
I have the following class that generates a Notice: Uninitialized  
string offset: 0 each time it is called. The lines generating the  
notice are marked. How do I fix this?


class InputFilter {
var $tagsArray;
var $attrArray;
var $tagsMethod;
var $attrMethod;
var $xssAuto;
	var $tagBlacklist = array('applet', 'body', 'bgsound', 'base',  
'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id',  
'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object',  
'script', 'style', 'title', 'xml');
	var $attrBlacklist = array('action', 'background', 'codebase',  
'dynsrc', 'lowsrc');
	function inputFilter($tagsArray = array(), $attrArray = array(),  
$tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) {		
		for ($i = 0; $i < count($tagsArray); $i++) $tagsArray[$i] =  
strtolower($tagsArray[$i]); //<< Notice Generated Here
		for ($i = 0; $i < count($attrArray); $i++) $attrArray[$i] =  
strtolower($attrArray[$i]); //<< Notice Generated Here also

$this->tagsArray = (array) $tagsArray;
$this->attrArray = (array) $attrArray;
$this->tagsMethod = $tagsMethod;
$this->attrMethod = $attrMethod;
$this->xssAuto = $xssAuto;
}
}

TIA.

Al Padley

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



Re: [PHP] Dynamic Year Drop Down

2006-11-16 Thread Albert Padley
Thanks, Larry. This was close, but didn't quite work. I played around  
with the syntax and the following worked great.


$this_year = date('Y');
echo "\n";
for ($i= $this_year-1; $i < $this_year+3; ++$i) {
echo "" . $i . "\n";
}   
echo "\n";

Al Padley

On Nov 16, 2006, at 11:32 PM, Larry Garfield wrote:


Quite simple:

$this_year = date('Y');
for ($i= $this_year-1; $i < $this_year+3; ++$i) {
  print "$i\n";
}

Obviously modify for however you're doing output.  (Note that you  
DO want to
have the redundant value attribute in there, otherwise some  
Javascript things
don't work right in IE.  Good habit to get into.)  I don't think it  
can

really get more simple and elegant.

On Thursday 16 November 2006 23:26, Albert Padley wrote:

I want to build a select drop down that includes last year, the
current year and 3 years into the future. Obviously, I could easily
hard code this or use a combination of the date and mktime functions
to populate the select. However, I'm looking for a more elegant way
of doing this.

Thanks for pointing me in the right direction.

Al Padley


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



Re: [PHP] Dynamic Year Drop Down

2006-11-16 Thread Albert Padley


On Nov 16, 2006, at 11:04 PM, Tom Ray [Lists] wrote:




Albert Padley wrote:
I want to build a select drop down that includes last year, the  
current year and 3 years into the future. Obviously, I could  
easily hard code this or use a combination of the date and mktime  
functions to populate the select. However, I'm looking for a more  
elegant way of doing this.


Thanks for pointing me in the right direction.


This works for me, simple and easy.

// Grabs current Year
$year=date("Y");

// Number of years you want total
$yearEnd=$year+10;

// Generate Drop Down
for($year=$year; $year <= $yearEnd; $year++) {
   print "$year";
}


Thanks. This was close, but it didn't account for the first option  
being last year. I edited and ended up with this which works.


// Grabs current Year
$year=date("Y");
$yearFirst = $year-1;
// Number of years you want total
$yearEnd=$year+2;

// Generate Drop Down
echo "\n";
for($year=$yearFirst; $year <= $yearEnd; $year++) {
   print "$year";
}
echo "\n";

Al Padley

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



[PHP] Dynamic Year Drop Down

2006-11-16 Thread Albert Padley
I want to build a select drop down that includes last year, the  
current year and 3 years into the future. Obviously, I could easily  
hard code this or use a combination of the date and mktime functions  
to populate the select. However, I'm looking for a more elegant way  
of doing this.


Thanks for pointing me in the right direction.

Al Padley

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



Re: [PHP] For Loop

2006-06-20 Thread Albert Padley
Thanks everyone. Always nice to know there is more than one direction  
to go in.


Albert


On Jun 20, 2006, at 4:52 PM, Ray Hauge wrote:


On Tuesday 20 June 2006 15:28, Adam Zey wrote:

Ray Hauge wrote:

On Tuesday 20 June 2006 15:14, Albert Padley wrote:

I have a regular for loop - for($i=1; $i<100; $i++)

Within the loop I need to create variables named:

$p1name;
$p2name;
$p3name;
etc.

The integer portion of each variable name needs to be the value  
of $i.


I can't seem to get my syntax correct?

Can someone point me in the right direction?

Thanks.

Albert Padley


If you really want to keep the p?name syntax, I would suggest  
throwing

them in an array with keys.

$arr["p1name"]
$arr["p2name"]

Then that way you can create the key dynamically:

$arr["p".$i."name"]

Not pretty, but it works.

Thanks,


I haven't checked this, but couldn't you reference it as $arr["p 
$iname"]

? Is there a reason why variable expansion wouldn't work in this
circumstance?

If it does, you could make it easier to read by doing $arr["p{$i} 
name"]

even though the {} aren't required. It'd be a lot easier to read than
concatenations :)

Regards, Adam.


Both of those ways work.  I think there's a question on the PHP  
Certification

Exam about the different ways to work with strings.

--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



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



[PHP] For Loop

2006-06-20 Thread Albert Padley

I have a regular for loop - for($i=1; $i<100; $i++)

Within the loop I need to create variables named:

$p1name;
$p2name;
$p3name;
etc.

The integer portion of each variable name needs to be the value of $i.

I can't seem to get my syntax correct?

Can someone point me in the right direction?

Thanks.

Albert Padley

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



Re: [PHP] var_dump($POST)

2006-04-12 Thread Albert Padley


On Apr 13, 2006, at 12:16 AM, William Stokes wrote:


Hello,
var_dump($POST) returns now always NULL.


Try var_dump($_POST);

Note the underline between $ and P.

Al Padley

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



Re: [PHP] Proper OOP Syntax

2006-02-20 Thread Albert Padley

Thank you Chris.

Albert


On Feb 20, 2006, at 5:00 PM, Chris wrote:


Albert Padley wrote:

Given the following code:
$password = (strlen($this->user_pw) < 32) ? md5($this->user_pw) :   
$this->user_pw;
$sql = sprintf("SELECT COUNT(*) AS test, TeamID FROM % 
s WHERE  BINARY login = '%s' AND pw = '%s' AND active = 'y'",  
$this-  >table_name, $this->user, $password);

}
$result = mysql_query($sql) or die(mysql_error());
if (mysql_result($result, 0, "test") == 1) {
return true;
} else {
return false;
}
How would I set a session variable for the value of TeamID?


You'll need to change it so you actually fetch the teamid:


$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_assoc($result);
if (empty($row)) {
  return false;
}

$_SESSION['TeamID'] = (int)$row['TeamID'];
return true;


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



[PHP] Proper OOP Syntax

2006-02-20 Thread Albert Padley

Given the following code:

$password = (strlen($this->user_pw) < 32) ? md5($this->user_pw) :  
$this->user_pw;
			$sql = sprintf("SELECT COUNT(*) AS test, TeamID FROM %s WHERE  
BINARY login = '%s' AND pw = '%s' AND active = 'y'", $this- 
>table_name, $this->user, $password);

}
$result = mysql_query($sql) or die(mysql_error());
if (mysql_result($result, 0, "test") == 1) {
return true;
} else {
return false;
}

How would I set a session variable for the value of TeamID?

Thanks.

Albert Padley

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



Re: [PHP] Unique Names for Variable in Loop

2006-02-02 Thread Albert Padley

Yes, that's it. Thanks for the "swift kick".

AP


On Feb 2, 2006, at 12:37 PM, Jim Moseby wrote:



I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each
last name returned needs to be assigned to a unique variable like
name1, name2, name3, etc.


How about $names[1], $names[2], $names[3]?

JM

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



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



[PHP] Unique Names for Variable in Loop

2006-02-02 Thread Albert Padley

I must be brain dead today since I can't get my syntax correct.

Simple MySQL query to return a list of last_name. No problem. Each  
last name returned needs to be assigned to a unique variable like  
name1, name2, name3, etc.


Somebody just kick me in the right direction.

Thanks.

Al Padley

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



[PHP] Re: [SPAM] - [PHP] Nested IFs Problem - Bayesian Filter detected spam

2005-08-31 Thread Albert Padley

Justin & Jordan,

Thanks. The && was what I needed.

Albert Padley


On Aug 31, 2005, at 2:27 PM, Justin Francis wrote:


Albert Padley wrote:



I have the following nested ifs:

if ($row['date'] < '2005-10-02') {
if ($row['time'] < '12:00') {
if ($row['field'] == 'P5' ) {

echo "Success";

}
}
}

else {

echo "Failed";
}


Whenever the 3 if statements are true, I always get the correct   
"Success" to echo. However, if any or all of the if statements  
are  false, I never get "Failed" to echo.



Once the first if statement is evaluated as true, the else  
statement will never be executed -- regardless of the outcome of  
the two nested ifs. I am not sure what you are trying to accomplish  
here, but perhaps all three of your if conditions should be  
combined into one if condition ANDed (&&) together? Or maybe the  
if...elseif...else structure is what you need.


Hope this helps.

Justin





I know it's something simple, but I just can't see it at the moment.

TIA

Albert Padley









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



[PHP] Nested IFs Problem

2005-08-31 Thread Albert Padley

I have the following nested ifs:

if ($row['date'] < '2005-10-02') {
if ($row['time'] < '12:00') {
if ($row['field'] == 'P5' ) {

echo "Success";

}
}
}

else {

echo "Failed";
}


Whenever the 3 if statements are true, I always get the correct  
"Success" to echo. However, if any or all of the if statements are  
false, I never get "Failed" to echo.


I know it's something simple, but I just can't see it at the moment.

TIA

Albert Padley

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



Re: [PHP] Validating Dynamic Checkboxes

2004-08-06 Thread Albert Padley
Jason,
You lost me on this go around. I don't understand how we got from the 
following function to your new verson:

//loop through records
$id = $row['id'];
$counter++;
if ($counter > 1) {
$jscondition .= " || document.getElementById('ed" . $id . 
"').checked";
 } else {
   $jscondition .= "document.getElementById('ed" . $id . 
"').checked";
}
}
?>

<br>
 function validate() {<br>
if (!(<?php print $jscondition; ?>)) {<br>
 alert('Please check at least one edit checkbox before submitting this 
form.');<br>
 return false;<br>
 }<br>
 }<br>
 

Remember that the above works insofar as it throws up the javascript 
alert, but then submits the form anyway. I don't see how your new 
function incorporates the loop to build $jscondition.

Thanks for any further input. I think I need to get some sleep.
Albert Padley
On Aug 6, 2004, at 11:39 PM, Jason Paschal wrote:
make ur submit button a regular button with an onClick event trigger:


then make ur javascript submit the form if conditions are true. 
otherwise it gives an alert:


function validate() {
if (document.getElementById('ed2').checked) {
document.getElementById('myform').submit();
} else {
alert("check something.");
}
}


---
http://www.dailymedication.com  -  Everything you didn't know you 
needed until you went there and said to yourself, "What did I do 
before I visited DailyMedication.com?" and another part of you 
answered, "It does not matter.  You are here now."



From: Albert Padley <[EMAIL PROTECTED]>
To: "Jason Paschal" <[EMAIL PROTECTED]>
Subject: Re: [PHP] Validating Dynamic Checkboxes
Date: Fri, 6 Aug 2004 23:27:29 -0600
We are very close. I now get the javascript alert when I don't check 
any of the checkboxes. However, as soon as I click the OK button in 
the alert, the results page is returned.

Albert Padley
On Aug 6, 2004, at 10:55 PM, Jason Paschal wrote:
i read the other guy's bit.  he may be referring to how you identify 
the elements.  and that could be related to the same validation 
trouble you're still having.

i've had to do similar stuff, but it wasn't exactly the same.  
however, i had to give a an id different from the name of the 
element.


and in ur javascript:

 if ($counter > 1) {
$jscondition .= " || document.getElementById('ed" . $id . 
"').checked";
 } else {
   $jscondition .= "document.getElementById('ed" . $id . 
"').checked";


---
http://www.dailymedication.com  -  Everything you didn't know you 
needed until you went there and said to yourself, "What did I do 
before I visited DailyMedication.com?" and another part of you 
answered, "It does not matter.  You are here now."



From: Albert Padley <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Validating Dynamic Checkboxes
Date: Fri, 6 Aug 2004 22:36:10 -0600
Jason,
Thanks. That seems to build the javascript string, but 
unfortunately the form doesn't validate. In other words, if I leave 
all the checkboxes unchecked the results page still is returned.

Perhaps there is a problem with the javascript? Any ideas?
Albert Padley
On Aug 6, 2004, at 10:02 PM, Jason Paschal wrote:
here's an idea:
above the HTML, you could put something like this [i'm going to 
use pseudo-code since i don't know how you set it up, but you may 
have to do the same query twice]:

$counter = 0;
loop through records {
$id = $row['id'];
$counter++;
if ($counter > 1) {
 $jscondition .= " || mainform.ed[" . $id . "].checked";
} else {
 $jscondition .= "mainform.ed[" . $id . "].checked";
}
}
then in ur javascript:

function validate() {
if (!(<?php print $jscondition; ?>)) {</pre><br>
<tt><br>---<br>
<a  href="http://www.dailymedication.com">http://www.dailymedication.com</a>  -  Everything you didn't know you 
needed until you went there and said to yourself, "What did I do 
before I visited DailyMedication.com?" and another part of you 
answered, "It does not matter.  You are here now."</tt><br>
<br>
<pre style="margin: 0em;"><br></pre><br>
<pre style="margin: 0em;"><br></pre><br>
<blockquote style="border-left: #EE solid 0.2em; margin: 0em; padding-left: 0.85em"><pre style="margin: 0em;">From: Albert Padley <[EMAIL PROTECTED]>
To

Re: [PHP] Re: Validating Dynamic Checkboxes

2004-08-06 Thread Albert Padley
On Aug 6, 2004, at 10:39 PM, Manuel Lemos wrote:
Hello,
On 08/07/2004 12:49 AM, Albert Padley wrote:
I have a php/mysql script that returns a series of records to 
populate a form. The number of records returned varies from 1 to as 
many as 100. On the display page, each record has a checkbox to 
indicate that the record is being edited. This is checked on the 
results page to know which records to update. The checkbox code is:

This part of the system has been working perfectly for weeks.
Now I've been asked to add client side validation to make sure at 
least one of the records (checkboxes) has been checked before sending 
the data to the results page. (The results page already has working 
validation code in it.)
I've have the following javascript code that should work for my 
purposes if I can figure out how to dynamically build the javascript 
code.
<br>
 function validate() {<br>
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {<br>
 alert('Please check at least one record before submitting this 
form.');<br>
 event.returnValue=false;<br>
 }<br>
 }<br>
 
This is the line I need to build dynamically:
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
It can't be done that way because the brackets have a different 
meaning in Javascript syntax. You need to quote the whole name.

You may want to take a look at the example that comes with this forms 
generation and validation class that supports the exact same type of 
validation that you want:

http://www.phpclasses.org/formsgeneration
Hi Manuel,
I'm not certain I understand what you mean by "quote the whole name". 
Also, there are a lot of files in the formsgeneration class. Which one 
has the example you are referring to?

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


Re: [PHP] Validating Dynamic Checkboxes

2004-08-06 Thread Albert Padley
Jason,
Thanks. That seems to build the javascript string, but unfortunately 
the form doesn't validate. In other words, if I leave all the 
checkboxes unchecked the results page still is returned.

Perhaps there is a problem with the javascript? Any ideas?
Albert Padley
On Aug 6, 2004, at 10:02 PM, Jason Paschal wrote:
here's an idea:
above the HTML, you could put something like this [i'm going to use 
pseudo-code since i don't know how you set it up, but you may have to 
do the same query twice]:

$counter = 0;
loop through records {
$id = $row['id'];
$counter++;
if ($counter > 1) {
 $jscondition .= " || mainform.ed[" . $id . "].checked";
} else {
 $jscondition .= "mainform.ed[" . $id . "].checked";
}
}
then in ur javascript:

function validate() {
if (!(<?php print $jscondition; ?>)) {</pre><br>
<tt><br>---<br>
<a  href="http://www.dailymedication.com">http://www.dailymedication.com</a>  -  Everything you didn't know you 
needed until you went there and said to yourself, "What did I do 
before I visited DailyMedication.com?" and another part of you 
answered, "It does not matter.  You are here now."</tt><br>
<br>
<pre style="margin: 0em;"><br></pre><br>
<pre style="margin: 0em;"><br></pre><br>
<blockquote style="border-left: #EE solid 0.2em; margin: 0em; padding-left: 0.85em"><pre style="margin: 0em;">From: Albert Padley <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [PHP] Validating Dynamic Checkboxes
Date: Fri, 6 Aug 2004 21:49:40 -0600</pre><br>
<tt>I have a php/mysql script that returns a series of records to 
populate a form. The number of records returned varies from 1 to as 
many as 100. On the display page, each record has a checkbox to 
indicate that the record is being edited. This is checked on the 
results page to know which records to update. The checkbox code is:</tt><br>
<br>
<pre style="margin: 0em;"><input type=\"checkbox\" name=\"ed[{$row['id']}]\" value=\"Y\"></pre><br>
<pre style="margin: 0em;">This part of the system has been working perfectly for weeks.</pre><br>
<tt>Now I've been asked to add client side validation to make sure at 
least one of the records (checkboxes) has been checked before sending 
the data to the results page. (The results page already has working 
validation code in it.)</tt><br>
<br>
<tt>I've have the following javascript code that should work for my 
purposes if I can figure out how to dynamically build the javascript 
code.</tt><br>
<br>
<tt><SCRIPT><br>
 function validate() {<br>
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {<br>
 alert('Please check at least one record before submitting this 
form.');<br>
 event.returnValue=false;<br>
 }<br>
 }<br>
 

This is the line I need to build dynamically:
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
Any help, pointers, suggestions, etc. will be greatly appreciated.
Thanks.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


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


[PHP] Validating Dynamic Checkboxes

2004-08-06 Thread Albert Padley
I have a php/mysql script that returns a series of records to populate 
a form. The number of records returned varies from 1 to as many as 100. 
On the display page, each record has a checkbox to indicate that the 
record is being edited. This is checked on the results page to know 
which records to update. The checkbox code is:


This part of the system has been working perfectly for weeks.
Now I've been asked to add client side validation to make sure at least 
one of the records (checkboxes) has been checked before sending the 
data to the results page. (The results page already has working 
validation code in it.)

I've have the following javascript code that should work for my 
purposes if I can figure out how to dynamically build the javascript 
code.


 function validate() {
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
 alert('Please check at least one record before submitting this form.');
 event.returnValue=false;
 }
 }
 
This is the line I need to build dynamically:
 if (!(mainform.ed[0].checked || mainform.ed[1].checked)) {
Any help, pointers, suggestions, etc. will be greatly appreciated.
Thanks.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Regex (Phone Number)

2004-07-25 Thread Albert Padley
I have been struggling with a javascript regex validation for U.S. 
phone numbers all afternoon. This is part of Manuel Lemos' Formsgen 
class. This is limited to the 7 digit number sans 3 digit area code. To 
be complete, the regex should disallow a phone number that begins with 
0 or 1, 555 or any digit followed by 11. Here is the regex I'm using:

^(?!\d[1]{2}|[5]{3})([2-9]\d{2})([-])\d{4}$
Manual Lemos indicated to me in an offline post that this should throw 
a javascript runtime error because of the (? at the beginning of the 
regex. I have tested it in over a dozen different browsers (Windows and 
Mac) and the only one that throws the runtime error is IE on the Mac. 
All others catch the errors I am trying to trap for with no runtime 
errors. Can this regex be improved on or do I have to live with the 
idiosyncratic behavior of Mac IE?

Thanks.
Albert Padley

Re: [PHP] Update Multiple Records From Form

2004-05-28 Thread Albert Padley
On May 28, 2004, at 3:50 AM, Ford, Mike [LSS] wrote:
On 28 May 2004 04:47, Albert Padley wrote:
I feel I'm so close.
I have a form with multiple database records with a checkbox to
indicate which records to update set up like so:
$name = "ed[" . $row['id'] . "]";

Each text input is set up like so:

On the processing page I am doing this:
foreach($ed as $id=>$val){
  $query = "UPDATE ref_events_reg
 SETfname = '$fname'
WHERE id = '{$id}'";
I am looping through the correct records, but every field is being
updated to "Array".
What tweak do I need to make?
I'd make two tweaks, actually.  First and most obviously, you're not 
selecting *which* fname field to pass to your update query, so this 
needs to be:

$query = "UPDATE ref_events_reg
 SET fname = '{$fname[$id]}'
 WHERE id = '{$id}'";
(By putting just $fname there, you are telling PHP to insert the 
string representation of the whole array -- and the string 
representation of any array is, er, exactly "Array"! ;)

This change may give you a clue to my other tweak -- I'd explicitly 
set the indexes of all the fname[] fields to be sure they sync 
correctly to the related check box, thus:




Cheers!
Mike
Mike,
Thanks for the tweaks. That solved the problem.
I had actually tried something like that, but obviously didn't have all 
the parts working together at the same time.

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


[PHP] Update Multiple Records From Form

2004-05-27 Thread Albert Padley
I feel I'm so close.
I have a form with multiple database records with a checkbox to 
indicate which records to update set up like so:

$name = "ed[" . $row['id'] . "]";


Each text input is set up like so:

On the processing page I am doing this:
foreach($ed as $id=>$val){
 $query = "UPDATE ref_events_reg
 SETfname = '$fname'
WHERE id = '{$id}'";
I am looping through the correct records, but every field is being 
updated to "Array".

What tweak do I need to make?
Thanks.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
On May 26, 2004, at 11:17 PM, Albert Padley wrote:
On May 26, 2004, at 11:16 PM, Curt Zirzow wrote:
* Thus wrote Albert Padley ([EMAIL PROTECTED]):

The processing code is:
if (count($del) > 0){
for ($i=0;$iI think you need to take a step back and figure out where the $del
variable is comming from.
Both solutions that have been provided should have worked if $del
was really an array.
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Curt,
I agree. I did a var_dump() with the following result:
array(2) {  ["del"]=>  array(2) {  [0]=>  string(2) "15"  [1]=>  
string(2) "16"  }  ["submit"]=>  string(6) "Delete" }

"15" and "16" are the correct id's for the records I'm trying to 
delete. However, when I echo $del[0] it returns "A" and when I echo 
$del[1] it returns "r" which happen to be the first 2 character in 
Array. So what gives?

Albert Padley
John, Tom and Curt,
I found that I had an include of functions that was somehow mucking 
things up. When I removed the functions page, all 3 of your solutions 
worked.

Thank you all for taking the time to assist.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
On May 26, 2004, at 11:16 PM, Curt Zirzow wrote:
* Thus wrote Albert Padley ([EMAIL PROTECTED]):

The processing code is:
if (count($del) > 0){
for ($i=0;$iI think you need to take a step back and figure out where the $del
variable is comming from.
Both solutions that have been provided should have worked if $del
was really an array.
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Curt,
I agree. I did a var_dump() with the following result:
array(2) {  ["del"]=>  array(2) {  [0]=>  string(2) "15"  [1]=>  
string(2) "16"  }  ["submit"]=>  string(6) "Delete" }

"15" and "16" are the correct id's for the records I'm trying to 
delete. However, when I echo $del[0] it returns "A" and when I echo 
$del[1] it returns "r" which happen to be the first 2 character in 
Array. So what gives?

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


Re: [PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
On May 26, 2004, at 7:55 PM, Tom Rogers wrote:
Hi,
Thursday, May 27, 2004, 11:34:03 AM, you wrote:
AP> I've checked the archives and several other sources, but still 
can't
AP> seem to make this work.

AP> I have a form with checkboxes to designate records to be deleted 
from
AP> the mysql database. The pertinent form code is:

AP> 

AP> The processing code is:
if (count($del) >> 0){
AP>  for ($i=0;$i  $query = "DELETE FROM ref_events_reg WHERE id = '$del[$i]'";
AP> }
AP> }
AP> Echoing the query produces:
AP> DELETE FROM ref_events_reg WHERE id = A
AP> I've also tried the following:
AP> $query = "DELETE FROM ref_events_reg WHERE id IN ('" . 
implode("','",
AP> addslashes($del)) . "')";

AP> This one produces a warning:
AP> Warning: implode(): Bad arguments.
AP> and the following query:
AP> DELETE FROM ref_events_reg WHERE id IN ('')
AP> Both attempts fail to delete any records even though several 
records
AP> are checked.

AP> Where have I gone wrong?
AP> Thanks.
AP> Albert Padley
change it to
   
   Then you can do something like
   foreach($del as $id=>$val){
 $query = "DELETE FROM ref_events_reg WHERE id = '$id'";
 //do query
   }
--
regards,
Tom
Tom,
When I tried this I received a warning - Warning: Invalid argument 
supplied for foreach()
and, of course, no records were deleted.

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


Re: [PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
On May 26, 2004, at 8:01 PM, John W. Holmes wrote:
Albert Padley wrote:
I've checked the archives and several other sources, but still can't 
seem to make this work.
I have a form with checkboxes to designate records to be deleted from 
the mysql database. The pertinent form code is:

The processing code is:
if (count($del) > 0){
for ($i=0;$i
$query = "DELETE FROM ref_events_reg WHERE id = 
'$del[$i]'";
}
}
Echoing the query produces:
DELETE FROM ref_events_reg WHERE id = A
Should be:
$query = "DELETE FROM ref_events_reg WHERE id = '{$del[$i]}'";
or
$query = "DELETE FROM ref_events_reg WHERE id = '".$del[$i]."'";
--
---John Holmes...
John,
Sorry, same result. No records deleted. Echoing the query returns:
DELETE FROM ref_events_reg WHERE id = 'A'
However, the id should be an integer. A var_dump() returns:
array(2) {  ["del"]=>  array(2) {  [0]=>  string(2) "15"  [1]=>  
string(2) "16"  }  ["submit"]=>  string(6) "Delete" }

Further, when I echo $del[0], it returns -- 'A' while $del[1] returns 
'r'. Just $del returns 'Array'.

Still working on it.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Delete Multiple Records From Checkboxes

2004-05-26 Thread Albert Padley
I've checked the archives and several other sources, but still can't 
seem to make this work.

I have a form with checkboxes to designate records to be deleted from 
the mysql database. The pertinent form code is:


The processing code is:
if (count($del) > 0){
for ($i=0;$i
Echoing the query produces:
DELETE FROM ref_events_reg WHERE id = A
I've also tried the following:
$query = "DELETE FROM ref_events_reg WHERE id IN ('" . implode("','", 
addslashes($del)) . "')";

This one produces a warning:
Warning: implode(): Bad arguments.
and the following query:
DELETE FROM ref_events_reg WHERE id IN ('')
Both attempts fail to delete any records even though several records 
are checked.

Where have I gone wrong?
Thanks.
Albert Padley
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php