p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > PHP/MySQL > Beginning PHP
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 19th, 2006, 10:10 PM
Authorized User
 
Join Date: Feb 2006
Location: , , .
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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide/Show Desktop icons jpool Visual Basic 2005 Basics 0 July 27th, 2008 03:47 PM
HIDE/SHOW pallone Javascript How-To 11 April 16th, 2007 11: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 09:08 PM
Show/Hide in a DataGrid bmains ASP.NET 1.1 1 July 29th, 2004 04:16 PM



All times are GMT -4. The time now is 06:13 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc