URGENT-Use table ???

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

     
Jasbir21Asked:
Who is Participating?
 
seanpowellConnect With a Mentor Commented:
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
 
xabiCommented:
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
 
ADSaundersCommented:
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
xabiCommented:
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
 
xabiCommented:
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
 
seanpowellCommented:
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
 
YZlatCommented:
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
 
YZlatCommented:
and whenever you need a space, you can put an empty cell there:

<td style="width:40"> </td>
0
 
ADSaundersCommented:
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
 
seanpowellCommented:
Still unnecessarily complicated...
0
 
Jasbir21Author Commented:
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
 
seanpowellCommented:
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
 
Jasbir21Author Commented:
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
 
Jasbir21Author Commented:
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
 
Jasbir21Author Commented:
...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
 
seanpowellCommented:
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
 
Jasbir21Author Commented:
hi,
 
 I don't know why i got error, cannot resolve symbol of write.


Thanks
0
 
seanpowellCommented:
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
 
Jasbir21Author Commented:
oh, sorry,pls give me a bit more time ,very sorry for taking very long time,

thanks
0
 
Jasbir21Author Commented:
thanks for the help..
0
 
seanpowellCommented:
I'm glad it's working for you - and thanks :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.