473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to get table detail clicking on row?

HI,

I have table what I display on form. The table has multiple row with the same projectNumber, but difference description.
I need to click on row and another form open with detail belong to this row.
Is anybody can give code sample how to do this?
How can i find out that i click on right row?

Thanks
Jun 13 '07 #1
5 4042
Purple
404 Expert 256MB
Hi,

first thoughts are Javascript and clientside technologies, take a look at extjs.com the paged grid exampe. There are a number of the ajax components which will get you what you need.

if you want a quick solution without heavy javascript / ajax you could always use a submit button formatted with CSS to look a little more like your page style. by setting the value of the submit on each row of the table to a key on your database and using array_flip on $_post you can work out which row has been selected..

Hope this helps..

Regards Purple
Jun 13 '07 #2
i think i like more second solution............could you please base on my code give me exemple. I need to know how to add value to every row, i think i know how to do this, but i am not sure how to pass this to another page


THIS IS MY TABLE DISPLAY FORM:
Expand|Select|Wrap|Line Numbers
  1.  <?php
  2.     echo "    
  3.     <tr>
  4.     <td colspan='3'>
  5.         <form name='controltest' method='post'>
  6.           <div style='overflow:auto; height:100px;'>    
  7.     <table align='center' width='90%' border-style='inset'  padding='0' bgcolor='#FOFOFO' >
  8.     <tr>
  9.     <th bgcolor='#FOFOFO' align='left'><font color='navy'>Functionality to be Tested</font></th>
  10.     <th bgcolor='#FOFOFO' align='left'><font color='navy'>Person Responsible</font></th>
  11.     <th bgcolor='#FOFOFO' align='left'><font color='navy'>Due Date</font></th>
  12.     <th bgcolor='#FOFOFO' align='left'><font color='navy'>Completion Date</font></th>
  13.     </tr>"; 
  14.  
  15.       $controlQuery="SELECT * 
  16.             FROM project_controltest
  17.             WHERE projectNumber='$POST_projectNumber'";
  18.             $result=mysql_query($controlQuery);
  19.             $controlFound=false;
  20.             $controlNumber=0;
  21.             $count=mysql_num_rows($result);                
  22.         while ($controlrow = mysql_fetch_array($result)) {
  23.                         $controlFound=true;
  24.                     $controlNumber=$controlNumber+1;
  25.  
  26.     echo "                
  27.         <tr bgcolor='white'> " ;      
  28.  
  29.        echo "<tr input type='hidden' name='control' value='$controlNumber'> ";
  30.        echo "<tr input type='hidden' name='projectNumber[$controlNumber]' 
  31.        id='projectNumber' value='$controlrow[projectNumber]'> ";
  32.  
  33.  
  34.      echo "<td bgcolor='white' class='tdnavy' width='300px'>\n";     
  35.      echo "<a onClick='updateProject(\"testcontrol\")' href='javascript:void(0)'>";
  36.          echo "$controlrow[shortdescription]</a> ";
  37.          echo " </td> 
  38. <td bgcolor='white' class='tdnavy' >"; echo get_user_info($controlrow[personresponsible],'name'); echo "</td>  
  39. <td bgcolor='white' class='tdnavy'>";echo convert_date($controlrow[duedate],'fromSQL');
  40. echo "</td>
  41. <td bgcolor='white' class='tdnavy'>";
  42. if (convert_date($controlrow[completiondate],'fromSQL')<>'00/00/0000'){
  43. echo convert_date($controlrow[completiondate],'fromSQL');
  44.     }
  45.   else echo '' ;  
  46.     echo "</td>";
  47.     echo "</tr>";
  48.  
  49.  }    
  50.  
  51.  echo "</table></div></form>";
  52.     echo "<input type='hidden' name='maxcontrolNumber' value='$controlNumber'>  ";
  53.    echo "</tr>";
  54.  
  55.  ?>  
[Please use CODE tags when posting source code. Thanks! --pbmods]

THIS IS THE FORM I WANT TO DISPLAY WHEN I CLICK ON ANY ROW.

