[PHP] comparing two arrays in PHP3

2001-01-16 Thread Maurice Rickard

As my "learn PHP" project,  I'm setting up a version of my site to 
use it.  So far, so good.  I'm working on a relational system to 
handle what sections of my site go where in a hierarchy.

I'm able to add new rows to a table that relates categories to kinds 
of content.  That works fine, but my next step is what's confusing 
me.  I'm displaying the current subcategories ("flavors") as 
checkboxes in a form.  If they're selected, then they get passed to 
the next step and added to the relations table.  What I'd like to do, 
though, is have a checkbox already checked if there's an existing 
relation for it.

My first thought is taking the array of existing flavors and compare 
that array to the array of flavors that are children of the current 
parent category.  Array_intersect would seem to be perfect for this, 
but it's PHP4 only, right?  (I'm also open to the possibility that 
I'm approaching this in entirely the wrong way, so any contributions 
are welcome.)

Here's my existing code:

$childquery = "select * from flavors order by flavor";
$childtype = "flavor";
$childresult = mysql_query($childquery) or die(mysql_error());

//childresult behaves as expected

$relationsquery = "select * from relations where 
childtype='$childtype' and parenttype='$parenttype' and 
parentsku='$parentsku'";


$relationsresult = mysql_query($relationsquery) or die(mysql_error());

/* relationsresult is the other array I think I need; but I don't 
know what to do with it */

?>
form code goes in here, snipped for space/relevance
%s\n", $row["flavorsku"], $row["flavor"]);

}


Any ideas/thoughts or pointers to appropriate tutorials would be most 
helpful.  Thanks!

-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] Weird nested while loop problem

2001-01-17 Thread Maurice Rickard

In my attempt to simulate array_intersect in PHP3, I tried nesting 
while statements.  While traversing one array to display checkboxes, 
I wanted to loop through another array, testing to see if any of the 
values in it match the current value in the outer while loop.

What I'm getting is that the inner while loop executes on the first 
execution of the outer while, and then not at all.  How would I get 
it to execute each time?

Here's the code:

$childquery = "select * from flavors order by flavor";
$childtype = "flavor";
$childresult = mysql_query($childquery) or die(mysql_error());

$relationsquery = "select * from relations where 
childtype='$childtype' and parenttype='$parenttype' and 
parentsku='$parentsku'";
$relationsresult = mysql_query($relationsquery) or die(mysql_error());

?>


...various form variables...
Parent: 

%s\n", $thedisplay);

} //end the child results while loop



Thanks for any suggestions!
-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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 nested while loop problem

2001-01-17 Thread Maurice Rickard

Thanks!  This is starting to make sense...although when I try to 
reset what I thought was my array, I get the "Variable passed to 
reset() is not an array or object" error message.  Here's the 
relevant code:

$relationsquery = "select * from relations where 
childtype='$childtype' and parenttype='$parenttype' and 
parentsku='$parentsku'";

$relationsresult = mysql_query($relationsquery) or die(mysql_error());

while ($relationsrow = mysql_fetch_array($relationsresult)) {

$thischild = $relationsrow["childsku"];
if ($thevalue == $thischild) {
echo " checked";
}

} // end while for relations loop

reset($relationsresult);


Thanks again for your help so far!
Maurice


At 2:00 PM -0800 1/17/01, Rasmus Lerdorf wrote:
>>  > What I'm getting is that the inner while loop executes on the first
>>  > execution of the outer while, and then not at all.  How would I get
>>  > it to execute each time?
>>
>>  Coming from a perl background, I got stuck there too when I started using
>>  PHP.  PHP has this odd notion of an array pointer.  After the first time you
>>  loop through the array, the pointer is at the end, so the second loop won't
>>  really do anything.  Use the reset frunction to reset the array pointer to
>>  the first element.
>
>The array pointer can be pretty useful.  ie. give me the second last
>element of an array:
>
>   end($arr);
>   echo prev($arr);
>
>Or have it tell you what the index is at the second last element:
>
>   end($arr);
>   prev($arr);
>   echo key($arr);
>
>and the index before that one:
>
>   prev($arr);
>   echo key($arr);
>
>Perl has these too, they just aren't user accessible.
>
>-Rasmus
>
>
>--
>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]

-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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 nested while loop problem

2001-01-17 Thread Maurice Rickard

At 4:22 PM -0600 1/17/01, Darryl Friesen wrote:
>>  $relationsresult = mysql_query($relationsquery) or die(mysql_error());
>>
>>  while ($relationsrow = mysql_fetch_array($relationsresult)) {
>>
>>  $thischild = $relationsrow["childsku"];
>>  if ($thevalue == $thischild) {
>>  echo " checked";
>>  }
>>
>>  } // end while for relations loop
>>
>>  reset($relationsresult);
>
>Nope.  The array is $relationsrow (an array of the columns for the current
>row returned by mysql_fetch_array).  $relationresult is just that; a result
>'flag' for the query indicating whether or not the query was successful.

Hmm.  I get the same error for $relationsrow there.

At 5:22 PM -0500 1/17/01, Ignacio Vazquez-Abrams wrote:
>
>Um, no. $relationsresult isn't an array, it's a MySQL result resource. Use
>mysql_data_seek() instead.

OK, could this be why I'm getting the same error message for $relationsrow?

Thanks for the help, btw!

-Maurice

-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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 nested while loop problem

2001-01-17 Thread Maurice Rickard

At 5:22 PM -0500 1/17/01, Ignacio Vazquez-Abrams wrote:
>
>Um, no. $relationsresult isn't an array, it's a MySQL result resource. Use
>mysql_data_seek() instead.
>

Ah!  I get it!

mysql_data_seek($relationsresult,0);

does what I need it to do.

Thanks, everyone!

