Jump to content

multiple database rows


happygolucky

Recommended Posts

hello.

 

Just a quick question, In my databse i have several bands. I'll name two here Taking Back Sunday and Take That.

 

I type Tak into my search field and only one band will be returned. how can i change that so it will return all bands with the keyword?

 

<html>
    <head><title>Media Mart</title>
    </head>
        <body>
            <center><img src="welcome.jpg" alt="welcome" /></center>
            
            <p>
                <center>
                    <form action="artists.php" method="post">Search For...
                        <input type="text" name="keyword" size="60" maxlength="60" value="" />
                        <input type="submit" value="Search!" />
                    </form>
                </center>
            </p>
<?php

error_reporting (0);
$conn = @pg_connect("[i]hidden connection details[/i]"); 

if ($conn)  {

echo "connected to DB";

$keyword = $_POST['keyword'];
    {
	$resultset =  "SELECT artist_name, genre FROM artists WHERE artist_name ILIKE'$keyword%'"; 
        $artists = pg_query ($conn, $resultset);
        $array = pg_fetch_all($artists);
        
        foreach($array as $row);
     {   
    echo '<center>';
echo '<table border="6">';
    echo '<th>Artist</th>';
    echo '<th>Genre</th>';
    echo '<tr>';	
    echo '<td>' . $row['artist_name'] . '</td>'; 
    echo '<td>' . $row['genre'] . '</td>';
    echo '</tr>';
    echo '</center>';
    echo '</table>';
    }
    }
    }
    else
    {
    echo "no connection";
    } 

   echo pg_last_error($conn);

 

any help will be appreciated

 

 

Link to comment
https://forums.phpfreaks.com/topic/157285-multiple-database-rows/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.