Stuff!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hudson
Forum Newbie
Posts: 3
Joined: Tue Apr 30, 2002 5:49 am

Stuff!

Post by hudson »

yes yes i know its a lame question,, so just help me and prove me to be so.

ok here's my situation...
i'm creating an invoicing system ,, i have a table for invoices and a table for the services applicable
..i also have a form to generate a invoices ..it lists all the services dynamically with an array from the services table and gives each one its own checkbox with a name like name=sid_array[] and a value=$sid ..
this is all fine so far.
..when submitted to the generation page which will do all the work(totals and costs for services) i do something like this
if ($sid_array)
{
$stypes = implode($sid_array, "|");
}
(which gives me the service id's in this form 1|2|3..etc)(this is the form i need the services id's in for storage in a single field in case your wondering)
now wut i need to do is be able to take each seperate $sid (in either the $sid _array or $stype) and do a lookup with mysql on the services table and list the the matching records/services..
i'm having some hell of a time doing this.. anyone have any ideas?
samscripts
Forum Commoner
Posts: 57
Joined: Tue Apr 23, 2002 4:34 pm
Location: London, UK

Post by samscripts »

Hi, do you just want to get the records that have an service id that is in $stypes?

Code: Select all

$sids = implode(",", $sid_array);

$sql = "SELECT * FROM servicestable WHERE serviceid IN ($sids)";

$etc = mysql_query($sql).....
Sam
hudson
Forum Newbie
Posts: 3
Joined: Tue Apr 30, 2002 5:49 am

Post by hudson »

Yes thats exactly wut i mean,, or at least i got it to work the way i wanted.
.
One more question.

now that i can match all of those sids to records and display them. and it gives me all the pertanent services/records.

i need to be able to take cost's for each listed item and add them(i know how to do the math :P ),, but how do i make each service field the array spits out a unique var that i can take and manipulate...a.k.a. it looks somethin like this currently

//fetch all matching record to sid's
$sql = "SELECT * FROM services WHERE sid IN ($stypes)";
$sql_result = mysql_query($sql,$link);
while ($row = mysql_fetch_array($sql_result)) {
$sinfo1 = $row["id"];
$sinfo2 = $row["sid"];
$sinfo3 = $row["stype"];
$sinfo4 = $row["sfee"];
$sinfo5 = $row["sgst"];
$sinfo6 = $row["spst"];
$sinfo7 = $row["sdescription"];
$sinfo8 = $row["sdiscount"];

echo "<BR><BR>$sinfo1 | $sinfo2 | $sinfo3 | $sinfo4 | $sinfo5 | $sinfo6 | $sinfo7 | $sinfo8";
}

now how do i get it so that at least $sinfo4 = $row["sfee"]; is unique each time around so i can come up with a total for the selected services
or what would be the best way to do this?
get what i mean?
Post Reply