Solved

URGENT-Use table ???

Posted on 2003-11-26
21
293 Views
Last Modified: 2010-04-09
hi,
I have a table like this:

<table>
<tr>
<td ><img src=<%=rs.getString("path")%>> </td>
<td>&nbsp;&nbsp;</td>
<td><%= rs.getString( "updates1") %></td>
----------------->i need it to go to next line
<td><%= rs.getString( "updates2") %></td>
  ----> i need some space here ????  
<td ><img src=<%=rs.getString("path")%>> </td>
<td>&nbsp;&nbsp;</td>
<td><%= rs.getString( "updates1") %></td>
----------------->i need it to go to next line

<td><%= rs.getString( "updates2") %></td>
</tr>


<tr>
<td ><img src=<%=rs.getString("path")%>> </td>
<td>&nbsp;&nbsp;</td>
<td><%= rs.getString( "updates1") %></td>
----------------->i need it to go to next line

<td><%= rs.getString( "updates2") %></td>
 ----> i need some space here ????  


     
<td ><img src=<%=rs.getString("path")%>> </td>
<td>&nbsp;&nbsp;</td>
<td><%= rs.getString( "updates1") %></td>
----------------->i need it to go to next line

<td><%= rs.getString( "updates2") %></td>
</tr>
</table>

My problem is do i use a table or not , i mean first of all, how do i do the changes .If i don't use table for it , what do i use?
I need something like this:

     Path1    updates1           Path2     updates1    
                 updates2                        updates2

     Path3    updates1           Path4      updates1
                 updates2                         updates2


and not like this:

 Path1updates1updates2 Path2updates1updates2                      

 Path3 updates1updates2Path4updates1updates2
                                         



Pls help
Thansk

     
0
Comment
Question by:Jasbir21
  • 7
  • 7
  • 3
  • +2
21 Comments
 
LVL 8

Expert Comment

by:xabi
ID: 9823265
Why don't you put "updates1" and "updates2" in a table like this?:

<table>
<tr>
  <td ><img src=<%=rs.getString("path")%>> </td>
  <td>&nbsp;&nbsp;</td>
  <td>
    <table border=0 cellspacing=0 cellpadding=0>
      </tr><td><%= rs.getString( "updates1") %></td></tr>
      </tr><td><%= rs.getString( "updates2") %></td></tr>
    </table>
   </td>

..............

xabi
0
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9823290
Hi Jasbir21,
You can do it with a conbination of table rows (<tr> ... </tr>) and empty cells for the spacing (<td> .. </td>).
See:
<table>
<tr><td>Path1</td><td>updates1</td><td>Path2</td><td>updates1</td></tr>    
<tr><td>     </td><td>updates2</td><td>     </td><td>updates2</td></tr>
<tr></tr>
<tr><td>Path3</td><td>updates1</td><td>Path4</td><td>updates1</td></tr>
<tr><td>     </td><td>updates2</td><td>     </td><td>updates2</td></tr>
</table>

I've laid it out more or less visually here, the spaces are not necessary, but show you empty cells. The actual alignment ( line breaks, spaces etc.) in the HTML will of couse be totally ignored by the browser, it responding only to the markup.
I have of course not used the actual data values, those are up to you.

Cheers!.. Alan
0
 
LVL 8

Expert Comment

by:xabi
ID: 9823358
Or you can use rowspan this way:

<table>
  <tr>
    <td rowspan="2" valign="top"><img src=<%=rs.getString("path")%>></td>
    <td><%= rs.getString( "updates1") %></td>
    <td rowspan="2" valign="top"><img src=<%=rs.getString("path")%>></td>
    <td><%= rs.getString( "updates1") %></td>
  </tr>
  <tr>
    <td><%= rs.getString( "updates2") %></td>
    <td><%= rs.getString( "updates2") %></td>
  </tr>
  <tr>
    <td rowspan="2" valign="top"><img src=<%=rs.getString("path")%>></td>
    <td><%= rs.getString( "updates1") %></td>
    <td rowspan="2" valign="top"><img src=<%=rs.getString("path")%>></td>
    <td><%= rs.getString( "updates1") %></td>
  </tr>
  <tr>
    <td><%= rs.getString( "updates2") %></td>
    <td><%= rs.getString( "updates2") %></td>
  </tr>
</table>

xabi
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:xabi
ID: 9823378
Please Forget my last comment ... :) . If you want to use rowspan you must use Temp Variables to store "updates2". this way:

<% Dim updates2Tmp %>

<table>
  <tr>
    <td rowspan="2" valign="top"><img src=<%=rs.getString("path")%>></td>
    <td><%= rs.getString( "updates1") %></td>