-Maurice
-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] date("t")

2001-01-18 Thread Maurice Rickard

I know I can get the number of days in the current month with 
date("t"), but how would I go about getting the number of days in a 
different month?

I have a form that allows users to insert a date.  If the value they 
put in doesn't exist (February 31, 2001, for example), I want to 
override it.  I'm already using checkdate to determine if a date is 
bad, but I'm a bit stumped on using date("t") to set a valid maximum 
for the month the user submits.  (I've set up the form so that users 
will always submit a valid month, but the day is my one loose end.)

Here's my code, if you'd like to make suggestions:

$ver_date = checkdate($date_month, $date_day, $date_year);

if ($ver_date) {

$safedate = $date_year."-".$date_month."-".$date_day;

} else {

//reset their date_day somehow

}


Thanks for any suggestions,
Maurice

-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] date("t")

2001-01-18 Thread Maurice Rickard

It does indeed work.  Thanks, Toby!

-Maurice

At 10:47 PM -0500 1/18/01, Toby Butzon wrote:
>You might try this:
>
>Arguments for mktime for my reference and for yours are ...
>
>int mktime (int hour, int minute, int second, int month, int day, int year
>[, int is_dst])
>
>Then put it together with date() like this...
>
>date("t", mktime(1, 1, 1, $mm, 1, $));
>
>This is untested, but should work.
>
>--Toby
>
-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] Potential upcoming PHP development project

2001-07-23 Thread Maurice Rickard

I have a potential project coming up that would require a developer 
well-versed in PHP.   The site is largely an information site with 
some ecommerce, but there will be various extras like membership 
areas, password-protected logins, and other interesting things.

If you're interested, please reply to me with a plaintext resume and 
the URLs of sites you've built in PHP.  Graphic design experience 
isn't particularly important; a solid understanding of PHP and what 
can be done with it is much more so. (HTML skills are essential, 
though.)  It would be helpful to know about any tricks or features 
you've made with PHP that you're proud of, and, of course, I'd like 
to know your rate.

Unfortunately, while the project itself is on quite a reasonable 
timeline (work likely to be done beginning in September and 
continuing for several months), we need to identify a qualified PHP 
developer immediately--so if you are interested, please respond as 
soon as you can.

Best regards,
Maurice

-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] Example high-profile PHP sites

2001-07-26 Thread Maurice Rickard

For a number of reasons, I need to offer a client a list of big, 
impressive-sounding, high-profile sites using PHP.  I went looking 
for the list on PHP.net, and the closest I could find is 
http://pt2.php.net/sites.php  which, as you'll see, is suffering from 
a fatal error.

I did find a list at http://php.datalogica.com/sites.php which, while 
helpful,  seems a bit dated.  Does anyone have some favorite examples 
that aren't on this list?

I've been preparing other arguments as well, but the "all the cool 
people are doing it" examples will help.

Thanks!
-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] Example high-profile PHP sites

2001-07-26 Thread Maurice Rickard

While I do appreciate people's contributions, let me frame the 
discussion a little.  The person I need to convince is an 
administrator of an organization within North America, and he's never 
heard of PHP.  The response I'm hoping to provoke in him is something 
like this:  "You mean _ is using this PHP thing?  Wow!  They 
know what they're doing, so we'd better use it, too!"

Does this help frame things?  Thanks for the suggestions!

-Maurice

At 10:59 AM -0600 7/26/01, Unni wrote:
>If every one is giving their website about mine
>http://www.malayalamovies.com
-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] Example high-profile PHP sites

2001-07-26 Thread Maurice Rickard

Good point.  I'm working on that data as well, but I thought getting 
a few marquee names wouldn't hurt matters.  But yeah, functionality 
(which is why I'm using it in the first place) should trump 
popularity.

-Maurice

At 11:23 AM -0700 7/26/01, John Meyer wrote:
>
>I'd probably suggest using more of a "What PHP can do" tactic rather 
>than "Who's using PHP".  I'm sorry, but the latter tactic seems like 
>a jumping on the bandwagon approach.
>
>
>John Meyer
>[EMAIL PROTECTED]
>Programmer
>
>
>If we didn't have Microsoft, we'd have to blame ourselves for all of 
>our programs crashing

-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] Re: Example high-profile PHP sites

2001-07-26 Thread Maurice Rickard

At 10:40 AM -0700 7/26/01, Philip Hallstrom wrote:
>>  I'd probably suggest using more of a "What PHP can do" tactic rather than
>>  "Who's using PHP".  I'm sorry, but the latter tactic seems like a jumping
>>  on the bandwagon approach.
>
>Yeah, but if you're trying to convince a pointy haired boss, this is the
>route you have to take.  It's sad, but it's true.

The person in question isn't the PHB type, but I'm not sure how many 
layers may have to be traversed in the chain of command.  Given that, 
as information is repeated, nuances of argument drop out, I figure 
that the names may remain.  And there's the old business saw that 
nobody was ever fired for doing whatever everybody else was doing.

-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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] Example high-profile PHP sites

2001-07-31 Thread Maurice Rickard

Hey, thanks, everyone for the examples!  I also dug up a few others 
that are worth considering:

http://www.dc.com/  Deloitte Consulting.  Now *that's* a big name.

Also HP, IBM, and, yes, Microsoft all run _some_ Apache/PHP servers 
(looking it up on Netcraft--use their OS vendors search)

Thanks again to all who have helped!
-Maurice

At 1:58 AM -0700 7/31/01, Ralph Guzman wrote:
>here are a few:
>
>http://www.marketplayer.com: they provide the real-time stock market
>simulations for sites like etrade.com and smartmoney.com that have these
>games.
>
>http://www.chek.com/
>
-- 
Maurice Rickard
http://mauricerickard.com/

-- 
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]