Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Self help

Status
Not open for further replies.

kitfox69

Technical User
Aug 6, 2008
36
0
0
US
I have three PHP pages that post data to each consecutive page.

I would like the second page, the one with a pull down menu of customer ids, to spawn itself onto the next page so that the person using it would not have to click back to choose the next customer id.

Currently the first page captures and posts a date to the second page and the second page generates the pull down with values and has a get data submit button to forward to the third page where all the data is displayed.

How can I merge the second and third page together so that once a value is selected in the pull down and then the get data button is clicked it just populates the data right next to the pull down?

Script for page 2 and 3 below:

PAGE2:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"<html xmlns="<head>
<title>Today's Customers</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
$conn = odbc_connect("HOMES", "", "");
$billdate = $_POST[ 'billdate' ];
$query = ("SELECT DISTINCT sls_his_cust_id FROM sls_his where sls_his_prchdat_alt = $billdate");
$result = odbc_exec($conn, $query);

echo "<form method=post action=getcustdata.php>";
echo "<SELECT name=sls_his_cust_id>";
while($row = @odbc_fetch_array($result))
{
echo "<OPTION VALUE=\"$row[sls_his_cust_id]\">$row[sls_his_cust_id]</OPTION>";
}
echo "</SELECT><INPUT TYPE=submit name=custid VALUE=\"Get Data\"></FORM>";
?>
</body>
</html>

