php not returning any echo











up vote
-1
down vote

favorite












I have a table which Displays the book list from mysql Database and search form where user can search books.
I"m looking forward to show the book list as per title and author when user search for by input value of title and author and display " NO Books by name or author" as echo when there is no any record.



My code is






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<a href="searchform.php" class="btn btn-primary">Go Back</a>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>
<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>

</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>

</body>
</html>
<br>







My Search form is






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">

<form action = "DisplayBooks.php" method="get">
<br>
<center>Enter the title of the book to be searched :
<input type="text" name="search" size="48">
<br></br>
<input type="submit" value="submit">
<input type="reset" value="Reset">
</center>
<br>
</form>
</body>
</html>





But it sucessfully displays list of books but when there is no any record ..it don't launch echo.



ps. How can I add link button such that it shows Back to search results to navigate user to Searchform and user can go back to previous form.










share|improve this question
























  • This is open to SQL injection. Use a prepared statement if you value the time and effort you've put into this. We wouldn't want you to have your database compromised and possibly deleted.
    – Funk Forty Niner
    Nov 22 at 4:31












  • @FunkFortyNiner no it is just test it won't matter ....echo problems has been solved thanks to Delwar but I want to add button to go back to Serchform from results....that is only I"m not getting.
    – redface
    Nov 22 at 4:35















up vote
-1
down vote

favorite












I have a table which Displays the book list from mysql Database and search form where user can search books.
I"m looking forward to show the book list as per title and author when user search for by input value of title and author and display " NO Books by name or author" as echo when there is no any record.



My code is






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<a href="searchform.php" class="btn btn-primary">Go Back</a>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>
<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>

</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>

</body>
</html>
<br>







My Search form is






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">

<form action = "DisplayBooks.php" method="get">
<br>
<center>Enter the title of the book to be searched :
<input type="text" name="search" size="48">
<br></br>
<input type="submit" value="submit">
<input type="reset" value="Reset">
</center>
<br>
</form>
</body>
</html>





But it sucessfully displays list of books but when there is no any record ..it don't launch echo.



ps. How can I add link button such that it shows Back to search results to navigate user to Searchform and user can go back to previous form.










share|improve this question
























  • This is open to SQL injection. Use a prepared statement if you value the time and effort you've put into this. We wouldn't want you to have your database compromised and possibly deleted.
    – Funk Forty Niner
    Nov 22 at 4:31












  • @FunkFortyNiner no it is just test it won't matter ....echo problems has been solved thanks to Delwar but I want to add button to go back to Serchform from results....that is only I"m not getting.
    – redface
    Nov 22 at 4:35













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a table which Displays the book list from mysql Database and search form where user can search books.
I"m looking forward to show the book list as per title and author when user search for by input value of title and author and display " NO Books by name or author" as echo when there is no any record.



My code is






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<a href="searchform.php" class="btn btn-primary">Go Back</a>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>
<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>

</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>

</body>
</html>
<br>







My Search form is






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">

<form action = "DisplayBooks.php" method="get">
<br>
<center>Enter the title of the book to be searched :
<input type="text" name="search" size="48">
<br></br>
<input type="submit" value="submit">
<input type="reset" value="Reset">
</center>
<br>
</form>
</body>
</html>





But it sucessfully displays list of books but when there is no any record ..it don't launch echo.



ps. How can I add link button such that it shows Back to search results to navigate user to Searchform and user can go back to previous form.










share|improve this question















I have a table which Displays the book list from mysql Database and search form where user can search books.
I"m looking forward to show the book list as per title and author when user search for by input value of title and author and display " NO Books by name or author" as echo when there is no any record.



My code is






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<a href="searchform.php" class="btn btn-primary">Go Back</a>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>
<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>

</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>

</body>
</html>
<br>







My Search form is






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">

<form action = "DisplayBooks.php" method="get">
<br>
<center>Enter the title of the book to be searched :
<input type="text" name="search" size="48">
<br></br>
<input type="submit" value="submit">
<input type="reset" value="Reset">
</center>
<br>
</form>
</body>
</html>





But it sucessfully displays list of books but when there is no any record ..it don't launch echo.



