PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello...
I'm new to PHP and have this page written in ASP.....I need to translate it to PHP...can anyone help me ...please..
Thank you..
[syntax="asp"]
<!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=admin;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>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
switch
case $_GET["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;
Parse error: parse error, unexpected T_CASE, expecting '(' in C:\Accounts\wwwRoot\base\admin_records.php on line 17
Go to line 17 of your script. The error message is telling you that where it was expecting a parenthesis, it found a CASE statement instead. Your CASE syntax is wrong. Reference http://us3.php.net/switch
Beyond that, before you use a $_GET array value, you should assign it to a variable, then use the variable in your CASE statement, like:
switch($_GET['sort'])
{
case 'casename':
//code here
break;
case 'casename2':
//code here
break;
}
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.