Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2005-10-21, 04:59 PM
Junior Member
 
Join Date: Oct 2005
Posts: 16
OldManRiver
Default

How do I write to the current screen or browser session?

Echo/Print always open a new session and I need to write to the current one.

I am setting a var in another .php that is called by my Form action= statement and it is processing OK but can't get the screen resfresh right.

Help Please!

OMR
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2005-10-21, 05:52 PM
Junior Member
 
Join Date: Oct 2005
Posts: 16
OldManRiver
Default

More information on what I'm trying to do:

HTML code which is an include file to a .SHTML file.
Code:
<?php
include("dd-process.php");
?>
<html>
<head>

</head>

<body bgcolor=white lang=EN-US link=black vlink=black>
<table border=0 width=500 cellspacing=0 cellpadding=0 align=center height=400 width=800>
  <form method=post action="dd-process.php" name=parts>
  <tr height=20>
  <td valign=top bgcolor="#ffffff">
  <center>
  <font face="Verdana" size="4"><b>My Title</b></font>
  <br>
  <font face="Verdana" size="3">Parts Catalog</font>
  <br>
  <font face="Verdana" size="3"><b>Category:</b></font>
  </td>
  </tr>

  <tr height=5>
  <td height=5></td>
  </tr>

  <tr height=30>
  <td align=center valign=top>
  <SELECT NAME="Type">
    <OPTION SELECTED>
    <OPTION value="Bkt">Buckets
    <OPTION value="Fan">Fans - Cooling
    <OPTION value="Air">Filters - Air, Lube, Industrial
    <OPTION value="Fld">Fluids
    <OPTION value="Hrd">Hardware
    <OPTION value="Int">Intake/Exhaust Systems
    <OPTION value="Pre">Pre-Cleaning - Air
    <OPTION value="Scr">Scrapers
    <OPTION value="Tee">Teeth
    <OPTION value="Tir">Tires
    <OPTION value="Tol">Tools - Ground Engaging
    <OPTION value="Use">Used Parts
  </SELECT>
  <br><br>
  <input type=submit name=Prc value=Get>
  </td>
  </tr>

  <tr height=5>
  <td height=5></td>
  </tr>

  <tr>
  <td>
  <table border=5 height=300>
  <! Write the table elements from the PHP script! >
  <?php
    echo "Found Table!";
    echo $mid_block;
  ?>
  </table>
  </td>
  </tr>
  </form>
</table>
</body>
</html>
PHP script code
Code:
<?php
$mid_block = "<tr><td></td></tr>";
if ($_POST["Type"] == 'Fan') {
  echo "Found Fan!";
  $mid_block = "
    <tr>
    <td rowspan=3 width=25%>
    <img src='./Images/flexxairefan.gif'>
    </td>
    <td colspan=2 width=75%>
    <font face=Verdana size=3>
    <b>Cooling Fans by&col;
    </td>
    </tr>

    <tr>
    <td>
    <font face=Verdana size=3><ul>FlexxAire</ul>
    </td>
    </tr>

    <tr>
    <td>
    <font face=Verdana size=3><ul>SandVik</ul>
    </td>
    </tr>
  ";
} elseif ($_POST["Type"] == 'Air') {
  echo "Found Air!";
  $mid_block = "
    <tr>
    <td rowspan=3 width=25%>
    <img src='./Images/luberfiner.jpg'>
    </td>
    <td colspan=2 width=75%>
    <font face=Verdana size=3>
    <b>Cooling Fans by&col;
    </td>
    </tr>

    <tr>
    <td>
    <font face=Verdana size=3><ul>FlexxAire</ul>
    </td>
    </tr>

    <tr>
    <td>
    <font face=Verdana size=3><ul>SandVik</ul>
    </td>
    </tr>
  ";
}
?>
This process OK as I see the "Found <value>" statement, but in a new session, which blanks the original browser session and writes just the echo value.

Need this to write In place when the button is clicked/activated. Since this is part of an included file the orginal must stay in place.

Tried leaving out the echo(s) but saw no processing, included to check processing. I also look through the online PHP help to see if there was a refresh command so my inline echo would refresh it's value, but could not find anything on refresh.

If you need I can include a generic stripped version of the .SHTML file as well, which is the template file. This whole thing writes into a non-frame text area on the page.

Wanted to do buttonless but settled on the button as I could not find anything to support other activities unless I added a Java Script.

OMR
Reply With Quote
  #3 (permalink)  
Old 2005-10-22, 03:09 PM
Member
 
Join Date: Aug 2005
Location: Petoskey, MI
Posts: 83
n8dnx
Default

OldManRiver:

HTML is by it's very nature not interactive but page oriented. You click and you get another page. There are ways around this.

One is to simply redisplay the entire page again with all of the information updated as you'd like it. This is the standard way to handle this kind of situation.

Another is to use frames, which has all kinds of issues with it, but can do what you want. In essence, they're separate pages, you only update the frame and the rest of the page remains as it was.

Yet another is DHTML/JAVA which runs client-side to update the information locally on the user's computer. This approach either requires all possible information to be sent to the browser before the user makes the selection or has the added complexity of having to establish communications with the server again, which isn't standard with JAVA.

There's nothing wrong with taking the first approach and if you're going to be interacting with a database, it's likely your best approach.
Reply With Quote
  #4 (permalink)  
Old 2005-10-26, 02:13 AM
Junior Member
 
Join Date: Oct 2005
Posts: 16
OldManRiver
Default

All,

I found the newt_refresh ( void ) function in the online manual at:

http://us2.php.net/manual/en/function.newt-refresh.php

Going to test this to see if it does what I need. I know I cant set action to "self" or derivative thereof. Do you know the correct syntax?

OMR
Reply With Quote
  #5 (permalink)  
Old 2008-01-04, 05:48 AM
Junior Member
 
Join Date: Oct 2005
Posts: 16
OldManRiver
Default Fixed

All,

Fixed this. Post with final code at:

PHP - Drop Down List Mastery

Thanks all!

OMR
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:38 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.