ps. How can I add link button such that it shows Back to search results to navigate user to Searchform and user can go back to previous form.






<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<a href="searchform.php" class="btn btn-primary">Go Back</a>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>
<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>

</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>

</body>
</html>
<br>





<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<a href="searchform.php" class="btn btn-primary">Go Back</a>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>
<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>

</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>

</body>
</html>
<br>





<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">

<form action = "DisplayBooks.php" method="get">
<br>
<center>Enter the title of the book to be searched :
<input type="text" name="search" size="48">
<br></br>
<input type="submit" value="submit">
<input type="reset" value="Reset">
</center>
<br>
</form>
</body>
</html>





<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">

<form action = "DisplayBooks.php" method="get">
<br>
<center>Enter the title of the book to be searched :
<input type="text" name="search" size="48">
<br></br>
<input type="submit" value="submit">
<input type="reset" value="Reset">
</center>
<br>
</form>
</body>
</html>






php mysql forms mysqli






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 4:31









Funk Forty Niner

80.5k1247100




80.5k1247100










asked Nov 22 at 3:38









redface

226




226












  • This is open to SQL injection. Use a prepared statement if you value the time and effort you've put into this. We wouldn't want you to have your database compromised and possibly deleted.
    – Funk Forty Niner
    Nov 22 at 4:31












  • @FunkFortyNiner no it is just test it won't matter ....echo problems has been solved thanks to Delwar but I want to add button to go back to Serchform from results....that is only I"m not getting.
    – redface
    Nov 22 at 4:35


















  • This is open to SQL injection. Use a prepared statement if you value the time and effort you've put into this. We wouldn't want you to have your database compromised and possibly deleted.
    – Funk Forty Niner
    Nov 22 at 4:31












  • @FunkFortyNiner no it is just test it won't matter ....echo problems has been solved thanks to Delwar but I want to add button to go back to Serchform from results....that is only I"m not getting.
    – redface
    Nov 22 at 4:35
















This is open to SQL injection. Use a prepared statement if you value the time and effort you've put into this. We wouldn't want you to have your database compromised and possibly deleted.
– Funk Forty Niner
Nov 22 at 4:31






This is open to SQL injection. Use a prepared statement if you value the time and effort you've put into this. We wouldn't want you to have your database compromised and possibly deleted.
– Funk Forty Niner
Nov 22 at 4:31














@FunkFortyNiner no it is just test it won't matter ....echo problems has been solved thanks to Delwar but I want to add button to go back to Serchform from results....that is only I"m not getting.
– redface
Nov 22 at 4:35




@FunkFortyNiner no it is just test it won't matter ....echo problems has been solved thanks to Delwar but I want to add button to go back to Serchform from results....that is only I"m not getting.
– redface
Nov 22 at 4:35












2 Answers
2






active

oldest

votes

















up vote
-1
down vote



accepted










Try This:



<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>

<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>
</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>
</body>
</html>
<br>





share|improve this answer





















  • ok it works..lastly One question How can I add link such that whether it displays book result or echo ..there will be a BUtton with Go back to search and when user click it will navigate back to search form. any help?
    – redface
    Nov 22 at 4:11










  • You can add anchor tag anywhere in showing result page.... Like this -> <a href="search page link" class="btn btn-primary">Go Back</a> ...btn btn-primary -> Basically this classes are design of button in bootstrap
    – Delwar Sumon
    Nov 22 at 4:15












  • Umm but I have to add in displayBooks.php form which will show even when no search is made....I only want to show it when user goes to serchform and when click on submit button then it will open Displaybooks form only with books that match the result and also show the link to go back to search form again similar to echo which displays when only search is made in displaybooks form...!!
    – redface
    Nov 22 at 4:19












  • <a href="searchform.php" class="btn btn-primary">Go Back</a>....add this to displayBooks.php up on the table.
    – Delwar Sumon
    Nov 22 at 4:24










  • Please tell everyone by editing your answer to tell us what exactly it is you did to solve the question. It makes it very hard to compare between both the OP's code and the answer here.
    – Funk Forty Niner
    Nov 22 at 4:30


















