Unable to display the html table size equally - html

I am able to float the two tables, one is on the left side and one is on the right side. However, the table size on the left is not symmetrical to the table on the right. I am unable to display the table size equally. What should i do to display the table side by side equally?
html
html file
<div class="floatleft">
<div class="left">
<div class="row">
<div class="col-md-3">
<%
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver");
String connURL = "jdbc:mysql://localhost/test?user=1234&password=1234";
conn = DriverManager.getConnection(connURL);
String sql = "select * from test";
PreparedStatement pstmt=conn.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
%>
</div>
</div>
<div>
<p<u>Arm</u></a></font></p>
<table>
<tr>
<th >Arm Exercises</th>
<th >Number of times</th>
<th colspan='1'> </th>
<%
String sql1="";
{
sql1 = "select * from test";
PreparedStatement pstmt1=conn.prepareStatement(sql1);
ResultSet rs1 = pstmt1.executeQuery();
while(rs1.next()){
String id = rs1.getString("ID");
out.println("<tr>");
out.println("<td style = 'width: 85%'>");
out.println(arm);
out.println("</td>");
%>
<td>
<textarea cols="2"></textarea>
</td>
<%
out.println("</tr>");
}
conn.close();
}
%>
</table><br>
</div>

Just put the table in the div element with a class name.
<div class="floatleft">
<table>
</table>
<div class="floatright">
<table>
</table>

Related

How to get checkboxes values for JSP page?

I can get a single value for an item in jsp page by id. But I can't able to get checkboxes value. How can I get checkboxes value by id or anything else. when i will click in order page it will collect all products name and product price
Screenshot
Code is:
<table class="table table-hover table-striped">
<thead>
<tr>
<th>ID</th>
<th>Choose Product</th>
<th>Product Name</th>
<th>Product Price</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<%
String Host = "jdbc:mysql://localhost:3306/shopbilling";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(Host, "root", "");
statement = connection.createStatement();
String query = request.getParameter("q");
String data;
if(query != null)
{
data = "select * from products_tbl where product_name like '%"+query+"%' or product_price like '%"+query+"%'";
}
else
{
data = "select * from products_tbl";
}
rs = statement.executeQuery(data);
while (rs.next()) {
%>
<tr>
<td><%=rs.getString("id")%></td>
<td> <input type="checkbox" /> </td>
<td><%=rs.getString("product_name")%></td>
<td><%=rs.getString("product_price")%></td>
<td class="text-center" width="250">
Edit
Delete
</td>
</tr>
<%
}
%>
</tbody>
</table>
Order
Here you can use value tag of <input type="checkbox"> to put the data to user.Then you need to give a attribute 'name' to all of these check-boxes, which you can keep same and then you can grab all the selected values as an array.
Here is a changes you need to make in this code::
<table class="table table-hover table-striped">
<thead>
<tr>
<th>ID</th>
<th>Choose Product</th>
<th>Product Name</th>
<th>Product Price</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<%
String Host = "jdbc:mysql://localhost:3306/shopbilling";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(Host, "root", "");
statement = connection.createStatement();
String query = request.getParameter("q");
String data;
if(query != null)
{
data = "select * from products_tbl where product_name like '%"+query+"%' or product_price like '%"+query+"%'";
}
else
{
data = "select * from products_tbl";
}
rs = statement.executeQuery(data);
while (rs.next()) {
%>
<tr>
<td><%=rs.getString("id")%></td>
<td> <input type="checkbox" name="products" value ="<%=rs.getString("id")%>" /> </td>
<td><%=rs.getString("product_name")%></td>
<td><%=rs.getString("product_price")%></td>
<td class="text-center" width="250">
Edit
Delete
</td>
</tr>
<%
}
%>
</tbody>
</table>
Order
And while receiving the result you need to use something like this::
<%
String products[] = request.getParameterValues("products");
if (products!= null && products.length != 0) {
out.println("You have selected: ");
for (int i = 0; i < products.length; i++) {
out.println(products[i]);
}
}
%>
Hope this helped you!!
Happy Coding:)

Razor - two forms within one html table

Is it possible to combine these two html tables into one table instead?
I can't seems to do it no matter how, it either tell me no start tag or no close tag for the table.
Goals:
1) One <table> with two <tr> and each <tr> has two <td>.
2) Top download button (from top form) in top <tr>.
3) Bottom download button (from bottom form) in bottom <tr>.
<table>
<tr>
<td></td>
<td>
#using (Html.BeginForm("GenerateExcelReport", "Pages", FormMethod.Post, new { name = "formExcel", id = "formExcel" }))
{
#Html.DevExpress().Button(button =>
{
button.ClientSideEvents.Click = "OnClick";
button.Name = "buttonExcel";
button.Text = Resources.Global.buttonExportExcelExtra;
button.UseSubmitBehavior = true;
}).GetHtml()
}
</td>
</tr>
</table>
#using (Html.BeginForm("DownloadMainReport", "Pages", FormMethod.Post))
{
<table>
<tr>
<td style="padding:2px;">
#Html.DevExpress().ComboBox(settings =>
{
settings.Name = "ExportMode";
settings.Properties.Caption = Resources.Global.labelExportMode;// "Details Export Mode ";
settings.Properties.ValueType = typeof(GridViewDetailExportMode);
settings.SelectedIndex = 0;
}).BindList(Enum.GetValues(typeof(GridViewDetailExportMode))).Bind(GridViewDetailExportMode.None).GetHtml()
</td>
<td style="padding:2px;">
#Html.DevExpress().Button(settings =>
{
settings.Name = "buttonExportExcel";
settings.Text = Resources.Global.buttonExportExcel;
settings.UseSubmitBehavior = true;
}).GetHtml()
</td>
</tr>
</table>
#Html.Partial("HomeReportPartial", Model)
}
Even if I use div, it will tell me it cannot find matching tag.
<div class="container-fluid">
<div class="row">
<div class="col-md-1">1</div>
<div class="col-md-1">
#using (Html.BeginForm("test0", "test0", FormMethod.Post))
{ }
</div>
<div class="col-md-10">3</div>
</div>
#using (Html.BeginForm("test1", "test1", FormMethod.Post))
{
<div class="row">
<div class="col-md-1">1</div>
<div class="col-md-1">2</div>
<div class="col-md-10">3</div>
</div>
</div>
}
Parser Error Message: Encountered end tag "div" with no matching start tag. Are your start/end tags properly balanced?