<% updates2Tmp = rs.getString( "updates2") %>
    <td rowspan="2" valign="top"><img src=<%=rs.getString("path")%>></td>
    <td><%= rs.getString( "updates1") %></td>
  </tr>
  <tr>
    <td><%= updates2Tmp %></td>
    <td><%= rs.getString( "updates2") %></td>
  </tr>
  <tr>
    <td rowspan="2" valign="top"><img src=<%=rs.getString("path")%>></td>
    <td><%= rs.getString( "updates1") %></td>
<% updates2Tmp = rs.getString( "updates2") %>    
    <td rowspan="2" valign="top"><img src=<%=rs.getString("path")%>></td>
    <td><%= rs.getString( "updates1") %></td>
  </tr>
  <tr>
    <td><%= updates2Tmp %></td>
    <td><%= rs.getString( "updates2") %></td>
  </tr>
</table>

xabi
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9824301
I think you're over-complicating things here - the original code from the poster was almost correct - it just needs to be simplified:

<table border="0" cellspacing="0" cellpadding="4">
  <tr>
    <td valign="top">Path 1</td>
    <td>Updates1<br>Updates2</td>
    <td nowrap width="30">&nbsp;</td>
    <td valign="top">Path 2</td>
    <td>Updates1<br>Updates2</td>
  </tr>
  <tr>
    <td valign="top">Path 3</td>
    <td>Updates1<br>Updates2</td>
    <td>&nbsp;</td>
    <td valign="top">Path 4</td>
    <td>Updates1<br>Updates2</td>
  </tr>
</table>
0
 
LVL 35

Expert Comment

by:YZlat
ID: 9824958
you need to add more table rows:

<table>
<tr>
<td ><img src=<%=rs.getString("path")%>> </td>
<td>&nbsp;&nbsp;</td>
<td><%= rs.getString( "updates1") %></td>
</tr>
<tr>
<td><%= rs.getString( "updates2") %></td>

<td style="width:40">&nbsp;&nbsp;</td>

<td ><img src=<%=rs.getString("path")%>> </td>
<td>&nbsp;&nbsp;</td>
<td><%= rs.getString( "updates1") %></td>
</tr>
<tr>

<td><%= rs.getString( "updates2") %></td>
</tr>


<tr>
<td ><img src=<%=rs.getString("path")%>> </td>
<td>&nbsp;&nbsp;</td>
<td><%= rs.getString( "updates1") %></td>
</tr>
<tr>

<td><%= rs.getString( "updates2") %></td>
<td style="width:40">&nbsp;&nbsp;</td>


     
<td ><img src=<%=rs.getString("path")%>> </td>
<td>&nbsp;&nbsp;</td>
<td><%= rs.getString( "updates1") %></td>
</tr>
<tr>
<td><%= rs.getString( "updates2") %></td>
</tr>
</table>

0
 
LVL 35

Expert Comment

by:YZlat
ID: 9824963
and whenever you need a space, you can put an empty cell there:

<td style="width:40"> </td>
0
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9824982
Hi YZlat,
You don't actually have to specify the width of an empty cell, it will default to the width of the corresponding cells in other rows.

.. Alan
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9825011
Still unnecessarily complicated...
0
 

Author Comment

by:Jasbir21
ID: 9825525
hi,
  I forgot to meantion something, i mean when i mean the value like this:
     
     Path1    updates1           Path2     updates1    
                 updates2                        updates2

     Path3    updates1           Path4      updates1
                 updates2                         updates2


Lets say i delete value of path1

      Path2     updates1  
                   updates2
                     

     Path3    updates1           Path4      updates1
                 updates2                         updates2


How do i do it so that it stays in four corner like that and not change when delete happen. I hope i am not confusing, what i mean i need in four corner even when delete happen example:
                                            Path2     updates1  
                                                          updates2
                     

     Path3    updates1           Path4      updates1
                 updates2                         updates2




Pls help, i really need it very urgent
Thansk




0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9825683
As per my example above, nothing changes when you delete the info:

<table border="0" cellspacing="0" cellpadding="4">
  <tr>
    <td valign="top">&nbsp;</td>
    <td>&nbsp;</td>
    <td nowrap width="30">&nbsp;</td>
    <td valign="top">Path 2</td>
    <td>Updates1<br>Updates2</td>
  </tr>
  <tr>
    <td valign="top">Path 3</td>
    <td>Updates1<br>Updates2</td>
    <td>&nbsp;</td>
    <td valign="top">Path 4</td>
    <td>Updates1<br>Updates2</td>
  </tr>
