Advertisement

05.15.2008 at 06:16AM PDT, ID: 23404931
[x]
Attachment Details

elseif statement not working

Asked by peter_coop in PHP Scripting Language, MySQL

Tags: php, mysql

hello. i shall try to explain fully what i am trying to do. page1 contains a form which has a input field called box_add and a checkbox with the name 'boxes' and value of 'Box Retrival'. in page 2 i m trying to create a condition that tests for the value passed from page1. i am however having trouble getting pass the first isset statement of page 2. if i just enter a value it deals with the value correctly in the first part of th statement. but if i try to evaluate using post from form, it dosen't go to th next else statement.i have attached the code for your help. many thanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
page1 form
 
<label>
                <input name="boxes" type="radio" value="New Intake" checked="checked" />
 				 Intake</label>
                <label>
                <input type="radio" name="boxes" value="Box Return" />
			  Return</label>
                <label>
                <input type="radio" name="boxes" value="Box Retrival" />
			  Retrive</label>
                <br />
                <label>
                <input type="radio" name="boxes" value="Box Destruction" />
  				Destruction</label>
                <label>
                <input type="radio" name="boxes" value="Box Supply" />
			  Supply</label></fieldset></p>
                
             <p><fieldset><legend><strong>Select Service Level</strong></legend> 
             
               <label>
               <input name="service" type="radio" value="standard" checked="checked" />
  				Standard</label>
<input type="textfield" name="box_add[]" size="25" multiple="multiple" id="box_add" />
----------------------------------------------------------------------
page2 statement
 
<?php 
 
if(isset($_POST['box_add']) && sizeof($_POST['box_add']) > 0)
{
    // To make sure the user did include the 'box'
    // We will need this variable later on!
    $shall_we_proceed = true;
 
    // Here, we will loop each box's value and query it to check whether exist or not.
    // Ofcourse, it might be slower than yours previous posting, whereby using only 1 statement.
    // Is up to you to use which algorithm you wish to validate it. ^^
    foreach($_POST['box_add'] as $val)
    {
        $sql = "SELECT custref FROM boxes WHERE custref='$val'";
        $qry = mysql_query($sql) or die(mysql_error());
        $nRecords = mysql_num_rows($qry);
        if(mysql_num_rows($qry))
        {
            echo '<span style="font-weight:bold;color: #ff0000;">' . 'That record already exists in the database: ' . '</span>' . '<span style="font-weight:bold;color: #000;">' . '('  . $val . ')' . '</span>' . '<br />' . '<span style="font-weight:bold;color: #ff0000;">' . 'Please select another' . '</span>' . '<p />';
            $shall_we_proceed = false;
            break;    // Quit the loop
        }
    }
 
    if($shall_we_proceed)
    {
        // Okay! We can proceed!
       echo 'You have Added ref: ' . '<span style="font-weight:bold;color: #000;">' . $val . '</span>' . '<p />';
		$_SESSION['box_add'] = $_POST['box_add'];
    } 
}
else
 
if(isset($_POST['box_add']) && ($_POST['boxes']) == 'Box Retrival' && sizeof($_POST['box_add']) < 0)
{
    // To make sure the user did include the 'box'
    // We will need this variable later on!
    $shall_we_proceed = true;
 
    // Here, we will loop each box's value and query it to check whether exist or not.
    // Ofcourse, it might be slower than yours previous posting, whereby using only 1 statement.
    // Is up to you to use which algorithm you wish to validate it. ^^
    foreach($_POST['box_add'] as $val)
    {
        $sql = "SELECT custref FROM boxes WHERE custref='$val'";
        $qry = mysql_query($sql) or die(mysql_error());
        $nRecords = mysql_num_rows($qry);
        if(mysql_num_rows($qry))
        {
            echo '<span style="font-weight:bold;color: #ff0000;">' . 'That record already exists in the database: ' . '</span>' . '<span style="font-weight:bold;color: #000;">' . '('  . $val . ')' . '</span>' . '<br />' . '<span style="font-weight:bold;color: #ff0000;">' . 'Please select another' . '</span>' . '<p />';
            $shall_we_proceed = false;
            break;    // Quit the loop
        }
    }
 
    if($shall_we_proceed)
    {
        // Okay! We can proceed!
       echo 'You have Requested ref: ' . '<span style="font-weight:bold;color: #000;">' . $val . '</span>' . '<p />';
		$_SESSION['box_add'] = $_POST['boxes'];
    } 
}
else
{
    // Error!
    echo "hey! please add box!";
}
 
 
?>
 
Loading Advertisement...
 
[+][-]05.15.2008 at 06:22AM PDT, ID: 21573271

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 06:24AM PDT, ID: 21573297

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 06:25AM PDT, ID: 21573311

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 06:52AM PDT, ID: 21573605

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 07:05AM PDT, ID: 21573744

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 07:19AM PDT, ID: 21573899

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 07:39AM PDT, ID: 21574134

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 07:46AM PDT, ID: 21574212

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 07:55AM PDT, ID: 21574304

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 08:00AM PDT, ID: 21574366

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, MySQL
Tags: php, mysql
Sign Up Now!
Solution Provided By: cyberwebservice
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.15.2008 at 08:12AM PDT, ID: 21574522

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:11AM PDT, ID: 21575203

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:12AM PDT, ID: 21575223

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 02:33PM PDT, ID: 21578177

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 03:02PM PDT, ID: 21578333

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.15.2008 at 03:13PM PDT, ID: 21578395

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:45PM PDT, ID: 21580080

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 09:50PM PDT, ID: 21580100

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 02:39AM PDT, ID: 21581285

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 06:52AM PDT, ID: 21582636

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 12:27PM PDT, ID: 21585674

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 02:11PM PDT, ID: 21586474

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 02:37PM PDT, ID: 21586644

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 03:58PM PDT, ID: 21587065

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 04:49AM PDT, ID: 21588826

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628