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 3322244
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:09:32+00:00 2026-05-17T23:09:32+00:00

I’m having trouble producing the right output from my code, which dynamically list records

  • 0

I’m having trouble producing the right output from my code, which dynamically list records from mysql db.
This is the form:

<form action="lister.php" method="get" id="info" name="weboptions" class="lesser">
   <h2>List Products</h2>
    <input type="radio" name="xo" value="n" class="styled">Name<br/>
    <input type="radio" name="xo" value="c" class="styled">Category<br/>
    <input type="radio" name="xo" value="d" class="styled">Description
      <div id="dta-wrap" class="slider">
       <input type="text" id="neym" name="neym" onKeyUp="bypname(this.value)"   class="DEPENDS ON xo BEING n AND CONFLICTS WITH XO BEING d OR XO BEING c"/></span>
      </div><!--/#dta-wrap-->
   <div id="dta2-wrap" class="slider">
      <input type="text" id="c" name="c" onKeyUp="bycat(this.value)"  class="DEPENDS ON xo BEING c AND CONFLICTS WITH XO BEING d OR XO BEING n"/></span>
   </div><!--/#dta-wrap-->

    <div id="dta3-wrap" class="slider">
      <input type="text" id="dta3" name="dta3" onKeyUp="bydesc(this.value)"  class="DEPENDS ON xo BEING d AND CONFLICTS WITH XO BEING n OR XO BEING c"/></span>
   </div>
<a href="adminpage.php"><input type="button" id="btn" name="back" value="back"></a>
</form>
<div id="resultcat"></div>

And this is the javascript file which calls the php file where the query is located:

function bydesc(str)
{
if (str=="")
  {
  document.getElementById("resultcat").innerHTML="";
  return;
  }  
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("resultcat").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","listerdesc.php?dta3="+str,true);
xmlhttp.send();
}

function bypname(str)
{
if (str=="")
  {
  document.getElementById("resultcat").innerHTML="";
  return;
  }  
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("resultcat").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","listerpname.php?dta="+str,true);
xmlhttp.send();
}

function bycat(str)
{
if (str=="")
  {
  document.getElementById("resultcat").innerHTML="";
  return;
  }  
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("resultcat").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","listercat.php?dta2="+str,true);
xmlhttp.send();
}

And this is where the query is(listerpname.php):

<?php 
if(!empty($_GET['dta'])){
$pname=$_GET['dta'];  
$result1=query_database("SELECT * FROM prod_table WHERE PRODUCT LIKE'%$pname%'", "onstor", $link);
?>

<?php
if(mysql_fetch_assoc($result1)==0){
    echo "<center><h3 id='wyt'>Your query produced no results..</h3></center>";
}else{
?>          

<center>        
<table border="1">
<thead>
    <tr>
    <th>PID</th>
    <th>PRODUCT</th>
    <th>CATEGORY</th>
    <th>DESCRIPTION</th>

    <th>QTY_ON_HAND</th>
    <th>REORDER_QTY</th>
 <th>DEALER PRICE</th>
    <th>SELL PRICE</th>
    </tr>
</thead>

<?php
while($row=mysql_fetch_assoc($result1)) { 

?>
    <tbody>
            <tr>
        <td><a href="delprod.php?prodid=<?php echo $row['PID']; ?>"><?php echo $row['PID']; ?></td>
        <td><a href="updateprod.php?prodname=<?php echo $row['PRODUCT']; ?>" class="plain"><?php echo $row['PRODUCT']; ?></a></td>

        <td><?php echo $row['CATEGORY']; ?></td>
        <td><?php echo $row['P_DESC']; ?></td>

         <td><?php echo $row['QTYHAND']; ?></td>
         <td><?php echo $row['REORDER_LVL']; ?></td>
      <td><?php echo $row['B_PRICE']; ?></td>
         <td><?php echo $row['S_PRICE']; ?></td>
            </tr>
        </tbody>

<?php } ?>
<?php } ?>
<?php } ?>

The problem is that it outputs only one record if I type in a 3-letter word(‘Tos’). It should output 2 records. Because there are 2 records beginning with the word ‘tos’ in my database. It only outputs the most recent record that I have added.
When I do:

SELECT * FROM prod_table WHERE PRODUCT LIKE'$pname%'

It worsens the case. Please help.

  • 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-05-17T23:09:32+00:00Added an answer on May 17, 2026 at 11:09 pm

    It looks like the problem is that when you check for results in the following line, you are moving the cursor by 1 and are discarding the first record in the resultset:

    if(mysql_fetch_assoc($result1)==0){
    

    You probably want to use the mysql_num_rows function instead, to avoid losing the first record in the resultset.

    if(mysql_num_rows($result1)==0){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a text area in my form which accepts all possible characters from
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.