</table>
0
 

Author Comment

by:Jasbir21
ID: 9830362
i think  i understand now, my problem is the table is put in a while loop of an if statement.

For example:
<table border="0" cellspacing="0" cellpadding="4">
<tr>
if(condition A is met){

 <td valign="top">Path 1</td>
 <td>Updates1<br>Updates2</td>
}

(if condition B is met){

 <td nowrap width="30">&nbsp;</td>
    <td valign="top">Path 2</td>
    <td>Updates1<br>Updates2</td>
}
</tr>

(if condition C is met){

    <td valign="top">Path 3</td>
    <td>Updates1<br>Updates2</td>
    <td>&nbsp;</td>

}

(if condition D is met){
<td valign="top">Path 4</td>
    <td>Updates1<br>Updates2</td>

}
  </tr>
</table>

I think that's why the position mov because if the condition is notmet the loop is not entered.
I mean how to do if condition not met put empty space, so that data in table is empty , i mean position stay .

Sorry for me confusing,
Thanks
0
 
LVL 31

Accepted Solution

by:
seanpowell earned 250 total points
ID: 9830694
There may be an easier way to do this, but it's hard to judge without seeing the entire code:

<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
    if(condition A is met){
    <table border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td valign="top"><img src=<%=rs.getString("path")%>></td>
        <td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates1") %></td>
      </tr>
    </table>
    }
    </td>
    <td valign="top">if(condition B is met){
    <table border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td valign="top"><img src=<%=rs.getString("path")%>></td>
        <td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates1") %></td>
      </tr>
    </table>
    }
    </td>
  </tr>
  <tr>
    <td valign="top">if(condition C is met){
    <table border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td valign="top"><img src=<%=rs.getString("path")%>></td>
        <td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates1") %></td>
      </tr>
    </table>
    }
    </td>
    <td valign="top">if(condition D is met){
    <table border="0" cellspacing="0" cellpadding="4">
      <tr>
        <td valign="top"><img src=<%=rs.getString("path")%>></td>
        <td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates1") %></td>
      </tr>
    </table>
    }
    </td>
  </tr>
</table>


Note: If you're using any borders with your table, you may want to use the IF THEN ELSE format, depending again on your code and scripting choices:

<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
    If rs_somefield("Path").Value = "Some Value" Then
    Response.Write("<table border=""0"" cellspacing=""0"" cellpadding=""4"">")
    Response.Write("<tr>")
    Response.Write("<td valign="top"><img src=<%=rs.getString("path")%>></td>")
    Response.Write("<td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates1") %></td>")
    Response.Write("</tr>")
    Response.Write("</table>")
    }
    Else
    Response.Write("&nbsp;")
    </td>

    etc.


This just makes sure that the table cell that holds the conidtional statement has a non-breaking space character inside, in case the condition evaluates to false. Some browsers will not render the table correctly if the cell has no content...
0
 

Author Comment

by:Jasbir21
ID: 9830967
hi,
I am posting the code,pls see and help me and very sorry for confusing evreything:

<form action="menu.jsp" name="form1">

   <%

       //** quering database..
           query="select * from picture where position='upperleft'";
           rs=statement.executeQuery(query);

           }

   catch( SQLException ex ) { ex.printStackTrace() ; }
   catch( ClassNotFoundException ex ) {ex.printStackTrace() ;}

%>
 <table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">



<%

   if(rs.next()){

  %>
<table border="0" cellspacing="0" cellpadding="4">
<tr>  
 
  <%
    do

       {
  %>


<td valign="top"><img src=<%=rs.getString("path")%>></td>
 
  <td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates2") %><br><a target='mypopup' href='di.jsp?id=<%=rs.getString( "username") %>'>Click for more info</a></td>

 


  <%
         } while( rs.next() ) ;

%>
</tr>
 </table>
 

<%
     }

%>
 
