www.webdeveloper.com
Results 1 to 12 of 12

Thread: Website that pulls info from database?

  1. #1
    Join Date
    Mar 2006
    Posts
    5

    Website that pulls info from database?

    I would like to create a website with a list of addresses/names/phone numbers for different categories. Kind of like a directory. I would like to pull this information from a database if possible. Is there any way to do this?

  2. #2
    Join Date
    Nov 2003
    Location
    Worthington, OH, USA
    Posts
    3,634
    Sure, just need a database on the server and a server side language - ASP, ASP.Net, PHP, Java, or JSP are fairly common.
    54 68 65 42 65 61 72 4D 61 79

  3. #3
    Join Date
    Mar 2006
    Posts
    5
    That sounds difficult. The only thing I know is html. Do you know of any tutorial that could help me out?

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,633
    Quote Originally Posted by beckster2001
    That sounds difficult. The only thing I know is html. Do you know of any tutorial that could help me out?
    Start by determining what server-side language(s) and database(s) your web host supports. That will narrow down the selection.

    If PHP is an option, take a look at http://www.zend.com/php/beginners/index.php to get started.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Mar 2006
    Posts
    5

    Unhappy

    OK. So I am working on antiquesinva.com . On the index page I have a pull down menu. I'm trying to get the first option "Portsmouth" to work. The portsmouth.asp page comes up, but is not displaying the information I had hoped. I created portsmouth.asp hoping to pull information from a database. The database is called antiquesdb, but the table is called stores. I can't get any info from the database to show. Help please!!

  6. #6
    Join Date
    May 2004
    Location
    Manhattan NY
    Posts
    6,028
    This isn't a quick and easy thing to explain. What's in this asp file you created? 1st you need to make a connection to the database, and you need to know the connection string for that database. You need a SQL statement, such as:

    SELECT blah FROM tableName WHERE someCondition = someValue;

    I assume you plan to use vbscript as the scripting language.

  7. #7
    Join Date
    Mar 2006
    Posts
    5
    In the portsmouth.asp file it says:
    <%@ Language="VBScript" %>
    <% Option Explicit %>
    and in the body of the html it says:
    SELECT store_name, store_address, store_city, store_phone
    FROM stores
    WHERE store_city = 'Portsmouth'
    ORDER BY store_name;

    But when the website loads it just displays all my code! How do I get the database to load?

  8. #8
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Problems so far.
    1. Your host doesn't support ASP.
    2. You don't have a database named stores or if you do you haven't made a connection to it.
    3. You don't have any code that creates or reads a record set that would be returned by your SQL query.

  9. #9
    Join Date
    May 2004
    Location
    Manhattan NY
    Posts
    6,028
    But that's not close to a complete asp file. There's no connection to the db, there's no loop, there's no variables to hold the data, surrounded by the displaying elements for the html.

  10. #10
    Join Date
    Mar 2006
    Posts
    5
    Here is the entire code I have:
    <%@ Language="VBScript" %>
    <% Option Explicit %>


    <HTML>
    <HEAD>
    <TITLE>Portsmouth Antiques</TITLE>
    </HEAD>

    <BODY>
    SELECT store_name, store_address, store_city, store_phone
    FROM stores
    WHERE store_city = 'Portsmouth'
    ORDER BY store_name;
    </BODY>
    </HTML>


    I know my server does support ASP. I got a test page to work on it. I use godaddy.com. My database is called "antiquesdb", but the actual table I want to use is called "stores". Can someone give me the code I need to connect to my database? I really, really want to learn how to do this. I hope you all have patience to work with me.

  11. #11
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    Back in the day I found http://asp101.com/ very handy.

  12. #12
    Join Date
    Nov 2003
    Location
    Worthington, OH, USA
    Posts
    3,634
    Here's a slightly modified example from the Samples directory that comes with the IIS install:
    Code:
    <%@ LANGUAGE = VBScript %>
    <%  Option Explicit		%>
    
    <HTML>
        <HEAD>
            <TITLE>Simple ADO Query</TITLE>
        </HEAD>
    
        <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
    
    		<!-- Display Header -->
    
    		<font size="4" face="Arial, Helvetica">
    		<b>Simple ADO Query with ASP</b></font><br>
        
    		<hr size="1" color="#000000">
    
    		<%
    			Dim oConn
    			Dim oRs
    			Dim filePath
    			Dim Index
    
    
    			' Map database to physical path
    			filePath = Server.MapPath("antiquesdb.mdb")
    
    
    			' Create ADO Connection Component to connect
    			' with sample database
    
    
    			
    			Set oConn = Server.CreateObject("ADODB.Connection")
    			oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
    
    			
    			' Execute a SQL query and store the results
    			' within recordset
    			
    			Set oRs = oConn.Execute("SELECT store_name, store_address, store_city, store_phone FROM stores WHERE store_city = 'Portsmouth' ORDER BY store_name;")
    		%>
    
    
    		<TABLE border = 1>
    		<%
    			Do while (Not oRs.eof) %>
    
    				<tr>
    					<% For Index=0 to (oRs.fields.count-1) %>
    						<TD VAlign=top><% = oRs(Index)%></TD>
    					<% Next %>
    				</tr>
    
    				<% oRs.MoveNext 
    			Loop
    		%>
    
    
    		</TABLE>
    
    
    		<%
    			oRs.close
    			oConn.close
    		%>
    
    	</BODY>
    </HTML>
    54 68 65 42 65 61 72 4D 61 79

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles