1337hovie
04-02-2010, 02:31 PM
Ok so i am new to the forums, and new to php as well.
What i am trying to do is: I have a large form with 3 drop downs at the bottom that are "School_1", "School_2", and "School_3". school_1, school_2, and school_3 are Columns in that person's record..basically i filled out a form with a persons information and assigned them 3 schools. (first name, last name, address, school_1, school_2, school_3) etc..So basically per record, it'll be like Brandon Smith, blah balh, School of Rock , ITT Tech , and DeVry University. and thats 1 record on table School_data. (so those people's records are on SCHOOL_DATA, and our employee's are on EMPLOYEE_INFO)
What my goal is: When you press submit on the form, it'll add all the fields to a database (which it already does..so thats complete(it's the added.php included at the top)), but i also need to process the information, meaning, for whatever school was used in the school_1, school_2, school_3 slots, ALL get "-1" from their $virtual_number(column Virtual_number (INT)). and if they're virtual_number hits "0", CHANGE status to PAUSED, and it wont populate in my drop downs (because only status =="live" populate in dropdowns). So not just will it -1, from the schools that were used in the 3 slots, also "+1" for each Successful School processed, to column "web" WHERE employee="$employee", So who's ever name is on the bottom in the EMPLOYEE field, gets credit for the slots that have schools in them.
So if Joseph Processed school_1, school_2, and school_3, the 3 schools get -1 from their virtual_number, and Joseph gets +3 to WEB. Here is a rough (and proabbly wrong) script i have..
Other things to know. All 3 slots might not be filled everytime, could be 1,2 or 3. So if school_1 != "", continue script. (so if it's NOT empty, process slot 1) and each if statement for EACH slot (total of 3).
What i have so far is most likely wrong syntax, which is what im trying to get help on. I had planned to just have the script run for school_1 and just copy and paste it, but i could put into an array. and just loop it through?
i know pretty much nothing about php, so if someone can just build this out for me, with what i have so far, just fix it - that would be very helful and i could understand how its done. I googled high and low, and thats how i came up with this, but i just need help finishing it.
someone has posted on this forum and a differnet one in the past, and thats how i found that virtual_number concept because it's so close to what i need - he had it in a button, i need to run it in a script.., i've tried contacting that person, no luck yet.
the code:
$res = mysql_fetch_assoc(mysql_query("SELECT * FROM school_data"));
$row=mysql_fetch_assoc($res)
$update = "UPDATE school_data SET $virtual_number = $virtual_number - 1 WHERE name=' . $row['name']'";
$credit = "UPDATE employee_info SET $web = $web + 1 WHERE employee='$employee'";
$schools = array('school_1', 'school_2', 'school_3');
$pause = "UPDATE school_data SET status='PAUSED' WHERE name=' . $row['name'] . "-" . $row['cid'] . '";
foreach($schools as $school) {
$school = $school;
if ($school !="")
mysql_query($update);
echo $school" -1";
}
elseif ($virtual_number =="0");
{
echo "<? echo "$school"; ?> is now PAUSED!";
mysql_query($pause);
}
else
{
echo $school "Lead Successfull!"
mysql_query($credit);
echo $school "Credited +1 Successful";
can someone just please fix this for me? Thank you!
What i am trying to do is: I have a large form with 3 drop downs at the bottom that are "School_1", "School_2", and "School_3". school_1, school_2, and school_3 are Columns in that person's record..basically i filled out a form with a persons information and assigned them 3 schools. (first name, last name, address, school_1, school_2, school_3) etc..So basically per record, it'll be like Brandon Smith, blah balh, School of Rock , ITT Tech , and DeVry University. and thats 1 record on table School_data. (so those people's records are on SCHOOL_DATA, and our employee's are on EMPLOYEE_INFO)
What my goal is: When you press submit on the form, it'll add all the fields to a database (which it already does..so thats complete(it's the added.php included at the top)), but i also need to process the information, meaning, for whatever school was used in the school_1, school_2, school_3 slots, ALL get "-1" from their $virtual_number(column Virtual_number (INT)). and if they're virtual_number hits "0", CHANGE status to PAUSED, and it wont populate in my drop downs (because only status =="live" populate in dropdowns). So not just will it -1, from the schools that were used in the 3 slots, also "+1" for each Successful School processed, to column "web" WHERE employee="$employee", So who's ever name is on the bottom in the EMPLOYEE field, gets credit for the slots that have schools in them.
So if Joseph Processed school_1, school_2, and school_3, the 3 schools get -1 from their virtual_number, and Joseph gets +3 to WEB. Here is a rough (and proabbly wrong) script i have..
Other things to know. All 3 slots might not be filled everytime, could be 1,2 or 3. So if school_1 != "", continue script. (so if it's NOT empty, process slot 1) and each if statement for EACH slot (total of 3).
What i have so far is most likely wrong syntax, which is what im trying to get help on. I had planned to just have the script run for school_1 and just copy and paste it, but i could put into an array. and just loop it through?
i know pretty much nothing about php, so if someone can just build this out for me, with what i have so far, just fix it - that would be very helful and i could understand how its done. I googled high and low, and thats how i came up with this, but i just need help finishing it.
someone has posted on this forum and a differnet one in the past, and thats how i found that virtual_number concept because it's so close to what i need - he had it in a button, i need to run it in a script.., i've tried contacting that person, no luck yet.
the code:
$res = mysql_fetch_assoc(mysql_query("SELECT * FROM school_data"));
$row=mysql_fetch_assoc($res)
$update = "UPDATE school_data SET $virtual_number = $virtual_number - 1 WHERE name=' . $row['name']'";
$credit = "UPDATE employee_info SET $web = $web + 1 WHERE employee='$employee'";
$schools = array('school_1', 'school_2', 'school_3');
$pause = "UPDATE school_data SET status='PAUSED' WHERE name=' . $row['name'] . "-" . $row['cid'] . '";
foreach($schools as $school) {
$school = $school;
if ($school !="")
mysql_query($update);
echo $school" -1";
}
elseif ($virtual_number =="0");
{
echo "<? echo "$school"; ?> is now PAUSED!";
mysql_query($pause);
}
else
{
echo $school "Lead Successfull!"
mysql_query($credit);
echo $school "Credited +1 Successful";
can someone just please fix this for me? Thank you!