PAGE3:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"<html xmlns="<head>
<title>Customer Information</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body background="afi.jpg">
<?php
$conn = odbc_connect("HOMES", "", "");
$sls_his_cust_id = $_POST[ 'sls_his_cust_id' ];
$query1 = ("SELECT DISTINCT sls_his_d2_nam as 'Customer Name',
cust_phone_no as 'Phone Number 1',
cust_phone_no_2 as 'Phone Number 2',
cust_phone_no_3 as 'Phone Number 3'
FROM sls_his , cust
where CUST_ID = SLS_HIS_CUST_ID
and sls_his_cust_id = '$sls_his_cust_id'");
$query2 = ("SELECT DISTINCT sls_his_pft_ctr as 'Profit Center',
UPPER(slm_nam) as 'Sales Person'
FROM sls_his, slm
where sls_his_slm_1 = slm
and sls_his_cust_id = '$sls_his_cust_id'");
$query3 = ("SELECT sls_his_item_id as 'Item ID',
sum(sls_his_qty_sld) as 'Quantity Sold',
sls_his_prchdat_alt as 'Billed Date'
FROM sls_his
where sls_his_cust_id = '$sls_his_cust_id'
Group by sls_his_item_id, sls_his_prchdat_alt
Order by sls_his_prchdat_alt");
$result1 = odbc_exec($conn, $query1);
$result2 = odbc_exec($conn, $query2);
$result3 = odbc_exec($conn, $query3);
odbc_result_all($result1)

?>
</BR>
<?php
odbc_result_all($result2)

?>
</BR>
<?php
odbc_result_all($result3)

?>
</body>
</html>
 
get the pull down but moving to get the data still kicks Apache offline.

Below is the error log from Apache:

Code:
zend_mm_heap corrupted
[Sun Aug 17 23:45:57 2008] [notice] Parent: child process exited with status 1 -- Restarting.
[Mon Aug 18 07:58:23 2008] [warn] pid file D:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Mon Aug 18 07:58:25 2008] [notice] Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5 mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations
[Mon Aug 18 07:58:25 2008] [notice] Server built: Jan 18 2008 00:37:19
[Mon Aug 18 07:58:25 2008] [notice] Parent: Created child process 5408
[Mon Aug 18 07:58:29 2008] [notice] Child 5408: Child process is running
[Mon Aug 18 07:58:29 2008] [notice] Child 5408: Acquired the start mutex.
[Mon Aug 18 07:58:29 2008] [notice] Child 5408: Starting 250 worker threads.
[Mon Aug 18 07:58:29 2008] [notice] Child 5408: Starting thread to listen on port 443.
[Mon Aug 18 07:58:29 2008] [notice] Child 5408: Starting thread to listen on port 80.
zend_mm_heap corrupted
[Mon Aug 18 07:59:37 2008] [notice] Parent: child process exited with status 1 -- Restarting.
[Mon Aug 18 07:59:40 2008] [notice] Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5 mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations
[Mon Aug 18 07:59:40 2008] [notice] Server built: Jan 18 2008 00:37:19
[Mon Aug 18 07:59:40 2008] [crit] (22)Invalid argument: Parent: Failed to create the child process.
[Mon Aug 18 07:59:40 2008] [crit] (OS 6)The handle is invalid.  : master_main: create child process failed. Exiting.
[Mon Aug 18 07:59:40 2008] [notice] Parent: Forcing termination of child process 36 
[Mon Aug 18 08:01:34 2008] [warn] pid file D:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Mon Aug 18 08:01:36 2008] [notice] Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5 mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations
[Mon Aug 18 08:01:36 2008] [notice] Server built: Jan 18 2008 00:37:19
[Mon Aug 18 08:01:36 2008] [notice] Parent: Created child process 2700
[Mon Aug 18 08:01:41 2008] [notice] Child 2700: Child process is running
[Mon Aug 18 08:01:41 2008] [notice] Child 2700: Acquired the start mutex.
[Mon Aug 18 08:01:41 2008] [notice] Child 2700: Starting 250 worker threads.
[Mon Aug 18 08:01:41 2008] [notice] Child 2700: Starting thread to listen on port 443.
[Mon Aug 18 08:01:41 2008] [notice] Child 2700: Starting thread to listen on port 80.
zend_mm_heap corrupted
[Mon Aug 18 08:01:57 2008] [notice] Parent: child process exited with status 1 -- Restarting.
[Mon Aug 18 08:02:00 2008] [notice] Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5 mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations
[Mon Aug 18 08:02:00 2008] [notice] Server built: Jan 18 2008 00:37:19
[Mon Aug 18 08:02:00 2008] [crit] (22)Invalid argument: Parent: Failed to create the child process.
[Mon Aug 18 08:02:00 2008] [crit] (OS 6)The handle is invalid.  : master_main: create child process failed. Exiting.
[Mon Aug 18 08:02:00 2008] [notice] Parent: Forcing termination of child process 36

I posted the code exactly as jpadie posted with the slm.slm added in.
 
could be you have a buggy php installation that gets antsy with odbc calls.

the php code i provided is fine ( I think ). you could try debugging where things are going wrong by commenting out various sections. i would start with the odbc_result_all calls.

why are you using odbc by the way? what underlying database are you addressing?
 
Pervasive 9.5

I am running Debugs now and will let you know if I find something.

Note that using my original code for the data works fine using odbc_result_all amd the queries exactly as I have posted them... the only thing is that it showed three rows of No Rows Found once the Pulldown is populated... after that it all looks and works fine.

Posted below is what is being used now and is functioning:
Code:
<?php
$conn = odbc_connect("HOMES", "", "");
if (!empty($_POST['billdate'])){
    $billdate = $_POST[ 'billdate' ];
    //this is a REALLY bad idea.  you have not done any verification on $_POST['billdate'] and are thus open to a SQL injection attack
    $query = "SELECT DISTINCT sls_his_cust_id FROM sls_his where sls_his_prchdat_alt = $billdate";
    $result = odbc_exec($conn, $query);
    $options = '';
    while($row = odbc_fetch_array($result)){
        $options .= "\t\t<option value=\"{$row[sls_his_cust_id]}\">{$row[sls_his_cust_id]}</OPTION>\r\n";
    }

    echo  <<<HTML
<form method="post" action="getcustid.php">
    <div>
        <select name="sls_his_cust_id">
        {$options}
        </select>
        <input type="submit" name="custid" value="Get Data">
        <input type="hidden" name="billdate"value="$billdate" />
    </div>
</FORM>
HTML;
}

if (isset($_POST['custid'])) {
    $sls_his_cust_id = $_POST['sls_his_cust_id'];
}
$query1 = ("SELECT DISTINCT sls_his_cust_id as 'Customer ID',
sls_his_d2_nam as 'Customer Name',
cust_phone_no as 'Phone Number 1',
cust_phone_no_2 as 'Phone Number 2',
cust_phone_no_3 as 'Phone Number 3'
FROM sls_his , cust
where CUST_ID = SLS_HIS_CUST_ID
and sls_his_cust_id = '$sls_his_cust_id'");
$query2 = ("SELECT DISTINCT sls_his_pft_ctr as 'Profit Center',
UPPER(slm_nam) as 'Sales Person'
FROM sls_his, slm
where sls_his_slm_1 = slm
and sls_his_cust_id = '$sls_his_cust_id'");
$query3 = ("SELECT sls_his_item_id as 'Item ID',
sum(sls_his_qty_sld) as 'Quantity Sold',
sls_his_prchdat_alt as 'Billed Date',
sls_his_del_via as 'Ship Via'
FROM sls_his
where sls_his_cust_id = '$sls_his_cust_id'
Group by sls_his_item_id, sls_his_prchdat_alt, sls_his_del_via
Order by sls_his_prchdat_alt DESC");
$result1 = odbc_exec($conn, $query1);
$result2 = odbc_exec($conn, $query2);
$result3 = odbc_exec($conn, $query3);
?>
</BR>
<?php
odbc_result_all($result1)

?>
</BR>
<?php
odbc_result_all($result2)

?>
</BR>
<?php
odbc_result_all($result3)

?>
 
in this code
Code:
if (isset($_POST['custid'])) {
    $sls_his_cust_id = $_POST['sls_his_cust_id'];
}
what happens if $_POST['sls_his_cust_id'] is not set? will not all the queries fail? why is the whole block not conditioned by the if?

I have to say that I think my code is more likely to work than yours as it's friendlier to memory resources. but other than that, they look semantically identical and thus i'm surprised that you're getting errors or heap corruption.
 
Initially to use this page I have to start at enterbilldate.html where the yyyymmdd date is entered and the submit button is clicked... this pushes the $billdate variable to getcustid2.php.

When that loads up it shows the populated pulldown menu followed by three rows of "No rows found".

Once a sls_his_cust_id is selected and the get data button pressed, the data is shown and there are no other issues... the only time there is not a sls_his_cust_id selected is the initial load up coming from enterbilldate.html.

My code works fine other than the initial No rows found and has no errors during use.

I am still not sure why your code does not work... but if you are wanting to help I am moving on from this issue for now.

What I need to do now is keep the current data left aligned and have another form right aligned to collect answers to questions my customer satisfaction department will be asking. I want this on the same page as the data so that I can push the billdate and sls_his_cust_id into the insert statement so that the person using the page does not have to manually type them everytime.

I am working on the database table now and will process a query today.
 
for positioning forms, use css floats in surrounding divs. more help can be found in the css forum.

for a better user interaction you might consider ajax or iframes
 
No it does not work... I will just make a page with the images.
 
can you not provide us with access to your site?
 
No I cannot as this is not a public thing... it is an intranet server parsing the PHP and serving up the pages pulling the data from our database. It is all locked behind our VPN with no incoming port 80. You would have to be in my store or server location.
 
Ok I am checking out ipframes and it looks like that is my best bet... but I want to be sure that I will be able to pass along the variables to the iframe page. Also once I hit the submit button in the iframe will it only reload the frame or the whole page?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top