Hi,
Can anyone help me with flow control?
I've tried using a switch as suggested but have had no luck stopping the form code from displaying on the popup page.
Any ideas? Please?
tks, Wil
<?php
include "includes/functions.inc";
include "includes/common_db.inc";
$link_id = db_connect($db);
function list_summary() {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<? $sql_query = mysql_query("SELECT description, stockId FROM austock");
echo "<select name=\"stockId\">";
while(list($stockId)=mysql_fetch_array($sql_query)) {
echo "<option value=\"$stockId\">$stockId</option>";
}
echo "</select>";
mysql_free_result($sql_query);
?>
<br><br><input type="submit" name="submit" value="submit me!">
<br><br><input type="submit" name="viewDetails" value="View Details">
</form>
<?
if ($_POST['submit']) {
echo '<pre>';
print_r($_POST);
echo "<h1>Submitted to DB</h1><br>";
echo '<a href="'. $_SERVER['PHP_SELF'] .'">Please try again</a>';
echo "</pre>";
// Set Up viewDetails
} elseif ($_POST['stockId']) {
view($_POST['stockId']);
}
if($_GET['action'] == 'view_record' && isset($_GET['stockId'])) view_record();
}
function view($stockId) {
echo "<script language=\"javascript\">var newWindow = window.open('".$_SERVER['PHP_SELF']."?action=view_record&stockId=".$stockId."')</script>";
}
function view_record() {
print "hello world <br>";
$stockId = $_GET['stockId'];
echo $stockId ;
print "<br>";
}
switch($action) {
case "view_record":
view_record();
print "Hello Print 1";
break;
default:
list_summary();
print "Hello Print 2";
break;
}
?>