PDA

View Full Version : get information from sql database


sher_amf
01-19-2008, 06:53 AM
what i want is i get the informations in my database then all the information will be put in my table displyed at my page..and everytime i add something to my database the table also adds
so from here
http://i104.photobucket.com/albums/m188/sher_amf/sql.jpg
to here
http://i104.photobucket.com/albums/m188/sher_amf/sql-1.jpg

davidj
01-19-2008, 10:04 AM
http://www.dreamweaverclub.com/vtm/php-mysql-apache.php

sher_amf
01-19-2008, 12:51 PM
update i already know how to do it just dont know where to place it
so i will be needing a loop that rs.next=true
but when i put <td> <%= rs.getString("type") %> </td> it results to an error

<!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>
<script type="text/javascript" language="JavaScript">
<!-- Copyright 2002 Bontrager Connection, LLC
function getCalendarDate()
{
var months = new Array(13);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var now = new Date();
var monthnumber = now.getMonth();
var monthname = months[monthnumber];
var monthday = now.getDate();
var year = now.getYear();
if(year < 2000) { year = year + 1900; }
var dateString = monthname +
' ' +
monthday +
', ' +
year;
return dateString;
} // function getCalendarDate()
function getClockTime()
{
var now = new Date();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var ap = "AM";
if (hour > 11) { ap = "PM"; }
if (hour > 12) { hour = hour - 12; }
if (hour == 0) { hour = 12; }
if (hour < 10) { hour = "0" + hour; }
if (minute < 10) { minute = "0" + minute; }
if (second < 10) { second = "0" + second; }
var timeString = hour +
':' +
minute +
':' +
second +
" " +
ap;
return timeString;
} // function getClockTime()
//-->
</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Buy</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:155px;
height:51px;
z-index:1;
left: 41px;
top: 534px;
}
#Layer2 {
position:absolute;
width:155px;
height:51px;
z-index:2;
left: 322px;
top: 67px;
}
#Layer3 {
position:absolute;
width:195px;
height:66px;
z-index:3;
left: 769px;
top: 535px;
}
#Layer4 {
position:absolute;
width:159px;
height:50px;
z-index:4;
left: 586px;
top: 136px;
}
body {
background-image: url(wallpaper.jpg);
}
#Layer5 {
position:absolute;
width:996px;
height:60px;
z-index:5;
left: 7px;
top: 30px;
}
.style1 {
font-family: "Times New Roman", Times, serif;
font-size: 36px;
font-weight: bold;
}
#Layer6 {
position:absolute;
width:979px;
height:109px;
z-index:6;
left: 19px;
top: 168px;
}
#Layer8 {
position:absolute;
width:902px;
height:116px;
z-index:8;
left: 29px;
top: 164px;
}
#Layer9 {
position:absolute;
width:706px;
height:66px;
z-index:9;
left: 30px;
top: 346px;
}
.style2 {
font-size: 18px;
font-weight: bold;
}
#Layer10 {
position:absolute;
width:153px;
height:56px;
z-index:10;
left: 32px;
top: 529px;
}
#Layer11 {
position:absolute;
width:200px;
height:115px;
z-index:11;
left: 759px;
top: 355px;
}
-->
</style>
</head>
<body>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.*"%>
<%
try {
Connection con;
Statement stmt;
ResultSet rs;
String URL,query;

String year = request.getParameter("select5");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:sherwin","","");
stmt = con.createStatement();
query = "SELECT brokers FROM sell";
rs = stmt.executeQuery(query);

con.close();
} catch (Exception e){
System.out.println("SQL Exception : " + e.getMessage());
}
%>
<div class="style1" id="Layer5">
<p>ONLINE PORTFOLIO TRACKING SYSTEM</p>
<p><img src="border.jpg" width="982" height="24" /></p>
</div>
<div id="Layer3"><img src="BUY.gif" width="150" height="48" /></div>
<div id="Layer8">
<table width="898" height="109" border="1">
<tr>
<td width="279"><strong>Broker name </strong></td>
<td width="359"><strong>Stock Code </strong></td>
<td width="76"><strong>Price</strong></td>
<td width="156"><strong>Available Stocks </strong></td>
</tr>
<tr>
<td>Michael</td>
<td>PLDT</td>
<td>1000</td>
<td>500</td>
</tr>
<tr>
<td height="40">&nbsp;</td>
<td> iklo </td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</div>
<div id="Layer7">
<form method="post" action="checkbuy.jsp">
</div>
<div id="Layer9">
<p class="style2">Broker name:
<label>
<input type="text" name="brokers" />
</label>
Stock code:
<label>
<input type="text" name="stock" />
</label>
Quantity:
<input name="qty" type="text" size="10" />
</p>
<p class="style2">Date bought : Month
<select name="select3">
<option value="Jan">January</option>
<option value="Feb">February</option>
<option value="Mar">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="Aug">August</option>
<option value="Sept">September</option>
<option value="Nov">November</option>
<option value="Dec">December</option>
</select>
Day:
<select name="select4">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
Year:
<select name="select5">
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
</select>
</p>
<p class="style2">
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</p>
</div>
<div id="Layer10"><a href="main.jsp"><img src="home.gif" width="150" height="48" border="0" /></a></div>
</form>
<div id="Layer11">
<script type="text/javascript" language="JavaScript"><!--
var calendarDate = getCalendarDate();
var clockTime = getClockTime();
document.write('Date is ' + calendarDate);
document.write('<br>');
document.write('Time is ' + clockTime);
//--></script></div>
</body>
</html>

davidj
01-19-2008, 03:24 PM
hi mate

i advise you contact the author of this script for support

he will be able to point you in the right direction