[GRLUG] PHP question ... was Client/Server Database app question

Chris Lamrock clamrock at nmtdie.com
Thu Feb 2 09:52:12 EST 2006


Hey guys,

You may recall I am tinkering on reworking a quoting program here at work
currently written in FOXPRO.  I've got a customer database set up in MySQL
and have some of the first program working in PHP.

I can now display a customer and click on a NEXT or PREVIOUS button (FORM
SUBMIT stuff) to display the next or previous user.  Works pretty slick.

Now I have created (with the help of much googling) a search page that
brings up a selection box that populates with the customer's name from MySQL
and is mostly working.

What I would LIKE to do is be able to call or run the search.php from my
customers.php file when I hit the FIND button on that page.  From lots of
googling and looking at examples I'm not sure if I'm on the right track.

Can I just call find.php from within customer.php easily? Using the <form
submit buttons? Is this the right way to do it?

I know the info is a little sketchy but hey - that's the level of my php
knowlege so far!  ;-)

Any help is greatly appreciated as always!

-Chris


-----Original Message-----
From: grlug-bounces at grandrapids-lug.org
[mailto:grlug-bounces at grandrapids-lug.org]On Behalf Of zdennis
Sent: Thursday, January 19, 2006 8:52 AM
To: GRLUG general mailing list
Subject: Re: [GRLUG] Client/Server Database app question


Chris Lamrock wrote:
> Right now the program is made up of 4 or 5 live databases.  One with
quotes,
> one with customers, notes, signatures and companies - all running in
Foxpro
> (since 1995!) :-)
>
> So the databases would be created new in Mysql or what have you...
>
> Is that what you were asking?
>

Yeah, I am thinking that I'd like to show you a neat database trick. Here is
what sample code looks
like. I am a big fan of simplifying database access:

Say you have a customers table in the databse and it has a relationship to
the signatures table.

class Customer < ActiveRecord::Base
   has_many :signatures
end

class Signature < ActiveRecord::Base
   has_one :customer
end


That right there handles our relationship between Customer and Signature. Do
save data to the
databse you'd write:

customer = Customer.new
customer.name = "Jon Doe'
customer.company = 'ABC Corp.'

signature = Signature.new
customer.signature = signature

customer.save
signature.save


And that's pretty much it. Of course it gets more advanced and you can get
crazy with complex joins
and conditions on queries, but it makes accessing the databse 1000% nicer,
then using Perl::DBI or
something similar.

This may/may-not fix what you're going for, but I thought I'd throw it out
as a suggestion. The
sample code above is from the ActiveRecord portion of Ruby On Rails.
Although you can use
ActiveRecord by itself without Rails, I use it alot.

Whatever you choose, good luck!

Zach

_______________________________________________
grlug mailing list
grlug at grandrapids-lug.org
http://grlug.org/mailman/listinfo/grlug

!DSPAM:43cfa62b58788274788315!







More information about the grlug mailing list