Expand|Select|Wrap|Line Numbers
  1. <div id='testcontrolTable' style='position:absolute;
  2.                               top:150px;
  3.                               left:50px;
  4.                               width:1000px;
  5.                               height:550px;
  6.                               z-index:4;
  7.                                                  visibility="hidden"'>
  8.    <form name='testcontrolForm' method='post' onSubmit='return validateField("testcontrol")'> 
  9.   <input type='hidden' name='userNumber'       value='<?php echo $POST_userNumber; ?>'>
  10.   <input type='hidden' name='projectNumber'    value='<?php echo $POST_projectNumber; ?>'> 
  11.    <input type='hidden' name='shortdescription'    value='<?php echo $POST_shortdescription; ?>'> 
  12.   <input type='hidden' name='controlStatus'   value='restore'>
  13.     <table class='projectBar' align='right' width='100%' height='50%'>    
  14.    <tr>
  15.     <th colspan='4' align='center' >
  16.      <h3>Update Test Requirement</h3>
  17.     </th>
  18.    </tr>
  19.    <?php
  20.  
  21.    $controlQuery="SELECT * 
  22.             FROM project_controltest
  23.             WHERE projectNumber='$POST_projectNumber'";
  24.             $result=mysql_query($controlQuery);
  25.             $controlFound=false;
  26.     //        $controlNumber=0;                
  27.         while ($controlrow = mysql_fetch_array($result)) {
  28.                         $controlFound=true;
  29.     //                $controlNumber=$controlNumber+1;
  30.     $shortdesc=$controlrow[shortdescription];
  31.       }
  32.    }
  33.    ?>
  34.    <tr>
  35.    <th>     Short Description:
  36.     </th>
  37.    <td>
  38.     <input readonly type='text' 
  39.            size='50' 
  40.            name='shortdescription' 
  41.            value='<?php echo $shortdesc ?>' 
  42.            maxlength='50'></input>
  43.  </td>
  44.  
  45.    </tr>       
  46.    <tr>
  47.          <th>Functionality to be Tested:</th>
  48.       <td>
  49.     <textarea wrap='soft' rows='5' cols='52' name='funcText' value=''></textarea>
  50.     </td>
  51.     <th> Testing Result:</th> 
  52.     <td>
  53.     <textarea wrap='soft' rows='5' cols='52' name='testresult' value=''></textarea>
  54.     </td>
  55.    </tr>
  56.    <tr>
  57.      <td align='right'>
  58.      Due Date:
  59.     </td>
  60.     <td >
  61.  <input name='DueDate' 
  62.              type='text' 
  63.              size='15' 
  64.              onBlur='chkDateFld(this,"DueDate",true,true)' 
  65.              value=''>
  66.          <a href="javascript:showCal('Calendar15')">
  67.  <img border='0' src='/images/b_calendar.png'
  68.          alt='Get Date'>
  69.         </a>
  70.     </td>    
  71.     <td> Completion Date:</td>
  72.     <td>
  73.     <input name='CompletionDate' 
  74.              type='text' 
  75.              size='15' 
  76.              onBlur='chkDateFld(this,"CompletionDate",true,true)' 
  77.              value=''>
  78.          <a href="javascript:showCal('Calendar16')">
  79.  <img border='0' src='/images/b_calendar.png'
  80.          alt='Get Date'>
  81.         </a></td>    
  82.  </tr>        
  83.     <tr>           
  84.   <td align='right' >
  85.    Person Responsible:
  86.       </td><td>     
  87.       <input readonly type='text'
  88.               size='25'  
  89.              name='personresponsible' 
  90.          maxlength='25'
  91.          value=''></input>
  92.       </td>
  93.       <td>     Completed By:
  94.     </td>
  95.    <td>
  96.     <input  type='text' 
  97.            size='25' 
  98.            name='completedby' 
  99.            value='' 
  100.            maxlength='25'></input>
  101.  </td>
  102.      </tr> 
  103.      </tr> 
  104.  
  105.    <tr>
  106.  
  107.     <th colspan='4' align='center'>
  108.     <input  type='submit' value='Submit' class='fancyButton' >
  109.      <input   type='button' value='Cancel' class='fancyButton' onClick='closeControl("close")'>
  110.                 </th>
  111.             </tr>
  112.         </table>
  113.     </form>
  114. </div>
Jun 13 '07 #3
Purple
404 Expert 256MB
Hi,

I am having difficulty with readability of your code in the post - if you use code tags the code will be formatted with line numbers - makes it much easier to talk about..

Anyhow the logic for the select in the table

select records to be displayed including a key field
Loop the fetch2
[PHP]echo "<tr><td><input type = 'submit' name = '".$keyfield."' value = 'select'></input></td>more detail for the record in detail tags</tr>";[/PHP]
end loop

when the form is processed the $_POST array will have an element with a name of the record key and a value of select.

if you copy and array_flip($_POST) you then have the record key = $new_array['select']

Hows that ?

Purple
Jun 13 '07 #4
i am not really understand how exactly to do this, but i can try and let you know
I am still not clear, but i can play with this
Jun 13 '07 #5
Purple
404 Expert 256MB
Hi dkate777

Apologies if my answer was not clear.

Which bit are you having a problem understanding ?

Ask for clarification and we can assist further.

Regards Purple
Jun 13 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: webhigh | last post by:
Iım not sure if this a PHP question or an MySQL question but here it goes. I have a repeat region of a table called userid What Iım trying to accomplish is being able to edit the record and...
5
by: mm nn | last post by:
Hi, I want to create a table like this: ID Autonum Datefld Date Cat Text Itm Text tCount Number
4
by: Rich | last post by:
Hello, I have a master and detail table in sql server. Say the master has 10 rows and detail has 45 rows. I fill 2 tables in my dataset in the client app. When I iterate through the master...
3
by: inquisitivemind | last post by:
what I actually want is there should be 2 links at tha top of the page Hide and show. Default should be hide. on clicking it the titled data should not show details and on clicking show, the...
7
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
1
by: Steven | last post by:
Hi, I would need some help here: I have two tables, Patient (parent table) and Service (detail table). Composite primary key for parent table is (fname, lname, pid), while composite primary...
4
by: svgeorge | last post by:
I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) -------------------------------------------------------------------------------- How TO COLLECT THE ROWS...
0
by: howkoss | last post by:
Hi, I've been very frustrated for 2 days trying to make this work. I started with a built-in template "Projects" that came with Access 2007. On the "Employee List" I can click on any cell and bring...
1
by: ramaswamynanda | last post by:
Hello, I have a simple vb.net 2005 application using an SQLserver database There is a form , employees that has a grid view and a detail view control The grid displays data and has a "Select"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.