php - display element in search result page, then the details in another page -
the result of search comes database, on result page when click on name of searched element, want redirected page viewing more information element database!
here insert company code:
<?php $db = new mysqli('localhost', 'root', '', 'search'); if(isset($_post["submit"])) { $comname = addslashes($_post["comname"]); $comcountry = addslashes($_post["comcountry"]); $comkey = addslashes($_post["comkey"]); $comdes = addslashes($_post["comdes"]); $comlink = addslashes($_post["comlink"]); $comlogo = $_files["comlogo"]["name"]; $comlogo_tmp = $_files['comlogo']['tmp_name']; move_uploaded_file($comlogo_tmp, "images/$comlogo"); { $sql = "insert tshirt (comname, comcountry, comkey, comdes, comlink, comlogo) values ('$comname', '$comcountry', '$comkey', '$comdes', '$comlink', '$comlogo')"; $rs = mysqli_query($db, $sql); if($rs) { echo "<script> alert('company uploaded successfully') </script>"; } else { echo "<script> alert('uploading failed, please try again.') </script>"; } } } ?>
result page
<?php $mysqli = new mysqli("localhost", "root", "", "search"); if(isset($_get['search_button'])) { $search = $_get['search']; if($search=="") { echo "<center> <b> please write in search box </b> </center>"; exit(); } $sql = "select * tshirt comkey '%$search%' limit 0, 5"; $rs = mysqli_query($mysqli, $sql); if (mysqli_num_rows($rs) < 1) { echo "<center> <h4> <b> oops !!! sorry, there no result found, try again. </b> </h4> </center>"; exit(); } echo "<font size='+1' color='#1a1aff'> images $search</font>"; while ($row = mysqli_fetch_array($rs)) { echo "<td> <table style='margin-top: 10px'> <tr> <td> <a target='_blank' href='images.php?id=$search'><img src='img/$row[5]' height='100px'></a> </td> </tr> </table> </td>"; } } ?> </tr> </table> <?php echo "<a target='_blank' href='images.php?id=$search'><font size='+1' color='#1a1aff'> more images $search </font></a>"; echo "<hr>"; $sql1 = "select * tshirt comkey '%$search%' limit 0, 10"; $rs1 = mysqli_query($mysqli, $sql1); while ($row1 = mysqli_fetch_array($rs1)) { echo "<a href='$row1[2]'><font size='4' color='#0000cc'> $row1[1] </font></a><br>"; echo "<font size='3' color='#006400'> $row1[2] </font><br>"; echo "<font size='3' color='#666666'> $row1[4] </font><br><br>"; } ?>
help!
all answers welcome. thanks!
Comments
Post a Comment