Unstoppable Domains

Undefine $Php_self Help!!

Spaceship Spaceship
Watch

cotton

Established Member
Impact
0
i've added the $_SERVER['php_self'] but it still displayed the message undefine $php_self. i want to implement the pagination code but it failed. i would be very glad if someone could help me to solve this problem.here is the sample of my code.

<?


mysql_connect("localhost","root",""); //(host, username, password)

//specify database ** EDIT REQUIRED HERE **
mysql_select_db("e-library") or die("Unable to select database"); //select which database we're using

$search = isset($_GET['search'])? $_GET['search']:"" ;

$group = isset($_GET['group'])? $_GET['group']:"";

$limit=10;
$count = 1;
if ($search == "")
{
$query = "select * from book"; // EDIT HERE and specify your table and field names for the SQL query

}
if ($search != "" && $group == "all")
{
$query = "select * from book where author like '%$search%' or category like '%$search%' or edition like '%$search%' or ISBN like '%$search%' or publisher like '%$search%' or title like '%$search%' or year like '%$search%'"; // EDIT HERE and specify your table and field names for the SQL query
}

if($search != "" && $group == "author")
{
$query = "select * from book where author like '%$search%'";
}
if($search != "" && $group == "category")
{
$query = "select * from book where category like '%$search%'";
}
if($search != "" && $group == "edition")
{
$query = "select * from book where edition like '%$search%'";
}
if($search != "" && $group == "ISBN")
{
$query = "select * from book where ISBN like '%$search%'";
}
if($search != "" && $group == "publisher")
{
$query = "select * from book where publisher like '%$search%'";
}
if($search != "" && $group == "title")
{
$query = "select * from book where title like '%$search%'";
}
if($search != "" && $group == "year")
{
$query = "select * from book where year like '%$search%'";
}
$numresults=mysql_query($query) or die("x tahu");
$numrows=mysql_num_rows($numresults);


// If we have no results, offer a google search as an alternative

if ($numrows == 0)
{
echo "<tr><td>";
echo "<h4>Results</h4>";
echo "<p>Sorry,the data are not in database</p>";
echo "</td></tr>";
}
else
{
if (empty($s)) {
$s=0;
}

// get results
$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");

// display what the person searched for

$count = 1 + $s ;

// now you can display the results returned
while ($row= mysql_fetch_array($result))
{
$title = $row['title'];
$ISBN = $row['ISBN'];
$abstract = $row['description'];
echo "$count. <a href=\"View_Book.php?ref=$ISBN\">$title</a>" ;
?>
<img src="Image/nw2.gif" onclick="MM_openBrWindow('View_Book.php?ref=<? echo $ISBN;?>','','')" >
<?
echo "<br>";
echo myfragment($abstract, 150);
echo "<br>";
echo "<br>";

$count++ ;
}

$currPage = (($s/$limit) + 1);

//break before paging
echo "<br />";

// next we need to do the links to other results
if ($s>=1) { // bypass PREV link if s is 0
$prevs=($s-$limit);
print " <a href=\"".$_SERVER['$PHP_SELF']."?s=$prevs&search=$search&group=$group\"><<
Prev</a>&nbsp ";
}

// calculate number of pages needing links
$pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a remainder from division

if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}

// check to see if last page
if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

// not last page so give NEXT link
$news=$s+$limit;

echo " <a href=\"".$_SERVER['$PHP_SELF']."?s=$news&search=$search&group=$group\">Next>></a>";
}

$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Showing results $b to $a of $numrows</p>";
echo "<br> "; }?></td>





thanks in advance..
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
cotton said:
i've added the $_SERVER['php_self'] but it still displayed the message undefine $php_self.

shouldnt that be $_SERVER[’PHP_SELF’] <--- in your code and not $_SERVER['$PHP_SELF']?
 
0
•••
nope..the code is supposed to be right.. $_SERVER['PHP_SELF']...be it displayed error msg undefined.
 
0
•••
yep but in your code you have $ before PHP_SELF
 
0
•••
oh yes...what a careless mistake..haha..thanks..but unfortunately..im still unable to link it to the next page..my pagination code won't work..huhuhu..

my code is finally functioning...thnks all

how can i add the data to thesis table with if else statements by adding it to the code below? it means there are 3 tables involve. i managed to get from 2 tables such as below only.pls help..

while($row = mysql_fetch_array($result))
{
?>
<tr>
<td>
<div align="center"><? echo $count?>. </div></td>
<td>
<div align="center">
<?
$idno = $row['idno'];
$query3 = "SELECT name from user where idno = '$idno'";
$result3 = mysql_query($query3) or die("x jadi");
$row3 = mysql_fetch_array($result3);
echo $row3['name'];

?>
</div></td>
<td>
<div align="center"><? echo $row['type'];?> </div></td>
<td>
<div align="center">
<? $source = $row['sourceid'];
$query1 = "SELECT title from book where ISBN = '$source'";
$result1 = mysql_query($query1) or die("try");
if(!$row1 = mysql_fetch_assoc($result1))
{
$query2 = "SELECT title from cd where id = '$source'";
$result2 = mysql_query($query2) or die("x jadi");
$row2 = mysql_fetch_array($result2);
echo $row2['title'];
}
else
{
echo $row1['title'];
}?>
 
0
•••
Moved to Programming.
 
0
•••
Try using $PHP_SELF instead.
 
0
•••
JRBHosting said:
Try using $PHP_SELF instead.
That was already fixed. His latest reply was a new problem.
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back