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

  • Home
  • SEARCH
  • 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 8875471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:58:57+00:00 2026-06-14T18:58:57+00:00

From index.html using form i recieve null to function.php. index.html – form with input.

  • 0

From index.html using form i recieve null to function.php.

index.html – form with input.

manager.php – get values from form and send it to proper function in function.php.

function.js – get ajax for data.

my function stops on

    while($row = $result->fetchRow())
{

    $title = $row[0];
    echo '<tr><td>' . $title .'</td>';
}

cos zero rows found and display nothing.

sql select – works
structure of the database – https://www.dropbox.com/s/6cnnxb933yl11og/1.png

Index.Html

<script src="functions.js"> </script>
<style>
table, table td { border: 1px solid #666; }
</style>
</head>

<body>
    <form name="films" action="manager.php" method="POST">
        <select name="type">
            <option>Genre</option>
            <option>Actor</option>
            <option>Date</option>
        </select>

        <input type="text" name="search">
        <input type="text" name="additional">
        <input type="submit" value="Submite" onclick="getGoodsBy()">
        <input type="reset">
    </form>

<div id="result"></div>

manager.php

    <?php
    require_once 'functions.php';

    $type = $_POST['type'];
    $search = $_POST['search'];
    $additional = $_POST['additional'];

    if ($type == 'Genre')
    getGoodsByGenre($search);
    if ($type == 'Actor')
    getGoodsByActor($search);
    if ($type == 'Date')
    getGoodsByDate($search, $additional);
    ?>

functions.php

  <?php
    require_once 'DB.php';
    require_once 'manager.php';

    $user = 'root';
    $pass = '';
    $host = 'localhost';
    $db_name = 'lab2';
    $dsn = "mysql://$user:$pass@$host/$db_name";

    function getGoodsByGenre($genre)
    {
global $user;
global $pass;
global $host;
global $db_name;
global $dsn;
$db = DB::connect($dsn, true);

if (DB::isError($db)) {
    die ($db->getMessage());

}

$sql = "SELECT a.name as name 
    FROM film as a
    INNER JOIN film_genre as b ON b.FID_Film=a.ID_FILM
    WHERE b.FID_Genre='".$_POST['genre']."'";

$result = $db->query($sql);
echo '<table>';


while($row = $result->fetchRow())
{

    $title = $row[0];
    echo '<tr><td>' . $title .'</td>';
}
echo '</table>';



$db->disconnect();

}

    function getGoodsByActor($actor)
    {
global $user;
global $pass;
global $host;
global $db_name;
global $dsn;

$db = DB::connect($dsn, true);

if (DB::isError($db)) {
    die ($db->getMessage());
}
$sql = "SELECT a.name as name 
    FROM film as a
    INNER JOIN film_actor as b ON b.FID_FILM=a.ID_FILM
    WHERE b.FID_Actor =".$_POST['actor']."";


$result = $db->query($sql);

echo '<table>';
while($row = $result->fetchRow())
{
    $name = $row[0];

    echo '<tr><td>' . $name .'<td>' ;
}
echo '</table>';
$db->disconnect();
    }

    function getGoodsDate($startDate, $endDate)
    {
global $user;
global $pass;
global $host;
global $db_name;
global $dsn;

$db = DB::connect($dsn, true);

if (DB::isError($db)) {
    die ($db->getMessage());
}

$sql = "SELECT a.name as name 
    FROM film as a
    WHERE a.date >= ".$_POST['startDate']." and a.date                         <=".$_POST['endDate']."";

$result = $db->query($sql);

echo '<table>';
while($row = $result->fetchRow())
{
    $date = $row[0];

    echo '<tr><td>' . $date . '<td>';
}
echo '</table>';
$db->disconnect();
    }
    ?>

functions.js

  function createHttpRequest()
    {
var httpRequest;

if (window.XMLHttpRequest) 
{
    httpRequest = new XMLHttpRequest();
    if (httpRequest.overrideMimeType)
        httpRequest.overrideMimeType('text/xml');
} 
else if (window.ActiveXObject)
{
    try {
        httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) {
        try {
            httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (e) {}
    }
}

if (!httpRequest) 
{
    alert('Cannot create XMLHTTP instance');
    return null;
}
    return httpRequest;
    }

    function showResult(httpRequest)
    {
try 
{
    if (httpRequest.readyState == 4) 
    {
        if (httpRequest.status == 200)
        {
            var result = document.getElementById('result');
            result.innerHTML = httpRequest.responseText;
        }
        else 
        {
            alert('There was a problem with the request.');
        }
    }
}
catch( e ) 
{
    alert('Caught exception: ' + e.description);
}
    }

    function getGoodsBy()
    {
var type = document.forms['films'].type.value;
var search = document.forms['films'].search.value;
var additional = document.forms['films'].additional.value;
var params = encodeURI('type=' + type + '&search=' + search + '&additional=' + additional);

var httpRequest = createHttpRequest();
httpRequest.open('POST', 'manager.php', true);

httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");    
httpRequest.onreadystatechange = function() { showResult(httpRequest); };
httpRequest.send(params);
    }

PS: I can’t use jquery or something else. Just PHP with javascript ajax – no addons, mods or something like that.

  • 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-14T18:58:58+00:00Added an answer on June 14, 2026 at 6:58 pm

    1.
    Problem is you are using $_POST['genre'] in your query but it should use $genre which is parameter value you are passing.

    2.
    Remove $genre = $_POST['search']; from getGoodsByGenre function

    3.You have same as above problem in other functions

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

Sidebar

Related Questions

i am using php 5.2.8 i have index.html, which loads LOAD.PHP from IFRAME. iframe
When ever I pass a value from a form using submit to a php
I am using the project 'ModalBox' from http://okonet.ru/projects/modalbox/index.html in order to generate my modal.
I want to do autopostback to dropdownlist. My form on view: @using (Html.BeginForm(Index, Model,
I'm using the overlay jquery from here: http://flowplayer.org/tools/overlay/index.html Within my overlay I have a
@using (Html.BeginForm(Index, Checkout, FormMethod.Post)) { @Html.AntiForgeryToken(App.WebUI.Helpers.SecurityHelpers.AntiforgeryTokenSalt) <input type=hidden name=amount value=@Model.PackageCost/> <input type=hidden name=currency value=$/>
I'm unable to transition from index.html to any pages correctly. All transitions would show
I convert all links from example.com/action to example.com/index.html#action which is then parsed by my
I need to redirect user to another page called free.php from index page, if
When I convert list into array, the values are inserted starting from index 1.

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.