Jump to content

NEW TO PHP....SYNTAX HELP NEEDED


stephanny

Recommended Posts

Hello,

 

I am new to PHP...i create a database using ASP...but I only have a Unix server that only allows PHP...can someone help me with the sorting and the select syntax please...here is the code:

 


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<%
Dim conn, connstr

'create an instance of the ADO connection and recordset objects
set conn = Server.CreateObject("ADODB.Connection")

'define the connection string, specify database driver
connstr = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=database; User=admin;Password=1admin;Option=3;"

'Open the connection to the database
conn.Open(connstr)

select case request.QueryString("sort")
	case "lastname"
		sortby = "last_name, first_name"
	case "firstname"
		sortby = "first_name, last_name"
	case "emp"
		sortby = "employer"
	case "ind1"
		sortby = "industry_1"
	case "functional"
		sortby = "functional"
	case "position"
		sortby = "position_level"
	case else
		sortby = "last_name, first_name"
end select

sql = "SELECT * FROM Active ORDER BY LAST_NAME, FIRST_NAME"
set namers = conn.Execute(sql)

if session("searchcriteria") <> "" then
	sql = "SELECT * FROM Active " & session("searchcriteria") & " ORDER BY " & sortby
else
	sql = "SELECT * FROM Active ORDER BY " & sortby
end if
set rs = conn.Execute(sql)

sql = "SELECT distinct position_level FROM Active WHERE position_level <> '' "
set positionrs = conn.Execute(sql)


sql = "SELECT distinct functional FROM Active WHERE functional <> '' "
set trainrs = conn.Execute(sql)

sql = "SELECT distinct industry_1 FROM Active WHERE industry_1 <> '' "
set orgrs = conn.Execute(sql)

sql = "SELECT distinct employer FROM Active WHERE employer <> '' "
set employrs = conn.Execute(sql)

sql = "SELECT distinct project FROM Active WHERE project <> '' "
set projrs = conn.Execute(sql)

%>

<body>
<div align="center">
<h1><strong>Records</strong></h1>
</div>
<form action="search3.asp" method="post">
<table width="100%" border="0">

  <tr>
      <td><strong>SEARCH BY </strong>: Position:
    <select name="positionsearch">
  <option></option>
  <%while not positionrs.EOF%>
	<option value="<%=positionrs("position_level")%>"><%=positionrs("position_level")%></option>
  <%positionrs.MoveNext%>
  <%wend%>
  </select>
Project:	    
<select name="projectsearch">
  <option></option>
  <%while not projrs.EOF%>
	<option value="<%=projrs("project")%>"><%=projrs("project")%></option>
  <%projrs.MoveNext%>
  <%wend%>
  </select>
      
        Function: 
     <select name="trainsearch">
  <option value=""></option>
  <%while not trainrs.EOF%>
	<option value="<%=trainrs("functional")%>"><%=trainrs("functional")%></option>
  <%trainrs.MoveNext%>
  <%wend%>
  </select>
        Industry:
        <select name="dirsearch">
  <option></option>
  <%while not orgrs.EOF%>
	<option value="<%=orgrs("industry_1")%>"><%=orgrs("industry_1")%></option>
  <%orgrs.MoveNext%>
  <%wend%>
  </select>
      Employer:
        <select name="empsearch">
  <option></option>
  <%while not employrs.EOF%>
	<option value="<%=employrs("employer")%>"><%=employrs("employer")%></option>
  <%employrs.MoveNext%>
  <%wend%>
  </select>
        <input type="submit" name="submit" value="Search"></td>
  </tr>
  <tr>
      <td><strong>OR</strong>:  
        <input type="submit" name="submit" value="View All"></td>
  </tr>
</table>
</form>
<div align="right"><font size="-1"><a href="menu.htm">Back to Menu</a></font></div>
<table width="100%" border="1">
<% if session("searchresults") <> "" then %>
	<tr><td colspan="9"><strong>Search Criteria: </strong><font color=red><%=session("searchresults")%></font></td></tr>
<% end if %>	

  <tr> 
    <td width="17%" valign="bottom" bgcolor="#999999"><strong><a href="view_records.asp?sort=lastname">Last 
      Name</a></strong></td>
    <td width="19%" valign="bottom" bgcolor="#999999"><strong><a href="view_records.asp?sort=firstname">First 
      Name</a></strong></td>
 <td width="7%" valign="bottom" bgcolor="#999999"><strong>City </strong></td>
    <td width="14%" valign="bottom" bgcolor="#999999"><p><strong><a href="view_records.asp?sort=emp">Employer</a>
</strong></p></td>
    <td width="12%" valign="bottom" bgcolor="#999999"><strong><a href="view_records.asp?sort=ind1">Industry</a>
</strong></td>
 <td width="15%" valign="bottom" bgcolor="#999999"><strong><a href="view_records.asp?sort=functional">Function</a></strong></td>
 <td width="16%" valign="bottom" bgcolor="#999999"><strong><a href="view_records.asp?sort=position">Position Level</a></strong></td>
  </tr>
  <% WHILE NOT rs.EOF %>
  
  <tr>
    <td height="30"><a href="view_info.asp?id=<%=rs("id")%>">
      <p><%=UCase(rs("last_name"))%> <br>
      <a href="editAssociate.asp?id=<%=rs("id")%>">Edit Info for <%=UCase(rs("last_name"))%> </p>
    </td>
<td><%=UCase(rs("first_name"))%> </td>
<td><%=rs("city_location")%> </td>
<td><%=rs("employer")%> </td>
<td><%=rs("industry_1")%> </td>
<td><%=rs("functional")%> </td>
<td><%=rs("position_level")%> </td>
  </tr>
  <% rs.Movenext %>
  <% wend %>
</table>
</body>
</html>


 

Thanks in advance

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.