Export to Word from ASP

i am working in an old application developed using classic ASP and VB, i am trying to export an HTML table from an asp page to word, i searched the internet for this and i found a good code that its working perfectly, he problem is that it export the whole page to word, i need to export only a part of the page which is the <table></table>
<%# Language=VBScript %>
<%
Option Explicit
Response.Buffer = TRUE
Response.ContentType = "application/vnd.ms-word"
Response.AddHeader "Content-Disposition", "attachment; filename = MyDoc.doc"
%>
<html>
<head>
</head>
<body>
<%
Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("shotdev/mydatabase.mdb"),"" , ""
strSQL = "SELECT * FROM customer "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
%>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<%
While Not objRec.EOF
%>
<tr>
<td><div align="center"><%=objRec.Fields("CustomerID").Value%></div></td>
<td><%=objRec.Fields("Name").Value%></td>
<td><%=objRec.Fields("Email").Value%></td>
<td><div align="center"><%=objRec.Fields("CountryCode").Value%></div></td>
<td align="right"><%=objRec.Fields("Budget").Value%></td>
<td align="right"><%=objRec.Fields("Used").Value%></td>
</tr>
<%
objRec.MoveNext
Wend
%>
</table>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
</body>
</html>
you can check the link here
can you please help me to solve this issue
thank you

Fetch Multiple Records from Mysql Database Using Where Clause

Im using a web application ,which runs on Apache Tomcat and has Mysql Database as backend
I want to retrieve multiple rows for a particular column usin the Where clause
For Example If I give select * from xyz where type=abc
I should get all the rows having type abc.
Problem:
I use the JDBC connection to achieve this, however Only the 1st row matching the where condition is returned rather than all the rows (even though multiple rows match the criteria in database)
Kindly help me resolve this
Code:
<%# page import="java.sql.*" %>
<html>
<head><link href="style.css" rel ="stylesheet" type="text/css"></head>
<body bgcolor="white" >
<div id="container">
<div id="header">
<img src="logo.jpg">
<div class ="horiztext"><p> Order Tracker</p></div>
</div>
</div>
<br>
<img src="banner.jpg" width="1500 " height="5"><br>
<% if(session.getAttribute("username") !=null)
{
%>
<div id="navbar">
<ul>
<li>New Order</li>
<li>Update Order</li>
<li>Track Order</li>
<li>Track Delay</li>
<li>View Database</li>
<li>Delete Order</li>
<li>Logout</li>
</ul>
</div>
<br>
<br>
<form>
<TABLE cellpadding="15" border="1" style="background-color: #ffffcc;">
<%
String ProductNamez=request.getParameter("ProductName");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3307
/test","root", "root");
Statement st=conn.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM inventory WHERE ProductName = '"+
ProductNamez +"' ");
if(rs.next()){
%>
<tr>
<tr><th>Serial No</th>
<th>Product Name</th>
<th>Product Type</th>
<th>Model</th>
<th>Make</th>
<th>License / Voucher</th>
<th>Location</th>
</tr>
<tr>
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><%=rs.getString(6)%></td>
<td><%=rs.getString(7)%></td>
</tr>
<%
}
%>
</table>
</form>
<%
}
else { %>
you are not logged in click here to <b>login</b>
<%
} %>
</body>
</html>
You'll be wanting
while (rs.next()){
instead of
if (rs.next()){
It's because you just do a if(rs.next()){ so only the first row is shown.
You should do this instead
while (rs.next()) {
[...]
}

html image not displaying

I have to get the images from the database (oracle 10g) and display them, but I am unable to display the images. My code is:
<%
String[] salespersons;
String[] name;
String[] photoid;
String tempid="", tempname="", tempphoto="";
ResultSet rs = statement.executeQuery("select * from Employees where ManagerID=" + managerid);
while(rs.next()) {
tempid += rs.getInt("id") + ";";
tempname += rs.getString("firstname") + ";";
tempphoto += rs.getString("photoid") + ";";
}
salespersons = tempid.split(";");
name = tempname.split(";");
photoid = tempphoto.split(";");
%>
<input type="button" value="CLOSE" onclick="window.close()" />
<table border="5" cellpadding="2" align="center">
<%
for(int ite=0; ite < name.length; ite++) {
%>
<tr>
<td><%=salespersons[ite]%></td>
<td><%=name[ite]%></td>
<td><img src="<%=photoid[ite]%>" alt="image not available"/></td>
<td></td>
<%
}
%>
</tr>
</table>
Image has a wrong path than only image not showing first print image path and then put it as a image url...