up vote
1
down vote













You have duplicated your check for "no results":



if(mysqli_num_rows($result)>0)if(mysqli_num_rows($result)>0)


Remove one.






share|improve this answer





















  • This answer was entirely clear and IMHO, should have been the accepted answer. The other one being a "Try this", was hard for me to compare what it was exactly they did to deserve it being accepted/awarded. For all I know, there could have been more things wrong with the OP's code.
    – Funk Forty Niner
    Nov 22 at 4:29










  • "surely such a mysterious problem has a more complex solution" - non-experts
    – Joni
    Nov 22 at 16:09











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423536%2fphp-not-returning-any-echo%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
-1
down vote



accepted










Try This:



<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>

<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>
</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>
</body>
</html>
<br>





share|improve this answer





















  • ok it works..lastly One question How can I add link such that whether it displays book result or echo ..there will be a BUtton with Go back to search and when user click it will navigate back to search form. any help?
    – redface
    Nov 22 at 4:11










  • You can add anchor tag anywhere in showing result page.... Like this -> <a href="search page link" class="btn btn-primary">Go Back</a> ...btn btn-primary -> Basically this classes are design of button in bootstrap
    – Delwar Sumon
    Nov 22 at 4:15












  • Umm but I have to add in displayBooks.php form which will show even when no search is made....I only want to show it when user goes to serchform and when click on submit button then it will open Displaybooks form only with books that match the result and also show the link to go back to search form again similar to echo which displays when only search is made in displaybooks form...!!
    – redface
    Nov 22 at 4:19












  • <a href="searchform.php" class="btn btn-primary">Go Back</a>....add this to displayBooks.php up on the table.
    – Delwar Sumon
    Nov 22 at 4:24










  • Please tell everyone by editing your answer to tell us what exactly it is you did to solve the question. It makes it very hard to compare between both the OP's code and the answer here.
    – Funk Forty Niner
    Nov 22 at 4:30















up vote
-1
down vote



accepted










Try This:



<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>

<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>
</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>
</body>
</html>
<br>





share|improve this answer





















  • ok it works..lastly One question How can I add link such that whether it displays book result or echo ..there will be a BUtton with Go back to search and when user click it will navigate back to search form. any help?
    – redface
    Nov 22 at 4:11










  • You can add anchor tag anywhere in showing result page.... Like this -> <a href="search page link" class="btn btn-primary">Go Back</a> ...btn btn-primary -> Basically this classes are design of button in bootstrap
    – Delwar Sumon
    Nov 22 at 4:15












  • Umm but I have to add in displayBooks.php form which will show even when no search is made....I only want to show it when user goes to serchform and when click on submit button then it will open Displaybooks form only with books that match the result and also show the link to go back to search form again similar to echo which displays when only search is made in displaybooks form...!!
    – redface
    Nov 22 at 4:19












  • <a href="searchform.php" class="btn btn-primary">Go Back</a>....add this to displayBooks.php up on the table.
    – Delwar Sumon
    Nov 22 at 4:24










  • Please tell everyone by editing your answer to tell us what exactly it is you did to solve the question. It makes it very hard to compare between both the OP's code and the answer here.
    – Funk Forty Niner
    Nov 22 at 4:30













up vote
-1
down vote



accepted







up vote
-1
down vote



accepted






Try This:



<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>

<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>
</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>
</body>
</html>
<br>





share|improve this answer












Try This:



<!DOCTYPE HTML>
<html>
<body bgcolor="87ceeb">
<center><h2>Central Department of Physics</h2></center>
<br>
<?php
include("DBConnection.php");
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : '';

$query = "select ISBN,Title,Author,Edition,Publication from book_info where author like '%$search%' or title like '%$search%'";
//search with a book name in the table book_info
$result = mysqli_query($db,$query);


