Posted by Malcolm Dew-Jones on 09/20/05 23:36
elyob (newsprofile@gmail.com) wrote:
: Hi,
: I'm looking at storing snippets of details in MySQL about what credit cards
: a business excepts. Rather than have a whole column for Visa, another for
: Amex etc ... I am looking at having a column called payment types and
: inserting multiple codes ... e.g. ViAmBcCa
: Is this a good way of doing things?
No. The "correct" way would be a table that lists businesses and the
cards they accept.
create table business_accepts_cards
(
business_id
card_id
)
Other methods might occasionally be best, but I can't think of a good
example off hand.
E.g. to make a form to accept payment, you'll end up with something like
echo <select name = customer-card-type>
$sql = select card_id from business_accepts_cards
where business_id = $this_business_id
while ($row = fetch row)
{
echo <option value= $row[card_id]> $row[card_id] </option>
}
echo </select>
I.e. the code will almost always be straight forward.
$0.10
--
This programmer available for rent.
[Back to original message]
|