</td>
    <td valign="top">



   <%
    statement.close();
    statement=null;
    rs.close();
    rs=null;
    query="";
       
   %>


 
  <%
   statement=connection.createStatement();

   query="select * from picture where position='upperright'";
   rs=statement.executeQuery(query);


  if(rs.next()){
 
%>
 <table border="0" cellspacing="0" cellpadding="4">
      <tr>
       
     
<%
     do

         {

 %>

     <td   valign="top"><img src=<%=rs.getString("path")%>></td>
 
       <td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates2") %><br><a target='mypopup' href='di.jsp?id=<%=rs.getString( "username") %>'>Click for more info</a></td>

   


 <%
         } while( rs.next() ) ;


%>
</tr>
    </table>

<%
     }

 %>

 </td>
  </tr>
  <tr>
    <td valign="top">


 <%
    statement.close();
    statement=null;
    rs.close();
    rs=null;
    query="";
       
   %>
 
  <%
   statement=connection.createStatement();


 query="select * from picture where position='lowerleft'";
 rs=statement.executeQuery(query);



 if(rs.next()){
%>

 <table border="0" cellspacing="0" cellpadding="4">
      <tr>

<%

  do

         {

 %>
 


     <td valign="top"><img src=<%=rs.getString("path")%>> </td>
     
     <td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates2") %><br><a target='mypopup' href='di.jsp?id=<%=rs.getString( "username") %>'>Click for more info</a></td>


<%
         } while( rs.next() ) ;

%>

   </tr>
    </table>



<%
     }

 %>
</td>
    <td valign="top">
 <%
    statement.close();
    statement=null;
    rs.close();
    rs=null;
    query="";
       
   %>
 

 <%


 statement=connection.createStatement();

 query="select * from picture where position='lowerright'";
 rs=statement.executeQuery(query);



 if(rs.next()){

%>
<table border="0" cellspacing="0" cellpadding="4">
      <tr>
<%

 do

         {

 %>

     

     <td valign="top" ><img src=<%=rs.getString("path")%>> </td>
     <td><%= rs.getString( "updates1") %><br><%= rs.getString( "updates2") %><br>
<a target='mypopup' href='di.jsp?id=<%=rs.getString( "username") %>'>Click for more info</a></td>  
   

 <%
         } while( rs.next() ) ;

%>
</tr>
    </table>

<%
     }


 %>



<%
    statement.close();
    statement=null;
    rs.close();
    rs=null;
    query="";

 %>
</td>
  </tr>
</table>



 </p>


<table border="0">
<tr>
<td>
<label for="position">
 Location:</label>
 <select name="position">
 <option value='upperleft'>Upperleft</option>
 <option value='upperright'>Upperright</option>
 <option value='lowerleft'>Lowerleft</option>
 <option value='lowerright'>Lowerright</option>
 </select>
</td>
<td>&nbsp;</td>
 
<td><input type=button value="Add" onclick="Add(this.form)" ></td>
<td>&nbsp;</td>
 
<td><input type=button value="Update" onclick="Update(this.form)" ></td>
<td>&nbsp;</td>
 
<td> <input type=button value="Delete" onclick="Delete(this.form)"></td>

  </form>
   
   %>

</body>
</html>


this is part of the code:, i cut some because the code is very very long.It work like this, a user would select location-upperleft,uperright and etc, add button to add
info. the info could be added to 4 places-upperleft,upperigt, loweright and lowerleft

Pls help , i need this very urgently, thanks
0
 

Author Comment

by:Jasbir21
ID: 9837002
...I still don't know why i not geting empty space, i did put the code in if...while
did i do something..Pls see, i need very urgent
thanks

0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9837950
It's difficult to tell without seeing the code working - but you need to basically have:

If (the table should be displayed) then print it

else response.write ("&nbsp;")

Something like:

    <td valign="top">
    <%
    if(rs.next()){
    %>
    <table border="1" cellspacing="0" cellpadding="4">
      <tr>  
      <%
      do
      {
      %>
        <td valign="top"><img src=<%=rs.getString("path")%>></td>
        <td><%= rs.getString( "updates1") %><br>
        <%= rs.getString( "updates2") %><br>
        <a target='mypopup' href='di.jsp?id=<%=rs.getString( "username") %>'>Click for more info</a></td>
      <%
      } while( rs.next() ) ;
      %>
      </tr>
    </table>
    <%
    else response.write ("&nbsp;")
    }
    %>
    </td>
0
 

Author Comment

by:Jasbir21
ID: 9838141
hi,
 
 I don't know why i got error, cannot resolve symbol of write.


Thanks
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9838212
Do you mean this:

Response.Write "&nbsp;"

is not being displayed? Then there's a syntax error, but there's too much of your code missing to determine what it is...


0
 

Author Comment

by:Jasbir21
ID: 9842184
oh, sorry,pls give me a bit more time ,very sorry for taking very long time,

thanks
0
 

Author Comment

by:Jasbir21
ID: 9842296
thanks for the help..
0
 
LVL 31

Expert Comment

by:seanpowell
ID: 9842307
I'm glad it's working for you - and thanks :-)
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Mouse event to control image and transparency. 4 36
Call a function within the ASP code 4 19
Html Table looping 4 26
Word, Excel, Access icons 4 17
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question