?>
<table border="2" align="center" cellpadding="5" cellspacing="5">
<tr>
<th> ISBN </th>
<th> Title </th>
<th> Author </th>
<th> Edition </th>
<th> Publication </th>
</tr>
<?php
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_assoc($result))
{
?>
<tr>

<td><?php echo $row["ISBN"];?> </td>
<td><?php echo $row["Title"];?> </td>
<td><?php echo $row["Author"];?> </td>
<td><?php echo $row["Edition"];?> </td>

<td><a href="<?php echo $row["Publication"];?>" target="_blank">Click Me</a></td>
</tr>

<?php

}

}
else{ ?>
<tr>
<td colspan="5">
<center>No books found in the library by the name $search </center>
</td>
</tr>

<?php } ?>
</table>
</body>
</html>
<br>






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 at 3:53









Delwar Sumon

373112




373112












  • ok it works..lastly One question How can I add link such that whether it displays book result or echo ..there will be a BUtton with Go back to search and when user click it will navigate back to search form. any help?
    – redface
    Nov 22 at 4:11










  • You can add anchor tag anywhere in showing result page.... Like this -> <a href="search page link" class="btn btn-primary">Go Back</a> ...btn btn-primary -> Basically this classes are design of button in bootstrap
    – Delwar Sumon
    Nov 22 at 4:15












  • Umm but I have to add in displayBooks.php form which will show even when no search is made....I only want to show it when user goes to serchform and when click on submit button then it will open Displaybooks form only with books that match the result and also show the link to go back to search form again similar to echo which displays when only search is made in displaybooks form...!!
    – redface
    Nov 22 at 4:19












  • <a href="searchform.php" class="btn btn-primary">Go Back</a>....add this to displayBooks.php up on the table.
    – Delwar Sumon
    Nov 22 at 4:24










  • Please tell everyone by editing your answer to tell us what exactly it is you did to solve the question. It makes it very hard to compare between both the OP's code and the answer here.
    – Funk Forty Niner
    Nov 22 at 4:30


















  • ok it works..lastly One question How can I add link such that whether it displays book result or echo ..there will be a BUtton with Go back to search and when user click it will navigate back to search form. any help?
    – redface
    Nov 22 at 4:11










  • You can add anchor tag anywhere in showing result page.... Like this -> <a href="search page link" class="btn btn-primary">Go Back</a> ...btn btn-primary -> Basically this classes are design of button in bootstrap
    – Delwar Sumon
    Nov 22 at 4:15












  • Umm but I have to add in displayBooks.php form which will show even when no search is made....I only want to show it when user goes to serchform and when click on submit button then it will open Displaybooks form only with books that match the result and also show the link to go back to search form again similar to echo which displays when only search is made in displaybooks form...!!
    – redface
    Nov 22 at 4:19












  • <a href="searchform.php" class="btn btn-primary">Go Back</a>....add this to displayBooks.php up on the table.
    – Delwar Sumon
    Nov 22 at 4:24










  • Please tell everyone by editing your answer to tell us what exactly it is you did to solve the question. It makes it very hard to compare between both the OP's code and the answer here.
    – Funk Forty Niner
    Nov 22 at 4:30
















ok it works..lastly One question How can I add link such that whether it displays book result or echo ..there will be a BUtton with Go back to search and when user click it will navigate back to search form. any help?
– redface
Nov 22 at 4:11




ok it works..lastly One question How can I add link such that whether it displays book result or echo ..there will be a BUtton with Go back to search and when user click it will navigate back to search form. any help?
– redface
Nov 22 at 4:11












You can add anchor tag anywhere in showing result page.... Like this -> <a href="search page link" class="btn btn-primary">Go Back</a> ...btn btn-primary -> Basically this classes are design of button in bootstrap
– Delwar Sumon
Nov 22 at 4:15






You can add anchor tag anywhere in showing result page.... Like this -> <a href="search page link" class="btn btn-primary">Go Back</a> ...btn btn-primary -> Basically this classes are design of button in bootstrap
– Delwar Sumon
Nov 22 at 4:15














Umm but I have to add in displayBooks.php form which will show even when no search is made....I only want to show it when user goes to serchform and when click on submit button then it will open Displaybooks form only with books that match the result and also show the link to go back to search form again similar to echo which displays when only search is made in displaybooks form...!!
– redface
Nov 22 at 4:19






