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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:15:31+00:00 2026-05-26T22:15:31+00:00

I am trying to dynamically build a table on my page through ajax, using

  • 0

I am trying to dynamically build a table on my page through ajax, using jquery and php. The following is my php code:

<?php
$con = mysql_connect("127.0.0.1","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("tbl_name", $con);

$result = mysql_query("SELECT `Book ISBN` FROM tbl_name");


echo "<table id='booklist'><tr>
                         <th>Edit</th>
                         <th class='coursename'>Course Name</th>
                         <th class='startdate'>Start Date</th>
                         <th class='booktitle'>Book Title</th>
                         <th class='author'>Book Author</th>
                         <th class='isbn'>Book ISBN</th>
                     </tr>";
        while($row = mysql_fetch_array($result))
        { 
            echo    "<tr>
                        <td><input type='checkbox'></input></td>
                        <td class='coursename'>" . $row[`Course Name`] . "</td>
                        <td class='startdate'>" . $row[`Start Date`] . "</td>
                        <td class='booktitle'>" . $row[`Book Title`]. "</td>
                        <td class='author'>" . $row[`Book ISBN`]. "</td>
                        <td class='isbn'><input class='ISBN_number' type='text' value='' size='13' maxlength='13'></input></td> 
                  </tr>";                   
        }               
echo "</table>";

mysql_close($con);
?> 

(Note: the row names have spaces in them (thats how the database came). I used back ticks instead of single quotes because someone online said thats how you can keep the spaces… If I get over this issue I’ll see if that works.)

Next my jquery script:

$(document).ready(function()
   {
        $("#build_table").click(function()
        {
            $.get("build_table.php",
                function(table)
                {   console.log("Entered table function");
                    $("#input_table").replaceWith("<div id='input_table'>" + table + "</div>");
                });
        });
   });

and the html:

<input id="build_table" style="clear:both" type="button" value="Submit"></input>

When I click on this button, though, I get the following php error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:…pathname…\build_table.php on line 13
What is this error?

  • 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-26T22:15:31+00:00Added an answer on May 26, 2026 at 10:15 pm

    The problem lies in your query. Are you sure that your database and table is named tbl_name? Change your statement into this:

    $result = mysql_query("SELECT `Book ISBN` FROM tbl_name") or die(mysql_error());
    

    And you’ll get a error message from MySQL.

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

Sidebar

Related Questions

I'm trying to build a table that is 5x6 dynamically using PHP. Right now
I'm trying to build an associative array in PHP dynamically, and not quite getting
I am trying to dynamically create a Bitmap Image using byte array using following
I am trying to build a dynamically generated unordered list in the following format
I am trying to dynamically build a list of admin actions using the get_actions()
So I'm trying to dynamically build a table in javascript and I already have
I'm trying to build some code for dynamically sorting a Linq IQueryable<>. The obvious
I'm trying to construct a table with dynamically build information. My thought was to
I'm new to JQuery and trying to use it to dynamically build HTML based
I am trying to create a table dynamically in my code behind. My problem

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.