I am not sure how to fix the following error:
Microsoft VBScript compilation error '800a03f6'
Expected 'End'
/junk/test.asp, line 103
else
^
Relevant code:
<%
con.MoveNext()
Wend
%>
</table>
<% else %>
<p>No seminars available.</p>
<%
end if
con.close
%>
Whole code:
<%# LANGUAGE="VBSCRIPT" %>
<%
Dim connectString, connect, conDB, con, src_st
connectString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=" & Server.MapPath("data")
src_st = Request.QueryString("state")
set connect = Server.CreateObject("ADODB.connection")
connect.open connectString
if src_cat = "" then
conDB = "SELECT * FROM travel.csv"
else
conDB = "SELECT * FROM travel.csv where state = ' & src_st & '"
set con = connect.execute(conDB)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Seminars & workshops - AvSafety Seminars</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" media="screen" href="/style/screen.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/style/avsafety.css" />
<link rel="stylesheet" type="text/css" media="handheld" href="/style/handheld.css" />
<link rel="stylesheet" type="text/css" media="print" href="/style/print.css" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<style type="text/css">
<!--
.style2 {color: #666666 }
-->
</style>
<!--
-->
</head>
<body>
<div id="printtitle">Civil Aviation Safety Authority</div>
<div id="outer_wrapper">
<div id="wrapper">
<div id="container">
<div id="title"><h1> </h1></div>
<img src="images/windsock.jpg" alt="" width="166" height="500" align="right" />
<div id="content">
<!--Start of main content area-->
<div id="right"> <img src="/wcmswr/_assets/main/seminars/images/AVSAFETY-LOGO.GIF" alt="AVSafety logo" border="0" width="250px" height="50px">
</div>
<h1>AvSafety Seminars</h1>
<p>CASA is continuing with the Safety Seminar program, targeting pilots in regional Australia and run in partnership with the local aviation industry. </p>
<p>We also hold seminars targeted at engineers.</p>
<p>View further information on safety issues and topics.</p>
<h2>Request a seminar</h2>
<p> If you would like to request an AvSafety seminar in your local town, use the AvSafety request from.</p>
<h2>2013 Seminar schedule</h2>
<p>In 2013 CASA ASAs will be focusing on visiting organisations to discuss the forthcoming aviation regulatory changes. They will be in all regions of Australia and individuals or organisations are welcome to contact their local region ASA to arrange an appointment time. The approximate travel schedule for each region is shown below. ASAs are available and active each month for visits within capital city environs (approximately within 2 hours driving of a capital city).</p>
<p>Aero clubs and other aviation organisation are welcome to run Aviation Safety Seminars with ASAs presenting topics, however CASA will not be financially supporting the events. If you would like to run a seminar with ASA attendance, please use the AvSafety request from and complete the details of the request. Every effort will be made to provide support however it will be advantageous to consider timings when an ASA is visiting a local region.
</p>
<p>ACT | NSW | QLD | SA | TAS | VIC | WA</p>
<table>
<tr>
<th>Location</th>
<th>State</th>
<th>Date</th>
</tr>
<% while (NOT con.EOF) %>
<tr>
<td><%=con("location")%></td>
<td><%=con("state")%></td>
<td><%=con("date")%></td>
</tr>
<%
con.MoveNext()
Wend
%>
</table>
<% else %>
<p>No seminars available.</p>
<%
end if
con.close
%>
<!--End of main content area-->
</div> <!-- content -->
</div> <!-- container -->
<div id="sidebar">
<h2 id = "sidebarhome">CASA home</h2>
<h2>Seminars & workshops</h2>
<ul>
<li>AvSafety Seminars </li>
<li> Maintenance seminars</li>
<li>Archerfield chief pilots</li>
<li>Competency Based Training Education</li>
<li>Manufacturing & certification workshop</li>
</ul>
<form action="http://agencysearch.australia.gov.au/search/search.cgi" name="agencysearch">
<input type="text" name="query" size="13" maxlength="50" value="" alt="Search field" />
<input type="hidden" name="collection" value="agencies" />
<input type="hidden" name="form" value="simple" />
<input type="hidden" name="profile" value="casa" />
<input type="submit" value="Search" name="Search" alt="Search button" />
</form>
</div>
<div class="clearing"> </div>
</div><!-- wrapper -->
</div> <!-- outer_wrapper -->
<div class="extras">
Contact CASA
</div>
<div class="footer">
Site help |
Copyright | Privacy
</div>
</body>
</html>
what if you change your code to this ?
<%
Dim connectString, connect, conDB, con, src_st
connectString = "Driver={Microsoft Text Driver (*.txt; *.csv)}; DBQ=" & Server.MapPath("data")
src_st = Request.QueryString("state")
set connect = Server.CreateObject("ADODB.connection")
connect.open connectString
if src_cat = "" then
conDB = "SELECT * FROM travel.csv"
else
conDB = "SELECT * FROM travel.csv where state = '" & src_st & "'"
end if
set con = connect.execute(conDB)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Seminars & workshops - AvSafety Seminars</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" media="screen" href="/style/screen.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/style/avsafety.css" />
<link rel="stylesheet" type="text/css" media="handheld" href="/style/handheld.css" />
<link rel="stylesheet" type="text/css" media="print" href="/style/print.css" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<style type="text/css">
<!--
.style2 {color: #666666 }
-->
</style>
<!--
-->
</head>
<body>
<div id="printtitle">Civil Aviation Safety Authority</div>
<div id="outer_wrapper">
<div id="wrapper">
<div id="container">
<div id="title"><h1> </h1></div>
<img src="images/windsock.jpg" alt="" width="166" height="500" align="right" />
<div id="content">
<!--Start of main content area-->
<div id="right"> <img src="/wcmswr/_assets/main/seminars/images/AVSAFETY-LOGO.GIF" alt="AVSafety logo" border="0" width="250px" height="50px">
</div>
<h1>AvSafety Seminars</h1>
<p>CASA is continuing with the Safety Seminar program, targeting pilots in regional Australia and run in partnership with the local aviation industry. </p>
<p>We also hold seminars targeted at engineers.</p>
<p>View further information on safety issues and topics.</p>
<h2>Request a seminar</h2>
<p> If you would like to request an AvSafety seminar in your local town, use the AvSafety request from.</p>
<h2>2013 Seminar schedule</h2>
<p>In 2013 CASA ASAs will be focusing on visiting organisations to discuss the forthcoming aviation regulatory changes. They will be in all regions of Australia and individuals or organisations are welcome to contact their local region ASA to arrange an appointment time. The approximate travel schedule for each region is shown below. ASAs are available and active each month for visits within capital city environs (approximately within 2 hours driving of a capital city).</p>
<p>Aero clubs and other aviation organisation are welcome to run Aviation Safety Seminars with ASAs presenting topics, however CASA will not be financially supporting the events. If you would like to run a seminar with ASA attendance, please use the AvSafety request from and complete the details of the request. Every effort will be made to provide support however it will be advantageous to consider timings when an ASA is visiting a local region.
</p>
<p>ACT | NSW | QLD | SA | TAS | VIC | WA</p>
<table>
<tr>
<th>Location</th>
<th>State</th>
<th>Date</th>
</tr>
<%
if NOT con.eof then
while (NOT con.EOF) %>
<tr>
<td><%=con("location")%></td>
<td><%=con("state")%></td>
<td><%=con("date")%></td>
</tr>
<%
con.MoveNext()
Wend
%>
</table>
<% else %>
<p>No seminars available.</p>
<%
end if
con.close
%>
<!--End of main content area-->
</div> <!-- content -->
</div> <!-- container -->
<div id="sidebar">
<h2 id = "sidebarhome">CASA home</h2>
<h2>Seminars & workshops</h2>
<ul>
<li>AvSafety Seminars </li>
<li> Maintenance seminars</li>
<li>Archerfield chief pilots</li>
<li>Competency Based Training Education</li>
<li>Manufacturing & certification workshop</li>
</ul>
<form action="http://agencysearch.australia.gov.au/search/search.cgi" name="agencysearch">
<input type="text" name="query" size="13" maxlength="50" value="" alt="Search field" />
<input type="hidden" name="collection" value="agencies" />
<input type="hidden" name="form" value="simple" />
<input type="hidden" name="profile" value="casa" />
<input type="submit" value="Search" name="Search" alt="Search button" />
</form>
</div>
<div class="clearing"> </div>
</div><!-- wrapper -->
</div> <!-- outer_wrapper -->
<div class="extras">
Contact CASA
</div>
<div class="footer">
Site help |
Copyright | Privacy
</div>
</body>
</html>
Related
Goal is to modify existing html's content only.
For example, given current markup:
<html lang="en" op="item">
<head>
<meta name="referrer" content="origin">
<title>The Scientific Case for Two Spaces After a Period (2018)</title>
</head>
<body>
<center>
<table class="fatitem" border="0">
<tr class='athing' id='25581282'>
<td class="title">
<a class="titlelink">The Scientific Case for Two Spaces After a Period (2018)</a>
</td>
</tr>
</table>
</center>
</body>
</html>
Suppose, I want to append "™" string to each word which length is 6.
The result expected:
<html lang="en" op="item">
<head>
<meta name="referrer" content="origin">
<title>The Scientific Case for Two Spaces™ After a Period™ (2018)</title>
</head>
<body>
<center>
<table class="fatitem" border="0">
<tr class='athing' id='25581282'>
<td class="title">
<a class="titlelink">The Scientific Case for Two Spaces™ After a Period™ (2018)</a>
</td>
</tr>
</table>
</center>
</body>
</html>
I'm fairly new to python, and having trouble with this. Because of nested contents, I'm struggling with properly accessing the elements and returning expected outcome.
This is what I have tried so far:
soup = BeautifulSoup(markup, 'html.parser')
new_html = []
for tags in soup.contents:
for tag in tags:
if type(tag) != str:
split_tag = re.split(r"(\W+)", str(tag.string))
for word in split_tag:
if len(word) == 6 and word.isalpha():
word += "™"
tag.string = "".join(split_tag)
else:
str_obj.append(tag)
new_html.append(str(tag))
You can use .find_all(text=True) in combination with .replace_with():
import re
from bs4 import BeautifulSoup
html_doc = """
<html lang="en" op="item">
<head>
<meta name="referrer" content="origin">
<title>The Scientific Case for Two Spaces After a Period (2018)</title>
</head>
<body>
<center>
<table class="fatitem" border="0">
<tr class='athing' id='25581282'>
<td class="title">
<a class="titlelink">The Scientific Case for Two Spaces After a Period (2018)</a>
</td>
</tr>
</table>
</center>
</body>
</html>
"""
soup = BeautifulSoup(html_doc, "html.parser")
for s in soup.find_all(text=True):
new_s = re.sub(r"([a-zA-Z]{6,})", r"\1™", s)
s.replace_with(new_s)
print(soup.prettify())
# to have HTML entities:
# print(soup.prettify(formatter="html"))
Prints:
<html lang="en" op="item">
<head>
<meta content="origin" name="referrer"/>
<title>
The Scientific™ Case for Two Spaces™ After a Period™ (2018)
</title>
</head>
<body>
<center>
<table border="0" class="fatitem">
<tr class="athing" id="25581282">
<td class="title">
<a class="titlelink">
The Scientific™ Case for Two Spaces™ After a Period™ (2018)
</a>
</td>
</tr>
</table>
</center>
</body>
</html>
I am trying to pass parameters from my input text control to the called xquery by adding them as parameters in url. I tried doing in may ways - always without success. Could you have a look and tell me what I am doing wrong?
xquery version "3.0";
declare option exist:serialize "method=xhtml media-type=application/xhtml+xml indent=yes";
import module namespace xmldb="http://exist-db.org/xquery/xmldb";
declare variable $collection as xs:string := '/db/junitReports';
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:bf="http://betterform.sourceforge.net/xforms" xmlns:xf="http://www.w3.org/2002/xforms" bf:toaster-position="tl-down">
<head>
<title>IB interfaces regression testing report</title>
<meta name="author" content="test"/>
<meta name="author" content="test"/>
<meta name="description" content="IB interfaces regression testing report"/>
<link rel="stylesheet" type="text/css" href="styles/demo.css"/>
<!-- INPUT CONTROLS -->
<xf:model>
<xf:instance id="default">
<data xmlns="">
<InterfaceName constraint="true" readonly="false" required="false" relevant="true">
</InterfaceName>
<trigger1 constraint="true" readonly="false" required="false" relevant="true">
</trigger1>
</data>
</xf:instance>
<xf:instance id="table" xmlns="">
<data>
</data>
</xf:instance>
<xf:bind nodeset="InterfaceName" type="string">
</xf:bind>
<xf:submission id="showTable"
method="post"
action="{concat('/exist/rest/db/xquery/returnTable.xq?interface=',InterfaceName)}"
replace="instance"
ref="instance('table')"
instance="table">
</xf:submission>
</xf:model>
</head>
<body class="soria" style="margin:30px;">
<div class="Headline">IB test report</div>
<div class="description">
<p>You can restrict report output:</p>
</div>
<p>2. By typing in particular interface name</p>
<div class="Interface">
<xf:input id="InterfaceName" ref="InterfaceName" incremental="false">
<xf:label></xf:label>
<xf:hint>(S|R)xxxxxYYYZZZ</xf:hint>
<xf:help>Enter interface name</xf:help>
<xf:alert>Enter interface name</xf:alert>
</xf:input>
</div>
<br/>
<div>
<xf:trigger id="trigger1" ref="trigger1" incremental="true">
<xf:label>Filter output</xf:label>
<xf:hint>a Hint for this control</xf:hint>
<xf:help>help for trigger1</xf:help>
<xf:action ev:event="DOMActivate">
<xf:send submission="showTable"/>
</xf:action>
</xf:trigger>
</div>
<div>
<table border="1">
<thead>
<tr>
<th>Inteface Name</th>
<th>Test Date</th>
<th>Test Result</th>
<th>Report Link</th>
</tr>
</thead>
<tbody xf:repeat-nodeset="instance('table')//result">
<tr>
<td>
<xf:output ref="interfaceName"></xf:output>
</td>
<td>
<xf:output ref="reportDate"></xf:output>
</td>
<td>
<xf:output ref="testResult"></xf:output>
</td>
<td>
<li>
<xf:output ref="fileLink"></xf:output>
</li>
</td>
</tr>
</tbody>
</table>
</div>
<label>{InterfaceName}</label>
</body>
</html>
My uri remains without parameters:
"resource-uri":"http://localhost:8080/exist/rest/db/xquery/returnTable.xq?interface="
The right way to do it was to replace action attribute with this element in submission:
<xf:resource value="concat('/exist/rest/db/xquery/returnTable.xq?interface=',instance('defaultInstance')//InterfaceName,'&','date=',instance('defaultInstance')//CalendarDate)"/>
I want to embed an XML file into an existing template I have been creating. My website contains a content header, content section, sidebar etc. But I want to embed the XML data into the content section, so that I can use my existing CSS and formatting without rewriting half of it in XSLT. I have already run across the "xml" tag, but I want to import it from an external file rather than inline.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Local fish and chips bar, serving the city for over 20 years.">
<meta name="keywords" content="Food,Drink,Fish,Chips,British">
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<div id="header">
<h1>
<img alt="logo" src="images\logo.jpg" style="width:473px;height:135px">Home</h1>
</div>
<div id = "wrap">
<div id = "navWrap">
<div id = "nav">
<ul>
<li><a class ="nav" href="index.html">Home</a></li>
<li><a class ="nav" href="order.html">Order Online</a></li>
<li><a class ="nav" href="look.html">Look Around</a></li>
<li><a class ="nav" href="contact.html">Contact Us</a></li>
<li><a class ="nav" href="#menu">Download Our Menu</a></li>
<li><a class ="nav" href="#contact">Download Our App</a></li>
<li><a class ="nav" href="report.html">Report</a></li>
</ul>
</div>
</div>
</div>
<div id="main">
<xml Id = msg SRC = "menu.xml"></xml> ----- **XML GOES HERE**
</div>
<div id="sidebar">
<div id = "sidebarMain">
</div>
<div id = "mapWrap">
<iframe src= width="400" height="300" frameborder="0" style="border:0"></iframe>
</div>
<h3><center><u>Opening Times</u></center></h3>
<table style="width:100%">
<tr>
<th>Day</th>
<th>Lunch</th>
<th>Evening</th>
</tr>
<tr>
<td>Monday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Tuesday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Wednesday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Thursday</td>
<td>10:00 - 14:00</td>
<td>16:00 - 22:00</td>
</tr>
<tr>
<td>Friday</td>
<td>10:00 - 14:00</td>
<td>15:00 - 23:00</td>
</tr>
<tr>
<td>Saturday</td>
<td>10:00 - 14:00</td>
<td>15:00 - 23:00</td>
</tr>
<tr>
<td>Sunday</td>
<td>Closed</td>
<td>Closed</td>
</tr>
</table>
</div>
<div id = "footer">
Copyright © FryingNemo.com<br>
<br>
</div>
</body>
</head>
My xml file:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="nemoMenu.xsl"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>Light Belgian waffles covered with strawberries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>Light Belgian waffles covered with an assortment of fresh berries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>Thick slices made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>Two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
<calories>950</calories>
</food>
</breakfast_menu>
Any resolution on the issue would be appreciated, or perhaps I would be better of simply using XSLT.
Neither HTML 4 nor HTML5 has an xml element, only older versions of IE on Windows supported that to embed so called XML data islands inline in HTML. So there is no other way to embed external XML documents in an HTML document other than there is to embed other content, namely the iframe element and the object element. That is as far as static HTML is concerned, of course if you have some server-side programming/processing framework or want to rely on client-side scripting, then there are other options.
I wasn't exactly sure how to word my question, so sorry if the question isn't phrased correctly.
Ill try to give the minimum amount of info needed to help me out. Please let me know edits to make or things to add. Thanks.
So I have a Relational MYSQL database already setup with data in 4 tables. This program is supposed to be a small-scale customer database lookup. I have an HTML page with a form: a text box asking for customer number, and 4 radio buttons to determine what data to retrieve. We're using Ruby on Rails (which I've never used) to access and control the data in the tables.
The 4 radio buttons:
Customer Data
Sales Rep
Orders
Parts
Here's a link to what these table's contain: http://www.cs.uky.edu/~paulp/CS316/tables.txt
The first two radio's were easy to implement since a customerNum is input. For customer data, I set variables to retrieve the values from the customers table. The SalesRep option was also easy. I took the customerNum input, set a variable to be the data in customers and another to be the data in salesreps. I made another variable to be the salesrep id by taking it from customers where customerNum was the input. Then used that sales rep id to display the associated data for the sales rep for that customer.
The 3rd and 4th radio options (orders and parts) has got me stumped! If you look at the orders table, some customerNum's have multiple orders.
My question is essentially "How do I go about displaying all of the orders (and the associated data for each) for a given customer?"
I can't just do what I did for the first 2 radios since each customerNum could have 1 or multiple orders. I'm new to Ruby on Rails and not sure how to go about implementing this.
Ill post some code in a sec. Any suggestions to edits for this post or to help implement this are greatly appreciated. Thanks!
CODE:
index.html.erb
<%
# index.html.erb
# First (input) screen for example
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<link rel="stylesheet" type="text/css" href="style.css">
<title>The Data Access Program</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Spartan Hardware Data Access</h1>
<form action="cs316ruby/result" method="post" >
<h3>Data requested:
<input type="text" name="data" /> </h3>
<ol>
<li><input type="radio" name="field" value="cu" id="field_cu" checked="checked" />
Customer data</li>
<li><input type="radio" name="field" value="sr" id="field_sr" />Sales rep</li>
<li><input type="radio" name="field" value="or" id="field_o" />Orders</li>
<li><input type="radio" name="field" value="p" id="field_p" />Parts</li>
</ol>
<input type="hidden" name=<%= request_forgery_protection_token.to_s %>
value=<%= form_authenticity_token %> />
<input type="submit" value="submit" />
</form>
</body>
</html>
salesrepdisplay.html.erb
<%
# salesrepisplay.html.erb.rb
# View that displays customer's sales rep data for cs316ruby program
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<link rel="stylesheet" type="text/css" href="style.css">
<title>The Data Access Program</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Spartan Hardware Stores Data Access</h1>
<% # get the customer data from the customer table
#custdata = Customer.find(#data)
# copy the Sales rep field into a variable to retrieve sales rep data
# if sales rep id = 00, the entered customer has no sales rep
#sr = #custdata.sales_rep
#srdata = Salesrep.find(#sr)
#ln = #srdata.last_name
#fn = #srdata.first_name
#rt = #srdata.rate
#cm = #srdata.commission;
#cm = sprintf("%7.2f",#cm)
%>
<h1>Sales Rep data for customer: <%=#data %></h1>
<table border=1>
<tr>
<td>ID</td>
<td>Last name</td>
<td>First name</td>
<td>Commission</td>
<td>Rate</td>
</tr>
<tr>
<td><%=#sr%></td>
<td><%=#ln%></td>
<td><%=#fn%></td>
<td><%=#cm%></td>
<td><%=#rt%></td>
</tr>
</table>
</body>
</html>
custdisplay.html.erb
<%
# custdisplay.html.erb.rb
# View that displays customer data for cs316ruby program
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>The Data Access Program</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Spartan Hardware Stores Data Access</h1>
<% # get the customer data from the customer table
#custdata = Customer.find(#data)
# copy each field into a variable for display
#id = #custdata.id
#ln = #custdata.last_name
#fn = #custdata.first_name
#bl = #custdata.balance;
#bl = sprintf("%7.2f",#bl) # format as currency
#cl = #custdata.credit_limit
#cl = sprintf("%7.2f",#cl) # format as currency
#sr = #custdata.sales_rep
%>
<h1>customer data for customer: <%=#data %></h1>
<table border=1>
<tr>
<td>ID</td>
<td>Last name</td>
<td>First name</td>
<td>Balance</td>
<td>Credit limit</td>
<td>Sales rep</td>
</tr>
<tr>
<td><%=#id%></td>
<td><%=#ln%></td>
<td><%=#fn%></td>
<td><%=#bl%></td>
<td><%=#cl%></td>
<td><%=#sr%></td>
</tr>
</table>
</body>
</html>
orderdisplay.html.erb
This is basically a copy and paste of the sales rep and customer order pages to start from
<%
# orderdisplay.html.erb
# View that displays customer's order data for cs316ruby program
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>The Data Access Program</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Spartan Hardware Stores Data Access</h1>
<% # get the customer data from the customer table
#custdata = Customer.find(#data)
%>
<h1>Order data for customer: <%=#data %></h1>
<table border=1>
<tr>
<td>Order Number</td>
<td>Order Date</td>
<td>Cost of Order</td>
</tr>
<tr>
<td><%=#sr%></td>
<td><%=#ln%></td>
<td><%=#fn%></td>
</tr>
</table>
</body>
</html>
You need to ask a narrower question. (Also ~'s is possessive; plain ~s is for plurals.)
Reviewing your tables.txt, orderlines.id appears to mean orderline.order_id - that is the foreign key of orders, in orderlines.
So if you expressed these as ActiveRecord objects, how would you write in class Order a has_many that points to OrderLine?
I figured it out.
I was close to figuring it out one way with the code I had. Here's the code block that put everything into an array, then the loop to access values each iteration:
<% #creating the array
#orderdata = Order.find(:all, :conditions => ["customer_ID = ?",#data])
#the loop
#custdata.orders.each do |order|
#id = order.id %>
<td><%=#id%></td>
<%end%>
So much easier than I thought it would be!
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()) {
[...]
}