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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:37:16+00:00 2026-05-25T03:37:16+00:00

I have a PHP form where one of the fields in the SQL table

  • 0

I have a PHP form where one of the fields in the SQL table shows up as a link. However I want it to display something other than the field data and only if that field has something in it.
It’s a gig list and I want the option of displaying a link to the ‘setlist’. I don’t want it to display the filename though as it does now, but an image icon or something like ‘SET’.

Someone suggested I add

if ($row['gigsetlist']=="") {

to the code but this has thrown up a Unexpected Catch.. error message.

Below is the code with the above if statement included.
Can someone point out what else might be missing or conflicting?

<?php 

try {

    require_once "pdo_testdb_connect.php";

    $dbh = testdb_connect ();

    $sql = "SELECT id, gigdate,  date_format(gigdate,'%d %M') as d, gigshortdesc, 
    gigsetlist FROM gigs WHERE gigdate 
    BETWEEN '1995-01-01' AND '1995-12-31' ORDER BY gigdate ASC";

    print '<table>';

    foreach($dbh->query($sql) as $row)
    {
        print '<tr>
        <td width=100>' . $row['d']  . ' </td>
        <td> ' . $row['gigshortdesc'] . '</td>
        <td>';
        if ($row['gigsetlist']=="")
        {
            print '<a href="sets/' . $row['gigsetlist'] . '.php" 
            onclick="return openWin  (this.href, 

            this.target, 480, 480, 1, 0, 0, 0, 0, 1);" 
            rel="nofollow" target="_setlist">' . $row['gigsetlist'] . '</a></td>
            </tr>';
        }

    }

    print '</table>';

    $dbh = null;

}

catch(PDOException $e)
{
    echo $e->getMessage()
;}?>

Many thanks

  • 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-25T03:37:17+00:00Added an answer on May 25, 2026 at 3:37 am

    Change

    From:

    if ($row['gigsetlist']=="")
    

    To:

    if ($row['gigsetlist']!="")
    

    You have to check $row[‘gigsetlist’] not equal to empty which means it contains some data then display the link.

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

Sidebar

Related Questions

I have one form in a PHP (5.2.9-1) application that causes IIS (Microsoft-IIS/6.0) to
I have a PHP form that when submitted saves to a MySQL database. One
I have two PHP functions - one that builds a html form and another
I have two fields <form action=insert.php method=post> Firstname: <input type=text name=firstname /> Lastname: <input
Basically when I have more than about 25 file uploads in one form, the
I made a small database(1 table) in phpMyAdmin. One of the fields I want
I have a page with a register form. Username is one of the fields
I have a php form that has a known number of columns (ex. top
I currently have a PHP form that uses AJAX to connect to MySQL and
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect

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.