Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2006, 10:10 PM
Authorized User
 
Join Date: Feb 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default show/hide row(s)

Hi All.
I create form/page and would like to show whole row(s) under NOTE-1 if value of field TYPE is 3 and show whole row(s) under NOTE-2 if value of field TYPE are 1 or 2. And I would like hide whole row(s) under NOTE-1 if value of field TYPE is 3 doesn't exist and hide whole row(s) under NOTE-2 if value of field TYPE are 1 or 2 doesn't exist for according ID. That is my code.
Code:
<?php 
  include ('Connections/dbconn.php'); 

    if (!($connection = @ mysql_pconnect($hostname, $username, $password))) 
        die("Could not connect to database"); 
    if (!mysql_select_db($dbName, $connection)) 
            showerror( ); 

$ID = $_REQUEST['ID']; 
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<title>Untitled Document</title> 
</head> 
<body> 
<form method="POST" action="Update.php" name="update"> 
<table width="100%"  border="0" cellspacing="0" cellpadding="2"> 
<? 
    $query1 = "SELECT ID, Type, Date, Note 
                FROM dbo.Test 
                WHERE ID = " . $ID; 
    if (!($result1 = @ mysql_query($query1, $connection))) 
        showerror( ); 
while($row1 = mysql_fetch_array($result1)) 
{ 
    $formVars = array( ); 
    $formVars['Type'] = $row1['Type']; 
    $formVars['Date'] = $row1['Date']; 
    $formVars['Note'] = $row1['Note']; 

    if ($formVars['Type'] == 3) 
    { 
?> 
  <tr> 
    <td width="7%"><input type="hidden" name="Type" value="<? echo $Type; ?>"></td> 
  </tr> 
  <tr align="center"> 
    <td width="7%"><input name="submit" type="submit" value="add"></td> 
    <td width="18%">DATE</td> 
    <td width="75%">NOTE-1</td> 
  </tr> 
  <tr> 
    <td align="center" valign="bottom"><input name="note" type="submit" value="del"></td> 
    <td> 
<?php 
    if(isset($formVars['Date']) && $formVars['Date'] != "") 
    { 
        $formVars['Date'] = date("m/d/Y", strtotime($formVars['Date'])); 
    } 
?> 
    <input name="NoteDate" type="text" value="<?php echo $formVars['Date']; ?>" size="20"> 
    </td> 
    <td><input type="text" name="Note" value="<?php echo $formVars['Note']; ?>" size=107></td> 
  </tr> 
<? 
    } 
    if ($formVars['Type'] == 1 || $formVars['Type'] == 2) 
    { 
?> 
  <tr> 
    <td colspan="4" align="center">&nbsp;</td> 
  </tr> 
  <tr align="center"> 
    <td width="7%" align="center"><input name="submit" type="submit" value="add"></td> 
    <td width="18%">DATE</td> 
    <td width="75%">NOTE-2</td> 
  </tr> 
  <tr> 
    <td align="center" valign="bottom"><input name="note" type="submit" value="del"></td> 
    <td> 
<?php 
    if(isset($formVars['Date']) && $formVars['Date'] != "") 
    { 
        $formVars['Date'] = date("m/d/Y", strtotime($formVars['Date'])); 
    } 
?> 
    <input name="NoteDate" type="text" value="<?php echo $formVars['Date']; ?>" size="20"> 
    </td> 
    <td><input type="text" name="Note" value="<?php echo $formVars['Note']; ?>" size=107></td> 
  </tr> 
<?    } 
} 
?> 
</table> 
</form> 
</body> 
</html>
Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide/Show Desktop icons jpool Visual Basic 2005 Basics 0 July 27th, 2008 02:47 PM
HIDE/SHOW pallone Javascript How-To 11 April 16th, 2007 10:24 AM
how to show/hide forms ? ashrafzia C# 3 November 3rd, 2006 11:07 AM
Programatically Show Hide Textboxes miriv365 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 April 19th, 2005 08:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.