查看: 1358|回复: 7
|
php link problem
[复制链接]
|
|
下面是 interface, when i click accounting 1, it should link to book.php and display the detail info about the book. The Problem is when i click the link , it link to book.php but didn't display the detail info
can anyone tell me wat wrong in my coding i'm blur edi
TITLE ISBN AUTHOR PUBLISHER
Accounting 1 56-23-12 Jimmy Roy MC-HILL
Accounting 2 56-23-12 Jimmy Roy MC-HILL
Accounting 3 56-23-12 Jimmy Roy MC-HILL
Bussiness In Your Hand 52-13-30 Kenny Yan Liverpool
Statics of Business 36-00-16 Norman Uken Rk Yok
Previous Page Next Page
This is the coding
--------------------------------------------------------------------------
main.php
<?php
mysql_connect("localhost","root","1234");
mysql_select_db("book");
$pn=5;
$aa="select * from accounting";
$bb=mysql_query($aa);
$num=mysql_num_rows($bb);
$pages=intval($num/$pn)+1;
if($page>$pages)
{
$page=$pages;
}
if($page<1)
{
$page=1;
}
$pagen=($page-1)*$pn;
$aa="select * from accounting limit $pagen,$pn";
$bb=mysql_query($aa);
echo"<table width=100% border=1>";
echo"<tr><td>TITLE<td>ISBN<td>AUTHOR<td>PUBLISHER</tr>";
/*while($cc=mysql_fetch_row($bb))*/
while(list($a0,$a1,$a2,$a3)=mysql_fetch_row($bb))
{
echo"<tr>
<td><a href=book.php?pk=$a0>$a0</a></td>
<td>$a1</td>
<td>$a2</td>
<td>$a3</td>
</tr>
";
}
echo"</table>";
if($page>1)
{
$p1=$page-1;
}
else
{
$p1=1;
}
if($page<$pages)
{
$p2=$page+1;
}
else
{
$p2=$page;
}
/*$num=mysql_num_rows($bb);
echo"<p>Total Record was $num";*/
echo"
<p align=center>
<a href=try3.php?page=$p1>Previous Page</a>
<a href=try3.php?page=$p2>Next Page</a>";
?>
---------------------------------------------------------------------------
book.php
<?php
mysql_connect("localhost","root","1234");
mysql_select_db("book");
$aa="select * from accounting where title='$pk'";
$bb=mysql_query($aa);
list($a0,$a1,$a2,$a3,$a4)=mysql_fetch_row($bb);
echo"<table width=100% border=1>";
echo"<tr>
<td>TITLE<td>$a0</tr>
<tr><td>ISBN<td>$a1</tr>
<tr><td>AUTHOR<td>$a2</tr>
<tr><td>PUBLISHER<td>$a3</tr>
<tr><td>CONTENT<td>$a4</tr>";
echo"</table>";
?>
---------------------------------------------------------------------------
[ 本帖最后由 html 于 13-8-2006 01:08 PM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 13-8-2006 07:50 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 13-8-2006 09:35 PM
|
显示全部楼层
很容易,问题在你的book.php里。
你的$pk是如何来的呢??
$pk = $_GET['pk'];
$aa="select * from accounting where title='$pk'";
$bb=mysql_query($aa);
还有make sure你的$a0有value的。 |
|
|
|
|
|
|
|

楼主 |
发表于 13-8-2006 09:57 PM
|
显示全部楼层
原帖由 红发 于 13-8-2006 09:35 PM 发表
很容易,问题在你的book.php里。
你的$pk是如何来的呢??
$pk = $_GET;
$aa="select * from accounting where title='$pk'";
$bb=mysql_query($aa);
还有make sure你的$a0有value的。
of course my database has a value..
my $pk is come from main.php
<td><a href=book.php?pk=$a0>$a0</a></td>
i set pk=$a0 because $a0 store the title of the book , so i can 透过 $pk varible to get my record..
i had try ur coding but still cannot slove the problem.. |
|
|
|
|
|
|
|
发表于 14-8-2006 01:57 AM
|
显示全部楼层
$pk = $_GET['pk'];
$aa="select * from accounting where title='".$pk."'";
$bb=mysql_query($aa);
try this! replace the "sql" and add the "$pk = $_GET['pk']" |
|
|
|
|
|
|
|

楼主 |
发表于 14-8-2006 10:52 AM
|
显示全部楼层
Yeh , i Slove the problem lah....
thanks 红发 n keat8303
can i ask 2 questions
$pk = $_GET['pk']; <---- wht the function of this statement
$aa="select * from accounting where no='".$pk."'"; <---- why put ".xx."
[ 本帖最后由 html 于 14-8-2006 11:00 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 14-8-2006 12:23 PM
|
显示全部楼层
$pk = $_GET['pk'];
是要把你pass 过来的名字放进$pk里, 不然$pk就等於空
$aa="select * from accounting where no='".$pk."'
那两点的意思跟java的+,ASP的&,一样。用来把STRING和VARIABLE连起来 |
|
|
|
|
|
|
|

楼主 |
发表于 14-8-2006 06:06 PM
|
显示全部楼层
原帖由 keat8303 于 14-8-2006 12:23 PM 发表
$pk = $_GET;
是要把你pass 过来的名字放进$pk里, 不然$pk就等於空
$aa="select * from accounting where no='".$pk."'
那两点的意思跟java的+,ASP的&,一样。用来把STRING和VARIABLE ...
thanks   |
|
|
|
|
|
|
| |
本周最热论坛帖子
|