Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8402371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:02:26+00:00 2026-06-09T22:02:26+00:00

I want to redirect the user to another page based on what the user

  • 0

I want to redirect the user to another page based on what the user clicks in my search form, which uses ajax to populate from the DB.

How would I make an onclick event which redirects the page to a different one as well as passes an ID parameter?

Currently as soon as you highlight a option from the drop down search menu it sends me to a new page (called some_page.php? with the correct card ID the only thing I want to change is to only send the user there when he clicks on the card.

enter image description here

the JS

function display(id)
    {
        //document.getElementById('text_content').value = word;
            document.getElementById('box').style.display = 'none';
        document.getElementById('text_content').focus();
        window.location.href = "some_page.php?card_id=" + id;

    }

the php

<?php
    $mysqli = mysqli_connect('localhost', 'root', '', 'draftdb');

if(mysqli_connect_errno()) 
{
    echo "Connection Failed: " . mysqli_connect_errno();
    exit();
}


<?php
        $str = $_GET['content'];
        if(strlen($str))
        {
            $sel = mysqli_query($mysqli, "select CARD_NAME, CARD_ID,CARD_TYPE from cards where CARD_NAME like '".trim($str)."%'");
            if(mysqli_num_rows($sel))
            {
                echo "<table border =\"0\" width=\"100%\">\n";
                if(mysqli_num_rows($sel))
                {
                    echo "<script language=\"javascript\">box('1');</script>";
                    while($row = mysqli_fetch_array($sel))
                    {
                        $card_info = str_ireplace($str,"<b>".$str."</b>",($row['CARD_NAME']));
                        $card_type = str_ireplace($str,"<b>".$str."</b>",($row['CARD_TYPE']));

                echo "<tr id=\"word".$row['CARD_ID']."\" onmouseover=\"highlight(1,'".$row['CARD_ID']."');\" onmouseout=\"highlight(0,'".$row['CARD_ID']."');\" 
       onClick=\"display('".$row['CARD_NAME']."', " . $row['CARD_ID'] . ");\" >\n<td>".$card_info." ".$card_type."</td>\n</tr>\n";



                    }
                }
                echo "</table>";
            }
        }
        else
        {
            echo "<script language=\"javascript\">box('0');</script>";
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:02:27+00:00Added an answer on June 9, 2026 at 10:02 pm

    I would redo the code, and use something like this:

    PHP:

    <?php
    $mysqli = mysqli_connect('localhost', 'any_user_other_than_root', 'secure_password_here', 'draftdb');
    if(!$mysqli) 
    {
        die('Connection Failed: ' . mysqli_connect_errno());
    }
    $str = $_GET['content'];
    if(!empty($str))
    {
        $str = trim(mysqli_real_escape_string($mysqli, $str));
        $sel = mysqli_query($mysqli, "SELECT `card_name`, `card_id`, `card_type` FROM `cards` WHERE `card_name` LIKE '$str%'");
        if(mysqli_num_rows($sel) > 0)
        {
            echo '<form action="some_page.php" method="post">' . PHP_EOL;
            echo '<select name="card_id" id="card_id" size="8">' . PHP_EOL;
            while($row = mysqli_fetch_array($sel))
            {
                $card_info = str_ireplace($str, "<strong>$str</strong>", $row['CARD_NAME']);
                $card_info = str_ireplace($str, "<strong>$str</strong>", $row['CARD_TYPE']);
                echo '<option class="card" value="'. $row['CARD_ID'] . '">';
                echo "$card_info $card_type";
                echo '</option>' . PHP_EOL;
            }
            echo '</select>' . PHP_EOL;
            echo '</form>' . PHP_EOL;
        }
    }
    ?>
    

    CSS:

    <style type="text/css">
        .card {
            background: #eee
        }
        .card:hover {
            background: #ccc
        }
    </style>
    

    Of course, CSS would be needed to make it look like you have it at the moment, and some JS may be needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to redirect the user to next page afte successfully submitting their information
I want to redirect my page to another if a condition is satisfied say,
I want to redirect users that arrive at my root url to another page
I'm using a repeater on my page. I want to populate this repeater based
I have an aspx page, which is a User Log-In area. I want to
How is it possible to redirect the user to another page when he likes
How do I redirect the user to another page withing the same website? In
I want to redirect to home page if session get invalid. My spring-servlet.xml is
I want to redirect users to an error page if they enter any URL
I currently have a form based login in my application which is developed on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.