Avatar of AHMED SAMY
AHMED SAMY
Flag for Egypt asked on

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
PHPJavaScript

Avatar of undefined
Last Comment
AHMED SAMY

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
zephyr_hex (Megan)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AHMED SAMY

ASKER
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

Eddie Shipman

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.
AHMED SAMY

ASKER
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 ??
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Eddie Shipman

Still not clear enough. We need explanation of what you want, not just code.
AHMED SAMY

ASKER
i have div with inputs and submit button above this select element  to make another search how can i do without conflict results??
Eddie Shipman

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
AHMED SAMY

ASKER
<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>