how i can make search in another page

how i can make search in another page and take form values to search page

if there is another suggest i listen
AHMED SAMYownerAsked:
Who is Participating?
 
zephyr_hex (Megan)Connect With a Mentor DeveloperCommented:
You can take form values to another page by using POST or an AJAX call.
0
 
AHMED SAMYownerAuthor Commented:
i have this code need to ecute in another page or the same page if possible

<?php
            if($connect){
                if($_POST['Modify']){


                    error_reporting(E_ALL);
                    ini_set('display_errors', 1);

                    $Travel=$_POST['Travel'];
                    $Duration=$_POST['Duration'];
                    $cites=$_POST['cites'];
                    $themes=$_POST['themes'];
                    $Categories=$_POST['Categories'];
                    $rooms=$_POST['rooms'];
                    $Adults=$_POST['Adults'];
                    $children=$_POST['children'];
                    $agechildren=$_POST['agechildren'];

                    $sql11="SELECT * FROM packages WHERE Trip_Duration LIKE '%$Travel%' OR Trip_Duration LIKE '%$Duration%' OR Detailed_Itinerary LIKE '%$cites%' OR Detailed_Itinerary LIKE '%$themes%' OR HName1 LIKE '%$Categories%' OR HName2 LIKE '%$Categories%' OR Detailed_Itinerary LIKE '%$rooms%' OR Detailed_Itinerary LIKE '%$Adults%' OR Detailed_Itinerary LIKE '%$children%' ";

                    $packages = mysqli_query($connect,$sql11);

                    while ( $searchresult= mysqli_fetch_array($packages)) {

                        $pac_name1 = $searchresult['package_id'];
                        $sqlimg1 = "SELECT content FROM packages_image WHERE packageID='$pac_name1'";
                        $queryimg1 = mysqli_query($connect, $sqlimg1);
                        while ($resultimg1 = mysqli_fetch_array($queryimg1)) {
                            ?>
                            <div class="col-lg-6 portfolio-item">
                                <div class="card h-100">
                                    <a href="ViewDetails.php?id=<?php echo $searchresult['package_id']; ?>">
                                        <?php echo '<a href="#"><img src="data:image/png;base64,' . base64_encode($resultimg1['content']) . '" width="100%" height="350px"/></a>'; ?>
                                    </a>
                                    <div class="card-body">
                                        <h4 class="card-title">
                                            <a href="ViewDetails.php?id=<?php echo $searchresult['package_id']; ?>"><?php echo $searchresult['package_id']; ?></a>
                                        </h4>
                                        <h3 class="breadcrumb"
                                            style="color:#C00; text-align:center"><?php echo $searchresult['Package_Price']; ?> euro.</h3>
                                        <p class="card-text"><?php echo substr($searchresult['Detailed_Itinerary'], 0, 150) ?></p>
                                        <a href="ViewDetails.php?id=<?php echo $searchresult['package_id']; ?>" class="btn btn-primary">More
                                            Details</a>
                                    </div>
                                </div>
                            </div>
                            <?php
                        }
                    }

                }
            }

            ?>

Open in new window

0
 
Eddie ShipmanAll-around developerCommented:
So, you want to view the search results in another page? I understand that English is not your primary language but a little more explanation is needed.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
AHMED SAMYownerAuthor Commented:
ok i have this code java to excute select option value

<script type="text/javascript">
        $(document).ready(function() {
            $('#sortBy').change(function() {
                $.get('data.php', { sort: $(this).val() }, function(data) {
                    $('#response').html(data);
                });
            });
			// Trigger the change event when the page loads
    		$('#sortBy').trigger('change');
        }); 
        </script>

Open in new window


and other data.php file is

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

$dbh = new PDO("mysql:host=$localhost;dbname=$db_name", $db_users, $db_password);
$dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);

switch ($_GET['sort']):

    case "1":
        $sql = "SELECT * FROM packages ORDER BY Package_Price ASC";
        break;

    case "2":
        $sql = "SELECT * FROM packages ORDER BY Package_Price DESC";
        break;

    default:
        $sql = "SELECT * FROM packages ORDER BY Package_Price";

endswitch;

// Prepare the IMG query to be used later on
$imgQuery = $dbh->prepare("SELECT content FROM packages_image WHERE packageID = ? LIMIT 1");

// Execute the Packages query
$packages = $dbh->query($sql);

// Loop through the Package results
while ($package = $packages->fetch()): ?>

    <?php
    // Get the image data from the prepared query
    $imgQuery->execute(array($package->package_id));
    $imgData = $imgQuery->fetchColumn();
    ?>

        <div class="col-lg-6 portfolio-item">
            <div class="card h-100">
                <a href="ViewDetails.php?id=<?php echo $package->package_id ?>">
                  <?php  echo '<img src="data:image/jpeg;base64,'.base64_encode($imgData).'" width="100%" height="350px"/>'; ?>
                </a>
                <div class="card-body">
                    <h4 class="card-title">
                        <a href="ViewDetails.php?id=<?php echo $package->package_id ?>"><?php echo $package->package_name ?></a>
                    </h4>
                  <h3 class="breadcrumb" style="color:#C00; text-align:center"><?php echo $package->Package_Price ?> euro.</h3>
                    <p class="card-text"><?php echo substr($package->Detailed_Itinerary, 0, 150) ?></p>
                    <a href="ViewDetails.php?id=<?php echo $package->package_id ?>" class="btn btn-primary">More Details</a>
                </div>
            </div>
        </div>

<?php endwhile; ?>

Open in new window


i have div with inputs and submit button to make another search how can i do ??
0
 
Eddie ShipmanAll-around developerCommented:
Still not clear enough. We need explanation of what you want, not just code.
0
 
AHMED SAMYownerAuthor Commented:
i have div with inputs and submit button above this select element  to make another search how can i do without conflict results??
0
 
Eddie ShipmanAll-around developerCommented:
In none of your code do I see an element with the id response or the id sortBy
If you want us to fully understand what you need, one line answers that really do not show us isn't going to help.
0
 
AHMED SAMYownerAuthor Commented:
<div class="float-left">Packages Found : <span style="color:red"><?php echo $resultcount['COUNT(package_name)']; ?></span></div>
                    <div class="float-right" style="display:inline">
                        <style>
                        #duration{width:200px;}
                        </style>
                                    
                        <select id="sortBy" class="form-control" style="width:250px;">
                            <option value="2">Star Rating (1-5)</option>
                            <option value="1">Star Rating (5-1)</option>
                        </select>

       
                    </div>
                  </div>
        </div>
            <br>
        <br>
      <div class="container">

       <!-- Page Heading/Breadcrumbs -->

        <div class="row" id="response"></div>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.