this is the new problem im getting:
Warning: Supplied argument is not a valid MySQL result resource
All im trying to set up is some keyword search with 2 drop down lists with some pagination
the code im using below is:
THIS GOES IN THE HEAD SECTION OF THE PAGE:
<SCRIPT language=JavaScript>
function Navigate( pPagePos, pTimeStamps )
{
document.test.page_pos.value = pPagePos;
document.test.submit();
}
</SCRIPT>
THIS GOES IN THE BODY SECTION OF THE WEB PAGE:
<?
define ( "_PAGESIZE" , 10 );
$db_name = "";
$table_name = "";
$connection =
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
function RenderForm($pPagePos=0, $keyword = "",$region = "",$job_sector = "")
{
print "<form name=test id=test METHOD=POST><table width=75% border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=97% bgcolor=#FF9933><div align=left><strong><font color=#FFFFFF>Quick
Search</font></strong></div></td>
<td width=3%><img src=images/org_toprightcorner.gif width=20 height=18></td>
</tr>
</table>
<table width=75% border=0 cellspacing=0 cellpadding=0>
<tr>
<td height=21 bgcolor=#FFEBD7>Keyword </td>
<td height=21 bgcolor=#FFEBD7><input name=keyword type=text id=keyword value=$keyword></td>
<td width=60% valign=baseline bgcolor=#FFEBD7>Job Sector
<select name=job_sector id=job_sector>
<option value=$job_sector>All Job Sectors</option>
<option>Office </option>
<option>Finance</option>
<option>Catering/Hospitality</option>
<option>Sales & Marketing</option>
<option>Driving</option>
<option>Health & Social Care</option>
<option>IT</option>
<option>Retail</option>
<option>General</option>
<option>Manufacturing & Production</option>
</select></td>
</tr>
<tr>
<td width=13% bgcolor=#FFEBD7>Region </td>
<td width=27% bgcolor=#FFEBD7><select name=region id=region>
<option value=$region>All Regions</option>
<option>London</option>
<option>North East</option>
<option>Yorkshire</option>
<option>Norfolk</option>
</select></td>
<td bgcolor=#FFEBD7> <div align=center><input name=imageField type=image src=images/buttons/search.gif width=61 height=26 border=0>
</div></td>
</tr>
<tr bgcolor=#FFEBD7>
<td colspan=3><div align=center> </div></td>
</tr>
</table>
<input type=hidden name=page_pos ID=page_pos value=$pPagePos>
</form>";
}
function RenderNavigationLinks( $pCount, $pPagePos=0, $pPageSize, $pTableWidth = '70%')
{
// to display record nos. on navigation
if(( ( $pPagePos + 1 ) $pPageSize ) > $pCount ) $last_rec = $pCount;
else $last_rec = ( $pPagePos + 1 ) $pPageSize;
$beg_rec = ( $pPagePos * $pPageSize ) + 1;
print "<TABLE WIDTH=".$pTableWidth." BORDER=0 CELLPADDING=2 CELLSPACING=0 ALIGN='CENTER' CLASS='TextVerdanaBlack11Px'>\n";
print "<TR>\n";
// show rec nos.
print "<TH ALIGN=RIGHT> $beg_rec - $last_rec of $pCount \n";
// prev link
if( $pPagePos > 0 ) print "<A HREF=\"java script:Navigate( $pPagePos-1)\"> << Prev </A>\n";
// next link
if( $pCount > ( ( $pPagePos + 1 ) * $pPageSize ) ) print "<A HREF=\"java script:Navigate( $pPagePos+1)\"> Next >></A>\n";
print "</TH>\n";
print "</TR>\n";
print "</TABLE>\n";
}
function LoadJoblist($startrow,$endrow)
{
$select_clause = "select * from $table_name";
$where_and = " WHERE ";
$where_clause = "";
//these are constraint checking
if ($keyword )
{
$where_clause = $where_clause . $where_and ."job_title OR job_summary LIKE '%". $keyword ."%'";
$where_and = " AND ";
}
if ($job_sector )
{
$where_clause = $where_clause . $where_and ."job_sector=".$job_sector;
$where_and = " AND ";
}
if ($region )
{
$where_clause = $where_clause . $where_and ."region=".$region;
$where_and = " AND ";
}
$limit_clause = " limit $startrow , $endrow";
$stmt = $select_clause.$where_clause.$limit_clause;
$rs = mysql_query($stmt);
return $rs;
}
function RenderList($rs)
{
while ($row = mysql_fetch_array($rs))
{
$job_id = $row['job_id'];
$contact_name = stripslashes($row['contact_name']);
$contact_phone = $row['contact_phone'];
$date_posted = $row['date_posted'];
$job_title = stripslashes($row['job_title']);
$job_summary = stripslashes($row['job_summary']);
$short_summary = substr($job_summary,0,150);
$location = stripslashes($row['location']);
$job_status = stripslashes($row['job_status']);
$salary = $row['salary'];
$career_level = stripslashes($row['career_level']);
$display_block .= "
<table width=75% height=35 cellpadding=0 cellspacing=1>
<tr bgcolor=#FFEBD7>
<td width=54% align=left valign=top><a href=latest_jobs_detail.php?job_id=$job_id>$job_title</a><br>$short_summary.....<a href=latest_jobs_detail.php?job_id=$job_id>[More]</a><br>
<font size=2><strong>Job type:</strong> $job_status<br>
<strong> Salary:</strong>$salary</font>
<td width=15% align=left valign=top>$location
</tr>
</table>";
}
}
$start_row = ( $page_pos * _PAGESIZE );
RenderForm($page_pos,$keyword,$region,$job_sector);
$rs = LoadJobList($startrow , _PAGESIZE,$keyword,$region,$job_sector);
$TotalRows = mysql_num_rows($rs);
if ($TotalRows > 0){
RenderNavigationLinks($TotalRows,$page_pos,_PAGESIZE);
RenderList($rs);//fetching and Printing
}
?>