Why does this condition not work? - php

I've noticed that the first condition does not work
if (empty($ss)) {
echo "please write your search words";
}
but the second does
else if ($num < 1) {
echo "not found any like ";
Full code:
<?php
require_once "conf.php";
$ss= $_POST["ss"];
$sql2=("SELECT * FROM student WHERE snum = $ss");
$rs2 = mysql_query($sql2) or die(mysql_error());
$num = mysql_num_rows($rs2);
if (empty($ss)) {
echo "please write your search words";
}
else if ($num < 1 ) {
echo "not found any like ";
}else {
$sql=("SELECT * FROM student WHERE snum = $ss ");
$rs = mysql_query($sql) or die(mysql_error());
while($data=mysql_fetch_array($rs)) {
?>
<div id="name">
<table align="center" border="3" bgcolor="#FF6666">
<tr>
<td><? echo $data ["sname"]." "."نتيجة الطالب"; ?></td>
</tr>
</table>
</div>
<div id="ahmed">
<table width="50%" height="50" align="center" border="2px" bgcolor="#BCD5F8">
<tr>
<td width="18%"><strong>جيولوجي</strong></td>
<td width="13%"><strong>تاريخ</strong></td>
<td width="13%"><strong>رياضة</strong></td>
<td width="14%"><strong>عربي</strong></td>
<td width="12%"><strong>علوم</strong></td>
<td width="30%"><strong>المادة</strong></td>
</tr>
<tr>
<td>100</td>
<td>100</td>
<td>100</td>
<td>100</td>
<td>100</td>
<td><strong>الدرجة النهائية</strong></td>
</tr>
<td><? echo $data['geo']; ?></td>
<td><? echo $data['snum']; ?></td>
<td><? echo $data['math']; ?></td>
<td><? echo $data['arab']; ?></td>
<td><? echo $data['history']; ?></td>
<td><strong>درجات الطالب</strong></td>
</tr>
<tr>
<td colspan="5" align="center" valign="middle">
<? $sum= $data['geo'] + $data['snum'] +
$data['math'] + $data['arab'] +
$data['history'];
echo $sum ;
?>
</td>
<td><strong>مجموع الدرجات</strong></td>
</tr>
<tr>
<td colspan="5" align="center">
<?
$all=500 ;
$sum= $data['geo'] + $data['snum'] +
$data['math'] + $data['arab'] +
$data['history'];
$av=$sum/$all*100 ;
echo $av."%" ;
?>
</td>
<td><strong>
النسبة المئوية
</strong></td>
</tr>
</table>
</tr>
</div>
<?
}
};
The full code link is:
http://www.mediafire.com/?2d4yzdjiym0

Are you sure that $ss isset? i.e. there is a POST variable with the name ss. you could test it with.
if (empty($ss) || !isset($ss)) {
echo "please write your search words";
}
or test for it when you read in the post var
if ((!isset($_POST["ss"]) || (!is_numeric($_POST["ss"])))
{
$ss = 0;//empty considers 0 as been empty
}
else
{
$ss = $_POST["ss"];
}
ss looks to be a number too, so checking if it is numeric using is_numeric will help stop SQL errors, if for some reason it is not.

Use
if (!isset($ss)) {
echo "please write your search words";
}
instead of
if (empty($ss)) {
echo "please write your search words";
}

Try changing the condition to
if(empty($_POST['ss'])){ ... }
and continue using $_POST['ss'] instead of $ss.
BTW Always use error_reporting(E_ALL) when developing.

$sql=("SELECT * FROM student WHERE snum = $ss ");
Remove the brackets in the variables ($sql1 and $sql2) that have your query
It should be
$sql="SELECT * FROM student WHERE snum = $ss ";
I think that's why its telling you that you have an error near ...

Related

Error when empty MySQL field even with conditions

When I click on a project in my web app, that it contains values, I do not get any error, but I created another project with empty fields in MySQL, and I clicked on it, in my web app (PHP app), so I got this error:
Undefined variable: total in
C:\wamp\www\architect\projDetails.php on line 80
I have this PHP code:
$id = $_REQUEST['id'];
$sql = "SELECT (SELECT SUM(total_pay) FROM workers) total,workers. * FROM workers WHERE projects_id = ".$id." ORDER BY date_of_pay DESC";
$stmt = mysqli_query($con, $sql) or die($sql."<br/><br/>".mysqli_error($con));
And here html and php code near line 80:
<tr>
<?php while($rows = mysqli_fetch_array($stmt)){ $total = 0; ?>
<tr>
<?php if($rows['total']!=0){
$total = $rows['total'];
}
else {
$total = "غير متوفر";
}
?>
<td align="center"><?php echo $rows['total_pay']?></td>
<td align="center"><?php echo $rows['date_of_pay']?></td>
<td align="center"><?php echo $name['project_name'] ?></td>
<td align="center"><!--<input class="imgClass_insert" type="submit" name="submit1" value="" />-->
<input class="imgClass_dell" type="submit" onClick="return confirm('Are you sure you want to delete?')" name="delete_workers" value=""/>
</td>
</tr>
</tr>
<?php } ?>
<tr>
<td colspan="3">مجموع تكاليف العمال في مشروع <?php echo $name['project_name']?></td>
<td align="center"><?php echo $total ?></td>
</tr>
So when total is empty, I get the error,and when it is not empty, I don't get any errors, so what is the problem here?
Your variable $total is currently only alive within the while block. You are exiting this block at the statement </tr><?php } ?><tr>. That means your variable is no longer allocated in code row <td align="center"><?php echo $total ?></td> below. To use this total variable below the while block, add the declaration and initialization of the variable above the while block, e.g:
<tr>
<?php $total = 0;
while($rows = mysqli_fetch_array($stmt)){ ?>
<tr>
<?php if($rows['total']!=0){ <-- Check this comparison (described below)
$total = $rows['total'];
}
else {
$total = "غير متوفر";
}
?>
<td align="center"><?php echo $rows['total_pay']?></td>
<td align="center"><?php echo $rows['date_of_pay']?></td>
<td align="center"><?php echo $name['project_name'] ?></td>
<td align="center"><!--<input class="imgClass_insert" type="submit" name="submit1" value="" />-->
<input class="imgClass_dell" type="submit" onClick="return confirm('Are you sure you want to delete?')" name="delete_workers" value=""/>
</td>
</tr>
</tr>
<?php } ?>
<tr>
<td colspan="3">مجموع تكاليف العمال في مشروع <?php echo $name['project_name']?></td>
<td align="center"><?php echo $total ?></td>
</tr>
Hope this will work for you. The annotated line in code above will compare a string with an integer value. Please be aware that $rows['total'] will contain a value of type String. Your comparison is against an integer value of 0. PHP should not throw an error or warning but it could come to unwanted results in this if statement. (Further information: http://php.net/manual/de/language.types.type-juggling.php )
Try something like below.
echo isset($total)? $total: 0;
Here if we are getting any data from DB, then only it will enter into the while loop. Now inside while loop only $total is defining.
If we define it outside the while loop, the default value, will solve the issue
<tr> <?php
$total = "0";
while($rows = mysqli_fetch_array($stmt)){ $total = 0;
if($rows['total']!=0){
$total = $rows['total'];
}
//.....
//.....
} ?>
</tr>
<tr>
<td colspan="3">some text <?php echo $name['project_name']?></td>
<td align="center"><?php echo $total ?></td>
</tr>
Thank you

if any subject got "F" or "0", then Total Grade I want to show = "F"

I attached my output image here: this my output
<table width="100%" style="text-align:center">
<tr>
<td>Subject </td>
<td>Grade </td>
</tr>
<?php
include 'connect.php';
$class_n =$_POST['class_n'];
$class_s =$_POST['class_s'];
$r =$_POST['roll'];
$sql="select * from full_result where class_n='$class_n' AND class_s='$class_s' AND roll='$r'";
$data = mysql_query($sql);
$sum=0;
while ($row = mysql_fetch_array($data))
{
$r=$row['marks'];
if($r>=40)
{
$r1=$row['point'];
}
elseif($r<=33)
{
$r1=0;
}
$sum=$sum+$r1;
?>
<tr>
<td><?php echo $row['subject']; ?></td>
<td><?php echo $row['grade']; ?> </td>
<td><?php echo $row['point']; ?> </td>
</tr>
<?php } ?>
</table>
<br>
<p><?php echo $sum;
?> </p>
This my code, here I am trying to use one condition, but it's doesn't work. it comes almost total Marks. But what I want is that when any subject becomes 0 or F, the Total mark will become F.
Use a flag variable and set it to 1 if the student get 0 or F (I assume it's when $r <= 33) for any subject. Then before displaying sum, check if the flag is set and if set change value of $sum to 'F'
<table width="100%" style="text-align:center">
<tr>
<td>Subject </td>
<td>Grade </td>
</tr>
<?php
include 'connect.php';
$class_n =$_POST['class_n'];
$class_s =$_POST['class_s'];
$r =$_POST['roll'];
$flag = 0;
$sql="select * from full_result where class_n='$class_n' AND class_s='$class_s' AND roll='$r'";
$data = mysql_query($sql);
$sum=0;
while ($row = mysql_fetch_array($data))
{
$r=$row['marks'];
if($r>=40)
{
$r1=$row['point'];
}
elseif($r<=33)
{
$r1=0;
$flag = 1;
}
$sum=$sum+$r1;
?>
<tr>
<td><?php echo $row['subject']; ?></td>
<td><?php echo $row['grade']; ?> </td>
<td><?php echo $row['point']; ?> </td>
</tr>
<?php }
if($flag == 1)
{
$sum = F;
}
?>
</table>
<br>
<p><?php echo $sum; ?>
?> </p>

Back to previous page after deletion of row

<?php
include_once "library/inc.sesadmin.php";
include_once "library/inc.library.php";
include_once "mhsfunc.php";
$filterSQL = "";
if(isset($_POST['btnSubmit'])) {
$txtNim = trim($_POST['txtNim']);
$txtNama = trim($_POST['txtNama']);
$cmbProdi = trim($_POST['cmbProdi']);
$txtSmt = trim($_POST['txtSmt']);
$cmbSmt = trim($_POST['cmbSmt']);
if($cmbSmt<>""){
$filterSQL = "WHERE khs.nim='$txtNim' AND khs.smt='$cmbSmt'";
}else {
$filterSQL = "WHERE khs.nim='$txtNim'";
}
} else {
$filterSQL = "WHERE khs.nim='zzz'";
}
#tampilkan hasil isian di form
$dataNim =isset($_POST['txtNim']) ? $_POST['txtNim'] : '';
$dataNama =isset($_POST['txtNama']) ? $_POST['txtNama'] : '';
$dataProdi =isset($_POST['cmbProdi']) ? $_POST['cmbProdi'] : '';
$dataSmtMhs =isset($_POST['txtSmt']) ? $_POST['txtSmt'] : '';
$dataSmtKrs =isset($_POST['cmbSmt']) ? $_POST['cmbSmt'] : '';
# FOR PAGING (PEMBAGIAN HALAMAN)
$baris = 50;
$hal = isset($_GET['hal']) ? $_GET['hal'] : 1;
$pageSql = "SELECT * FROM khs $filterSQL";
$pageQry = mysql_query($pageSql, $koneksidb) or die ("error paging: ".mysql_error());
$jumlah = mysql_num_rows($pageQry);
$maks = ceil($jumlah/$baris);
$mulai = $baris * ($hal-1);
$jmlsks = 0;
$jmlbobot = 0;
$ipk = 0;
?>
<table width="800" border="0" cellpadding="2" cellspacing="0" class="table-border">
<tr>
<td colspan="3" align="right"><h1><b>DATA KRS MAHASISWA </b></h1></td>
</tr>
<tr>
<td colspan="3">
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="form1" target="_self">
<table class="table-list" width="1000" border="0" cellpadding="2" cellspacing="1" >
<tr>
<td colspan="3" style="font-size:20px; font-family:Cambria" bgcolor="#F5F5F5"><b>FILTER DATA</b></td>
</tr>
<tr>
<td width="169"><b>NIM Mahasiswa</b></td>
<td width="5"><b>:</b></td>
<td width="260"><input name="txtNim" type="text" id="txtNim" value="<?php echo $dataNim; ?>" size="15" maxlength="12" /></td>
</tr>
<tr>
<td><b>Nama Mahasiswa</b></td>
<td><b>:</b></td>
<td><input name="txtNama" type="text" id="txtNama" value="<?php echo $dataNama; ?>" size="40" maxlength="40" /></td>
</tr>
<tr>
<td><b>Program Studi</b></td>
<td><b>:</b></td>
<td><select name="cmbProdi" id="cmbProdi">
<option value="KOSONG">....</option>
<?php
$dataSql = "SELECT * FROM prodi ORDER BY kode";
$dataQry = mysql_query($dataSql, $koneksidb) or die ("Gagal Query".mysql_error());
while ($dataRow = mysql_fetch_array($dataQry)) {
if ($dataRow['kode'] == $cmbProdi) {
$cek = " selected";
} else { $cek=""; }
echo "<option value='$dataRow[kode]' $cek> [$dataRow[kode]] $dataRow[nama]</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td><b>Semester Mahasiswa</b></td>
<td><b>:</b></td>
<td><input name="txtSmt" type="text" id="txtSmt" value="<?php echo $dataSmtMhs; ?>" size="3" maxlength="1" /></td>
</tr>
<tr>
<td><b>Semester KRS</b></td>
<td><b>:</b></td>
<td><select name="cmbSmt" id="cmbSmt">
<option value="">ALL</option>
<?php
$pilihan = array("1", "2", "3", "4", "5","6");
foreach ($pilihan as $semester) {
if ($dataSmtKrs==$semester) {
$cek="selected";
} else { $cek = "";}
echo "<option value='$semester' $cek>$semester</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input name="btnSubmit" type="submit" value=" Submit" id="btnSubmit" /></td>
</tr>
</table>
</form>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">
<table class="table-list" width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td colspan="5"><img src="images/btn_add_data.png" height="30" border="0" /></td>
</tr>
<tr>
<td width="28" align="center" bgcolor="#F5F5F5"><b>No</b></td>
<td width="63" bgcolor="#F5F5F5"><b>NIM</b></td>
<td width="53" bgcolor="#F5F5F5"><b>KDMK</b></td>
<td width="368" bgcolor="#F5F5F5"><b>NAMA MK</b></td>
<td width="35" bgcolor="#F5F5F5"><b>SMT</b></td>
<td width="30" bgcolor="#F5F5F5"><b>SKS</b></td>
<td width="26" bgcolor="#F5F5F5"><b>TM</b></td>
<td width="21" bgcolor="#F5F5F5"><b>PR</b></td>
<td width="19" bgcolor="#F5F5F5"><b>LP</b></td>
<td width="252" bgcolor="#F5F5F5"><b>DOSEN (NIDN/NAMA)</b></td>
<td align="center" bgcolor="#CCCCCC"><b>Tools</b></td>
</tr>
<?php
$mySql = "SELECT khs.id_khs, khs.nim, khs.kdmk, khs.nmmk, khs.smt, mtkul.sks, mtkul.tm, mtkul.pr, mtkul.lp,mtkul.nodos
FROM khs
INNER JOIN mtkul
ON khs.tahun=mtkul.tahun AND khs.prodi=mtkul.prodi AND khs.smt=mtkul.smt AND khs.kdmk=mtkul.kode $filterSQL
ORDER BY khs.smt, khs.kdmk LIMIT $mulai, $baris";
$myQry = mysql_query($mySql, $koneksidb) or die ("Query salah : ".mysql_error());
$nomor = $mulai;
while ($myData = mysql_fetch_array($myQry)) {
$nomor++;
$nidn = $myData['nodos'];
$Kode = $myData['id_khs'];
$jmlsks = $jmlsks+$myData['sks'];
$qryDosen = "SELECT * from dosen WHERE nidn=$nidn";
$qryCek = mysql_query($qryDosen, $koneksidb) or die ("Eror Query".mysql_error());
$myData2 = mysql_fetch_assoc($qryCek);
if(mysql_num_rows($qryCek)>=1){
$namaDosen=$myData2['nama'];
} else {$namaDosen=$nidn;}
// Gradasi warna baris
if($nomor%2==1) { $warna="#FFFFFF"; } else {$warna="#F5F5F5";}
?>
<tr bgcolor="<?php echo $warna; ?>">
<td align="center"><?php echo $nomor; ?></td>
<td><?php echo $myData['nim']; ?></td>
<td><?php echo $myData['kdmk']; ?></td>
<td><?php echo $myData['nmmk']; ?></td>
<td align="center"><?php echo $myData['smt']; ?></td>
<td align="center"><?php echo $myData['sks']; ?></td>
<td><?php echo $myData['tm']; ?></td>
<td><?php echo $myData['pr']; ?></td>
<td><?php echo $myData['lp']; ?></td>
<td><?php echo $namaDosen ?></td>
<td width="56" align="center">Delete</td>
//here is the KRS-Delete.php
<?php
include_once "library/inc.sesadmin.php";
// Get From URL
if(empty($_GET['Kode'])){
echo "<b>Data yang dihapus tidak ada</b>";
}
else {
$Kode = $_GET['Kode'];
$mySql = "DELETE FROM khs WHERE id_khs='$Kode'";
$myQry = mysql_query($mySql, $koneksidb) or die ("Eror hapus data".mysql_error());
if (mysql_affected_rows() > 0) {
header('location: ' .$_GET['Kode']);
echo "<script type=\"text/javascript\">".
"alert('Data Berhasil Di Hapus');".
"</script>";
echo "<meta http-equiv='refresh' content='0; url=?open=KRS-Data'>";
} else {
echo "Data tidak ditemukan !! <br><br>";
}
My Problem is that when I successfully delete a row, I want my page to go back showing the previous table shown, minus the row that I have already deleted with the exact same page number. What I need to parse into and out of KRS-Delete.php
When building UI pages that involve multiple steps, I prefer to put all steps in the same PHP file. I start with $foo = #$_GET['foo']; if ($foo) DoFoo(); to see if this call needs to do the "foo" step (such as doing the DELETE). After DoFoo(), I usually fall into the main code, which presents the UI page identical to (or similar to) the original page.
In addition to avoiding navigation problem you mentioned, it allows me to have 'all' the stuff for this UI in one file. Often there is a lot of common code, too.

How to show records from database in html table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm selecting records from database and showing it as
<table>
<tr>
<td align="center" >Name</td>
<td align="center" >Contact</td>
</tr>
<?php
foreach($rowset as $row)
{
?>
<tr>
<td align="left"><?php echo $row['name'];?></td>
<td align="left"><?php echo $row['contact'];?></td>
</tr>
<?php
}
?>
</table>
It is displayed as
| Name | Contact |
a 9956874525
b 9856426569
c 9865989657
d 8956789565
e 8956879899
f 8985656465
Here each record is shown in separate <tr>
But now i've to show the records in such a way that ,two records are shown in a single <tr>
So my design should be
| Name | Contact | | Name | Contact |
a 9956874525 b 9856426569
c 9865989657 d 8956789565
e 8956879899 f 8985656465
What changes should i do in above code? Please help
You need create an counter to count how many times you have printed the data.
Maybe like this (not tested yet):
<?php
$i = 0;
foreach($rowset as $row)
{
if($i % 2 == 0) echo "<tr>";
?>
<td align="left"><?php echo $row['name'];?></td>
<td align="left"><?php echo $row['contact'];?></td>
<?php
if($i % 2 == 0) echo "</tr>"; $i++;
}
?>
modify the code like this
<table>
<tr>
<td align="center" >Name</td>
<td align="center" >Contact</td>
</tr>
<?php
$i=1;
foreach($rowset as $row)
{
if($i%2==1) {
?>
<tr>
<?php } ?>
<td align="left"><?php echo $row['name'];?></td>
<td align="left"><?php echo $row['contact'];?></td>
<?php if($i%2==0) { ?>
</tr>
<?php } ?>
<?php
$i++; }
?>
You can apply the loop conditionally on the basis of indexes.
<table>
<tr>
<td align="center">Name</td>
<td align="center">Contact</td>
<td align="center">Name</td>
<td align="center">Contact</td>
</tr>
<tr>
<?php
foreach($rowset as $i=>$row) {
if($i!=0 && $i%2 == 0) {
?>
</tr><tr>
<?php } ?>
<td align="left"><?php echo $row['name'];?></td>
<td align="left"><?php echo $row['contact'];?></td>
<?php } ?>
</tr>
</table>
Try using a for loop instead
$num_contacts = sizeof($rowset);
for($i = 0; $i < $num_contacts; $i++)
{
if($i%2 == 0)
echo "<tr>";
?>
<td align="left"><?php echo $row['name'];?></td>
<td align="left"><?php echo $row['contact'];?></td>
<?php
if($i%2 == 0)
echo "</tr>";
}?>
Its the appropriate way..
<table>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
<tr>
<?php
foreach($rowset as $i=>$row) {
if($i!=0 && $i%2 == 0) {
?>
</tr><tr>
<?php } ?>
<td align="left"><?php echo $row['name'];?></td>
<td align="left"><?php echo $row['contact'];?></td>
<?php } ?>
</tr>
</table>
First connect to database using: $con = mysql_connect(host,username,password);
Select Database : mysql_select_db(dbname,$con);
Write a query: $qselect = mysql_query("select * from mytable");
Now Let's start displaying in a HTML Table:
<table>
<tr>
<th>Name</th>
<th>Address</th>
</tr>
<?php
while($result = mysql_fetch_array($qselect))
{
extract($result);
?>
<tr>
<td><?= $name?></td>
<td><?= $addr?></td>
</tr>
<?php
}
?>
</table>
Note: $name and $addr are field names from mysql table.

mysql results error on php

hello below is my code for a query with submit from.. the no of rows are correctly count and show in the page and the result rows are not show in my page and show "No results found, please search again", i cant find the error on my code, can anyone help to find it..
<?
### DEBUG
$debugP = 0 ;
### END DEBUG
include 'db_connector.php';
require_once('myfunctions.php');
include('header.php');
#defauts
$maxRows_p = 10;
$pageNum_p = 0;
if (isset($_GET['pageNum_p'])) {
$pageNum_p = $_GET['pageNum_p'];
}
$startRow_p = $pageNum_p * $maxRows_p;
$limit = ' LIMIT '.$startRow_p.', '.$maxRows_p;
## Start building sql for GET varables for advanced search
###Add city
if(isset($_REQUEST['city']) && ($_REQUEST['city'] != ''))
$search[] = ' city = "'.$_REQUEST['city'].'"';
###Add State
if(isset($_REQUEST['district']) && ($_REQUEST['district'] != ''))
$search[] = ' district = "'.$_REQUEST['district'].'"';
###Add lot size
if(isset($_REQUEST['lot_size']) && ($_REQUEST['lot_size'] != ''))
$search[] = ' perches >= '.$_REQUEST['lot_size'];
$search[] = ' availibility = "0" ';
###implode to search string on ' and ';
$searchStr = #implode(' and ',$search);
$sql = 'select * FROM properties WHERE status="1" and'; ###status=1 and
$sql .= $searchStr;
###Add column sorting
if($_REQUEST['sort'] != '')
$sort = ' order by added asc ';
else
$sort = $_REQUEST['sort'];
### DEBUG
if($debugP) echo 'Advanced Search Sql<hr>'.$sql;
$error['Results'] = 'No results found, please search again';
###}
### Finished Building search sql and execting #####
$sql_with_limit = $sql . $sort . $limit;
if($debugP)
echo "<hr>Property Search with Limit SQL: $sql_with_limit";
###Perform search
$searchResults = mysql_query($sql.$sql_with_limit);
### BUILD OUTPUT ####
if (isset($_GET['totalRows_p'])) {
$totalRows_p = $_GET['totalRows_p'];
} else {
if($debugP)
echo "<hr>Property with out limit SQL: $sql $sort";
$all_p = mysql_query($sql.$sort);
$totalRows_p = mysql_num_rows($all_p);
if($debugP)
echo "<br>Result Rows $totalRows_p";
}
$totalPages_p = ceil($totalRows_p/$maxRows_p)-1;
if($debugP)
echo "<hr>Builting Query String for Limit: ";
###Build query string
foreach($_GET as $name => $value){
if($name != "pageNum_p")
$queryString_p .= "&$name=$value";
}
if($debugP)
echo $queryString_p;
?>
<div align="left" class="locText">Home<span class="locArrow"> > </span> Search Results</div>
<hr size="1" color="#666666">
<table border="0" align="center">
<tr>
<td align="center">
<?php if ($pageNum_p > 0) { ### Show if not first page ?>
< href="<?php printf("%s?pageNum_p=%d%s", $currentPage, 0, $queryString_p); ?>" class="pageLink">First</a> |
<?php } ### Show if not first page ?>
<?php if ($pageNum_p > 0) { ### Show if not first page ?>
< href="<?php printf("%s?pageNum_p=%d%s", $currentPage, max(0, $pageNum_p - 1), $queryString_p); ?>" class="pageLink">Previous</a> |
<?php } ### Show if not first page ?>
<?php if ($pageNum_p < $totalPages_p) { ### Show if not last page ?>
< href="<?php printf("%s?pageNum_p=%d%s", $currentPage, min($totalPages_p, $pageNum_p + 1), $queryString_p); ?>" class="pageLink">Next</a> |
<?php } ### Show if not last page ?>
<?php if ($pageNum_p < $totalPages_p) { ### Show if not last page ?>
< href="<?php printf("%s?pageNum_p=%d%s", $currentPage, $totalPages_p, $queryString_p); ?>" class="pageLink">Last</a>
<?php } ### Show if not last page ?>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="pageText" >Showing: <strong><?php echo ($startRow_p + 1) ?> to <?php echo min($startRow_p + $maxRows_p, $totalRows_p) ?> of <?php echo $totalRows_p ?></strong> Listings</td>
<td align="right" class="pageText"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="5">xx</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="4" class="resBorder">
<tr>
<td class="colText">Address</td>
<td class="colText">City</td>
<td class="colText">ST</td>
<td class="colText">Price</td>
<td class="colText">Beds</td>
<td class="colText">Baths</td>
<td class="colText">Sqft</td>
</tr>
<?php while($row_p = #mysql_fetch_assoc($searchResults)) { ?>
<tr valign="top">
<td class="bodytext"><?php echo $row_p['address']; ?></td>
<td class="bodytext"><?php echo $row_p['city']; ?></td>
<td class="bodytext"><?php echo $row_p['district']; ?></td>
<td class="bodytext"><?php echo Money($row_p['price'],1); ?></td>
<td class="bodytext"><?php echo $row_p['rooms']; ?></td>
<td class="bodytext"> </td>
<td class="bodytext"><?php echo $row_p['floor']; ?></td>
</tr>
</table></td>
</tr>
<? } ?>
</table></td>
</tr>
<tr>
<td height="5">xx</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="pageText"> </td>
<td align="right"></td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
<?
## if no results where found
if(#mysql_num_rows($searchResults)<=0){
foreach($error as $name => $value)
print '<div align=center class="error">'.$name . ': ' . $value.'</div>';
}
##Fetch Footer
?>
<script>
document.getElementById('loading').style.display = 'none';
</script>
Try changing:
###Perform search
$searchResults = mysql_query($sql.$sql_with_limit);
To:
###Perform search
$searchResults = mysql_query($sql_with_limit);

Categories