By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,966 Members | 812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,966 IT Pros & Developers. It's quick & easy.

Re: if statement in an elseif block with a preceeding exit statement

P: n/a
JRough <jl*****@yahoo.comwrote:
>
You are right there was a missing ' " '

However, there is still a syntax problem with the if inside the elseif
which was my original question.

}elseif($_POST['redirect']&&$_POST['redirect']!=$_SERVER['PHP_SELF']){
Header("Location: ".$_POST['redirect'].".php?id=".$_POST['id']);
exit;

if($_POST['assign']=='Open in Excel'){
Header("Location:
http://allcapitalrailmanagement.com/fakerockridge/tracing_reportsXL.php?param=".$_POST['redirect']."&id=['id']);
exit;
}
}
More than the syntax problems, you also have a logic problem here. How do
you think that "if" statement is ever going to be hit, given the statement
immediately before it?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 31 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
>
More than the syntax problems, you also have a logic problem here. *Howdo
you think that "if" statement is ever going to be hit, given the statement
immediately before it?
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
That was my original question! I did make some syntax errors because
I don't know how to pass paramaters in headers very well which I think
I have solved. That was my question though, where do I put the if for
the Excel button because it has to go after the page redrawing because
the user selects a choice in the html form in that redirect elseif.
That paramater has to pass to the Excel page and that determines which
query runs.
thanks,
<?
# * * * * ***********************************************
# * COPYRIGHT 2006 All Capital Rail Management ALL RIGHTS RESERVED
# * * * * ***********************************************
# * jkovac
# * 10.22.2007
# * current_sightings.php
# * PROVIDES THE LAST CLM FOR EACH CAR IN WHATEVER PARAMETER IS
PASSED: (lease, managed group, pool, etc)
# * modified by jrough
# * 7/15/2008
# * modified to add Excel button, see note

include './includes/config.inc.php';
include $include_path.'dates.inc.php';
include $include_path."LMS_functions.inc.php";

################################################
//Is the user logged in?
Validate_login("tracing_reports.php");
//if the $id is empty then one of the radio button options with name
'redirect' in the html form has not been posted
if(empty($id)&&($_SESSION["LMS_USER_DESC"]=='internal')){

# THIS IS id INSTEAD OF lease_id B/C ONE DAY WE MIGHT HAVE CUSTOMER
SUB GROUPS OR MANAGED CARS
$destroyed = GetDestroyed_lease_id();
$result = SELECT_leasesCLM();
$TPL_ids = "<SELECT name='id' class=box size=8>\n";
$trbg = "";
while($row = mysql_fetch_assoc($result)){
$id = $row['lease_id'];
$lnum = $row['lease_num'];
$comp = $row['comp_name'];

$trbg = GetTRBG($trbg);

$TPL_ids.=" <OPTION VALUE='".$id;
$TPL_ids.="' ".$trbg.">".$lnum." - ".$comp."</OPTION>\n";
}
$TPL_ids.="</SELECT>\n";
include "header.php";
include $template_path."tracing_reports_php.html";

}elseif($_POST['redirect']&&$_POST['redirect']!=$_SERVER['PHP_SELF']){
Header("Location: ".$_POST['redirect'].".php?id=".$_POST['id']);
if($_POST['assign_x']=='Open in Excel'){
Header("Location: tracing_reportsXL.php".
$_POST['redirect']."&id=['id']));
exit;
}
}

include "footer.php";
######################################
##
## FUNCTIONS
##
######################################

################################
##
## QUERIES
##
################################
function SELECT_leasesCLM(){
$query = "SELECT DISTINCT l.lease_id, m.lease_num, co.comp_name
FROM INTERNAL_LEASES l, INTERNAL_MASTER_LEASE m, INTERNAL_COMPANY
co,
INTERNAL_CAR_LEASE cl, INTERNAL_REMARK r, INTERNAL_CLM c
WHERE co.comp_id = m.comp_id
AND m.master_lease_id = l.master_lease_id
AND l.lease_id = cl.lease_id
AND cl.end_date IS NULL
AND cl.remark_id = r.remark_id
AND r.car_mark = c.car_mark
AND r.car_number = c.car_number";
$result = mysql_query($query);
if(!$result){
MySQLError($query);
exit;
}
return $result;
}
?>
Jul 31 '08 #2

P: n/a
tax problems, you also have a logic problem here. *How do
you think that "if" statement is ever going to be hit, given the statement
immediately before it?
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
The error I get now is:

Parse error: syntax error, unexpected T_STRING in /home/dhandler/
public_html/fakerockridge/tracing_reports.php on line 75
Jul 31 '08 #3

P: n/a
JRough <jl*****@yahoo.comwrote:
>
That was my original question! I did make some syntax errors because
I don't know how to pass paramaters in headers very well which I think
I have solved. That was my question though, where do I put the if for
the Excel button because it has to go after the page redrawing because
the user selects a choice in the html form in that redirect elseif.
That paramater has to pass to the Excel page and that determines which
query runs.
A single HTTP request can only redirect to one place at a time, and if you
are redirecting with a "Location" header, that page is done.

It sounds kind of like you have a chain of requests here. You have a form
on page A; user fills in some information and does a submit, which brings
up page B. User makes some other entry, which redirects to your Excel
download. Is that right? Then clearly, the redirect to Excel has to
happen in the processing for page B. If you have to pass some fields
between them, then you either need a long URL in the Location header, or
you need to use Javascript to do a POST instead.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Aug 2 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.