0

Hi everyone, i am building book store, i am thinking about to create a single page who fetch a record from MYSQL on the basis of Book_ID instead of create each product detail page. when some click on detail button it passes book_id to another page where i write a function which get book detail on basis of book_id and show this information through html. i use form submit button to pass book_id to another page. but when i set value in submit button is shows book_id on the page instead of detail. there another way to complete my target ???
here is the code but it is not working as i required.

$con = mysql_connect(server , userName , password ) or die('DataBase cannot connect. Reason: ' . mysql_errno());

mysql_select_db('tnc') or die('Table cannot connect. ' . mysql_errno());

$sql = "SELECT * From publications 
        WHERE Title LIKE '%Sales Tax Act%'
        order by Amended DESC 
        LIMIT $gid, $imgPerPage;";

$result = mysql_query($sql, $con) or die('Query Error. ' . mysql_errno());

while($row = mysql_fetch_array($result))
{
    $output =  "<div id='bookContainer'>";
    $output .= "<div id='bookImg'><img src='".$row["imgUrl"]."'/> </div>";
    $output .= "<div id='bookTitle'>" . $row["Title"] . "</div>";
    $output .= "<div id='bookInfo'> Emended Upto ". $row["Amended"] ."</div>";
    $output .= "<div id='bookPrice'> Price: Rs.  " . $row["Price"] . "</div>";
    $output .= "<div id='bookDetail'><form action='adminScripts/getBookDetail.php' method='post'><input type='submit' value='Detail' name='" . $row["Book_ID"] ."' /></form></div>";
    $output .= "</div>";
    $output .= "<hr />";

    echo ($output);
    }
2
Contributors
2
Replies
5
Views
5 Years
Discussion Span
Last Post by aneeqtariq_143
0

You have to place a hidden field with Book_ID as a value. Or you can use submit button to place Book_ID value there
Example:
$output .= "<div id='bookDetail'><form action='adminScripts/getBookDetail.php' method='post'><input type='submit' value='Detail' name='btn_submit' /><input type='hidden' name='book_id' value='".$row["Book_ID"] ."'</form></div>";

Or:
$output .= "<div id='bookDetail'><form action='adminScripts/getBookDetail.php' method='post'><input type='submit' name='book_id' value='" . $row["Book_ID"] ."' /></form></div>";

Then on the page you submit to, you can get the value:

$value=$_POST['book_id'];

Or you can try using the GET parameter instead.

Just place a link on the begining page, something like this: <a href="page_b.php?book_id=<?=$row["Book_ID"];?>">View detail</a>

page_b.phh page shold have:

$value=$_GET['book_id'];

Good luck.

Edited by Ezzaral: Snipped promotional link. Please don't refer to sites you are affiliated with.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.