John Davidson

html - Can't retrieve data from table php

0 comments
Message:


I have created a button on my HTML page that is supposed to retrieve data from my table. However, when I click on it, no Data seems to be showing. Here is my table (artists):


      name      | Style |  
----------+-------------+
Micheal Jackson | Pop
Tyga | Rap
Drake | Rap
50 cent | Rap
King Von | Rap


I am trying to print the name column but does not seem to be working? It shows a blank page. Here is my code:


<!DOCTYPE html>
<html lang="en">
<head>
<title>Artists Table</title>
<meta charset="utf-8">
<meta name="Author" content="Ron Mercer">

</head>
<body>
<h1>Players Table</h1>
<h2>

<?php


$con=pg_connect("dbname=ron") or die( pg_last_error());
$name=$_GET['name'];
$res = pg_query_params("select name from artists where name= $1",array($name))
or die( pg_last_error());

while ($row = pg_fetch_row($res))
{
print($row[0]."<br>");
}

?>
</body>


I know that there is a good connection to my database because when I spell type my table name(artists) wrong it says:



ERROR: relation "artisgsts" does not exist LINE 1: select name from artisgsts where name= $1 ^.



So it recognises my table, but why doesn't it print anything? Thanks.



My Answer:
you please provide more context or specify what you would like to know about HTML?

Rate this post

4 of 5 based on 1826 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us