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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:54:31+00:00 2026-06-17T19:54:31+00:00

<? // Set the MySQL Configuration $db_host = test; $db_user = test; $db_password =

  • 0
<?
// Set the MySQL Configuration
$db_host       = "test";
$db_user       = "test";
$db_password   = "test";
$db_name       = "test";
$db_table      = "test";

// Start Connection
$db_connect        =  mysql_connect ($db_host, $db_user, $db_password);

// Select Database
$db_select        =  mysql_select_db ($db_name, $db_connect);


$query = "SELECT bird_owner, place_name, funds, place_description FROM bird_locations";

$query2 = "SELECT blue_bird, red_bird, green_bird, gold_bird, black_bird FROM bird_locations"; 

// this query ($query2) is to select just the birds so can check if any bird = 1 then add a new image cell in table

// Execution MySQL Query
$result = mysql_query($query);


if($result)
{

// table headers

echo '<table width="90%" border="0" align="center" cellspacing="2" cellpadding="10">


<p><p><p>
<tr>
<th align="center"><b>Owner</b></th>
<th align="center"><b>PlaceName</b></th>
<th align="center"><b>Birds</b></th>
<th align="center"><b>Funds</b></th>
<th align="center"><b>Description</b></th>
</tr>
';

//now i add a new row for each result which works.

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
 {
     echo '<tr>
    <td align="center"><b>' . $row['bird_owner'].'</b></td>
    <td align="center"><b>' . $row['place_name'].'</b></td>

    <td align="center"><b><img src="bird_blue_50px.png"/></b></td> 

    <td align="center"><b>' . $row['funds'].'L$</b></td>
    <td align="center"><b>' . $row['place_description'].'</b></div></td>

    </tr>';

 }

echo '</table>';

}


//Close MySQL connection
mysql_close($db_connect);
?>

When the rows are generated the 3rd cell of a row is an image of a bird, but how can I make it so that if the value of a bird in the database is 1 that it shows an extra cell for another bird image?

e.g. if

  • blue_bird value equals 1 show image in row
  • red_bird value equals 1 show a red bird image in row also
  • green_bird value equals 1 show green bird image
  • gold_bird value equals show gold bird image
  • black_bird value equals show black bird image

and if there value equals 0 then don’t show that image in table

  • 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-17T19:54:32+00:00Added an answer on June 17, 2026 at 7:54 pm

    Split the echo:

    echo '<tr>
    <td align="center"><b>' . $row['bird_owner'].'</b></td>
    <td align="center"><b>' . $row['place_name'].'</b></td>';
    if ($row['blue_bird']==1){
       echo '<td>Etc...';
    }
    
    echo '<td align="center"><b><img src="bird_blue_50px.png"/></b></td> 
    
    <td align="center"><b>' . $row['funds'].'L$</b></td>
    <td align="center"><b>' . $row['place_description'].'</b></div></td>
    
    </tr>';
    

    Also, mysql_query won’t be supported for long anymore: http://php.net/manual/en/function.mysql-query.php

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

Sidebar

Related Questions

This is the code I'm using: <?php // Set the MySQL Configuration $db_host =
I have a MySQL database set-up in a hierarchy style. There are 4 tables
My rails app is set up using a mysql database. When I do a
I have a local and a remote connection with my mysql database. The local
So I have tried using the stock Play! 2.2 configuration for the MySql database
How do I set a port number for mysql connection in Agile Toolkit? The
Im trying to get my mysql test database setup and having a strange error,
Normally when I want to query large result set using Mysql I write this
I want to set my Django/mysql site to work with UTF-8. Please guide me
I'm using a nested set in a MySQL table to describe a hierarchy of

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.