Umm but I have to add in displayBooks.php form which will show even when no search is made....I only want to show it when user goes to serchform and when click on submit button then it will open Displaybooks form only with books that match the result and also show the link to go back to search form again similar to echo which displays when only search is made in displaybooks form...!!
– redface
Nov 22 at 4:19














<a href="searchform.php" class="btn btn-primary">Go Back</a>....add this to displayBooks.php up on the table.
– Delwar Sumon
Nov 22 at 4:24




<a href="searchform.php" class="btn btn-primary">Go Back</a>....add this to displayBooks.php up on the table.
– Delwar Sumon
Nov 22 at 4:24












Please tell everyone by editing your answer to tell us what exactly it is you did to solve the question. It makes it very hard to compare between both the OP's code and the answer here.
– Funk Forty Niner
Nov 22 at 4:30




Please tell everyone by editing your answer to tell us what exactly it is you did to solve the question. It makes it very hard to compare between both the OP's code and the answer here.
– Funk Forty Niner
Nov 22 at 4:30












up vote
1
down vote













You have duplicated your check for "no results":



if(mysqli_num_rows($result)>0)if(mysqli_num_rows($result)>0)


Remove one.






share|improve this answer





















  • This answer was entirely clear and IMHO, should have been the accepted answer. The other one being a "Try this", was hard for me to compare what it was exactly they did to deserve it being accepted/awarded. For all I know, there could have been more things wrong with the OP's code.
    – Funk Forty Niner
    Nov 22 at 4:29










  • "surely such a mysterious problem has a more complex solution" - non-experts
    – Joni
    Nov 22 at 16:09















up vote
1
down vote













You have duplicated your check for "no results":



if(mysqli_num_rows($result)>0)if(mysqli_num_rows($result)>0)


Remove one.






share|improve this answer





















  • This answer was entirely clear and IMHO, should have been the accepted answer. The other one being a "Try this", was hard for me to compare what it was exactly they did to deserve it being accepted/awarded. For all I know, there could have been more things wrong with the OP's code.
    – Funk Forty Niner
    Nov 22 at 4:29










  • "surely such a mysterious problem has a more complex solution" - non-experts
    – Joni
    Nov 22 at 16:09













up vote
1
down vote










up vote
1
down vote









You have duplicated your check for "no results":



if(mysqli_num_rows($result)>0)if(mysqli_num_rows($result)>0)


Remove one.






share|improve this answer












You have duplicated your check for "no results":



if(mysqli_num_rows($result)>0)if(mysqli_num_rows($result)>0)


Remove one.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 at 3:51









Joni

75.7k996148




75.7k996148












  • This answer was entirely clear and IMHO, should have been the accepted answer. The other one being a "Try this", was hard for me to compare what it was exactly they did to deserve it being accepted/awarded. For all I know, there could have been more things wrong with the OP's code.
    – Funk Forty Niner
    Nov 22 at 4:29










  • "surely such a mysterious problem has a more complex solution" - non-experts
    – Joni
    Nov 22 at 16:09


















  • This answer was entirely clear and IMHO, should have been the accepted answer. The other one being a "Try this", was hard for me to compare what it was exactly they did to deserve it being accepted/awarded. For all I know, there could have been more things wrong with the OP's code.
    – Funk Forty Niner
    Nov 22 at 4:29










  • "surely such a mysterious problem has a more complex solution" - non-experts
    – Joni
    Nov 22 at 16:09
















This answer was entirely clear and IMHO, should have been the accepted answer. The other one being a "Try this", was hard for me to compare what it was exactly they did to deserve it being accepted/awarded. For all I know, there could have been more things wrong with the OP's code.
– Funk Forty Niner
Nov 22 at 4:29




This answer was entirely clear and IMHO, should have been the accepted answer. The other one being a "Try this", was hard for me to compare what it was exactly they did to deserve it being accepted/awarded. For all I know, there could have been more things wrong with the OP's code.
– Funk Forty Niner
Nov 22 at 4:29












"surely such a mysterious problem has a more complex solution" - non-experts
– Joni
Nov 22 at 16:09




"surely such a mysterious problem has a more complex solution" - non-experts
– Joni
Nov 22 at 16:09


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423536%2fphp-not-returning-any-echo%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...