OK, I'm a total newbie and am totally lost. 😕
I am trying to allow users to obtain information from a database and click a link to edit any necessary fields. If a particular field is not completed, then the record in the database should retain its original value. When clicking the edit link I'm getting a "query is empty" error. I think the issue is with the first page, I'm not sure where to go with this.
Can someone point me in the right direction?
<?
include 'includes/mysqlInit.inc';
$sDate=$_POST['sDate'];
$id=$_POST['newID'];
if( $offset <= 0 )
{
$offset = 0;
}
//open connection
$conn=mysql_connect($host, $username, $password) or die ("Unable to connect!");
//select database
mysql_select_db($database) or die( "Unable to select database".mysql_error());
$query = "select count(*) as cnt from jobDatabase";
$result = mysql_query( $query);
$row = mysql_fetch_object( $result );
$num_rows = $row->cnt;
$query = "select *, date_format( expireDate, '%m/%d/%Y' ) as eDate from jobDatabase order by expireDate limit $offset, 20";
$result = mysql_query( $query);
if( $num_rows%20 )
{
$lastOffset = (($num_rows - ($num_rows%20))/20) * 20;
}
else
{
$lastOffset = (($num_rows/20) - 1) * 20;
}
if( ($nextOffset = $offset + 20) >= $num_rows )
{
$nextOffset = $lastOffset;
}
?>
<html>
<head>
<title>Admin - Job Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../css/style1.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" link="#0000FF" vlink="#0000FF" alink="#0000FF">
<p align="center">
<? include 'includes/head.inc' ?>
</p><br>
<table width="773" border="0" cellspacing="0" cellpadding="4" align="center">
<tr>
<td width="60"> </td>
<td> </td>
</tr>
<tr>
<td width="60"> </td>
<td>
<p>
<font face="Verdana, Arial, Helvetica, sans-serif" size="-1"><b><a href="add_job.php"><br>
Add a New Job</a> | <a href="http://www.desertpinnacle.com/jobs/admin/job_search_date.php">View Jobs Posted By
Date</a> | View Jobs By Status | <a href="http://www.desertpinnacle.com/jobs/admin/jobsearch2.php">View Jobs By Employer</a></b></font>
</p><table width="657"><tr><td width="412" valign="top">
<b><font face="Verdana, Arial, Helvetica, sans-serif">Expired Jobs Sorted By
Date </font></b></td><td width="233" valign="middle"><form name="form2" action="confirm_delete.php" method="post">
<input type="submit" name="submit2" value="Delete All Jobs">
</form></td></tr></table>
<table border="0" width="50%" class="site" align="center">
<tr>
<td width="23%" align="center"> <b>
<a href="job_search_date.php">First
Page </a></b>
</td>
<td width="31%" align="center"><b>
<a href="job_search_date.php?offset=<? echo $offset-20 ?>">Previous
Page </a> </b>
</td>
<td width="23%" align="center"><b>
<a href="job_search_date.php?offset=<? echo $nextOffset ?>">Next
Page </a></b>
</td>
<td width="23%" align="center"><b>
<a href="job_search_date.php?offset=<? echo $lastOffset ?>">Last
Page </a> </b>
</td>
</tr>
</table>
<table width="664" border="0" cellspacing="0" cellpadding="0" align="center" valign="middle">
<tr><td> </td>
<td> </td>
<td align="left">
</td></tr></table>
<table border="0">
<tr>
<?
$result = mysql_query("SELECT * FROM jobDatabase WHERE expireDate <= '$sDate' ORDER BY expireDate");
while( $row = mysql_fetch_object( $result ) ) { ?>
<table width="653" border="0" cellspacing="0" cellpadding="4" class="site">
<tr>
<td width="369"><b><form name="form2" method="post"><input type="hidden" name="newID" value="<? echo $row->id ?>"><input type="hidden" name="employee" value="<? echo $row->employer ?>"><? echo $row->employer ?></b></td>
<td width="268"><input type="hidden" name="city" value="<? echo $row->city ?>"><? echo $row->city ?>, <input type="hidden" name="state" value="<? echo $row->state ?>"><? echo $row->state ?></td>
</tr>
<tr>
<td width="637"><input type="hidden" name="description" value="<? echo substr($row->description, 0, 200) ?>"><? echo substr($row->description, 0, 200)."..." ?>
<tr>
<td width="369"><a href="edit_job.php?id=<? echo urlencode($row_name['id'])?>">Edit
Job</a> | <a href="renew_job.php?id=<? echo urlencode($row_name['id'])?>">Renew
Job</a> | <a href="delete_job.php?id=<? echo $row->id ?>">Delete This
Job</a></td>
<td width="268">Expire Date: <b><font color="#990000"><? echo $row->expireDate ?></font></b></form></td>
</tr>