Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
hi,
I appreciate all help on the following issue,
I have a problem when trying to pass a value to another page, at the other page
i want to display data from that value.
this is my search.php pageCode: Select all
<html>
<head>
<table>
<tr>
<td colspan="7" valign="top"><p align="center"><span class="style12">CARIAN PELAJAR </span></p>
<form id = "" name="form" method="get" action="" onSubmit="">
<table width="100%" id="" >
<tr bgcolor=>
<td bgcolor="#30669A"><div align="center" class="style3">Sila Masukkan Nama Pelajar</div></td>
</tr>
<tr bgcolor="#EEEEEE">
<td width="23%"><p align="center"> </p>
<p align="center"><span class="style13">Nama Pelajar</span>
<input type="text" name="nama" maxlength="12" value="">
<input type="submit" name="submit" value="Cari">
</p>
<p align="center"> </p></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<tr bgcolor="#EEEEEE">
<td>
<?php
// Get the search variable from URL
$var = $_GET['nama'] ; //before editing @$_GET['nama']
$trimmed = trim($var); //trim whitespace from the stored variable
// rows to return
$limit=10;
// check for an empty string and display a message.
if ($trimmed == "")
{
echo "<p></p>";
exit;
}
// check for a search parameter
if (!isset($var))
{
echo "<p>We dont seem to have a search parameter!</p>";
exit;
}
//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("10.21.7.91","root",""); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db("sila") or die("Unable to select database"); //select which database we're using
// Build SQL Query
$query = "select bank_userid, bank_nokp from bank where bank_nokp like \"%$trimmed%\" ";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0)
{
echo "<h4>Results</h4>";
echo "<p>Maaf, Tiada Maklumat Untuk "" . $trimmed . "" </p>";
// google
echo "<p><a href=\"http://www.google.com/search?nama="
. $trimmed . "\" target=\"_blank\" title=\"Look up
" . $trimmed . " on Google\">Klik Di Sini</a> Untuk Membuat Carian Pada Google</p>";
}
// next determine if s has been passed to script, if not use 0
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
echo "<p>Carian Anda Untuk: "" . $var . ""</p>";
// begin to show results set
echo "<b>Keputusan Carian</b><br></br>";
echo "<font color='red'>Sila Klik Pada Nama Untuk Paparan Maklumat Pelajar<br></font>";
$count = 1 + $s ;
/*{
// Display them to the screen...
echo "<a href=\"" . $row["link"] . "\">
<img src=\"" . $row["image"] . "\" border=0 alt=\"" . $row["text"] . "\">
</a>" ;
}*/
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$title = $row["bank_userid"];
$title2 = $row["bank_nokp"];
echo "<br>$count. $title || $title2" ;
echo "<a href = 'maklumat_bank.php?&nama=$title' target = '_self'><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=\"$PHP_SELF?s=$prevs&nama=$var\"><<
Prev 10</a>  ";
}
// 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=\"$PHP_SELF?s=$news&nama=$var\">Next 10 >></a>";
}
$a = $s + ($limit) ;
if ($a > $numrows) { $a = $numrows ; }
$b = $s + 1 ;
echo "<p>Paparan Carian $b hingga $a daripada $numrows</p>";
?> </td>
</tr>
<tr>
<td>
<hr></td>
</tr>
</table>
</form>
</table>
</body>
</center>
</html>feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]