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

  • Home
  • SEARCH
  • 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 8023593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:36:15+00:00 2026-06-04T22:36:15+00:00

I have created a field in MySQL named pid, which I use in PHP

  • 0

I have created a field in MySQL named “pid”, which I use in PHP coding at the end of other variable names to indicate which of 7 template designs a user has created. The limit is 7, at which point they are given a message that they have reached their limit.

I have the code working EXCEPT when the field is blank (before user creates the first template). When I hard-code a “0” it works. But, obviously, I need to use the “{pid}” variable to pick up the template sequence in the database.

Here is the PHP:

<?PHP
  $pid = {pid};
  $total_templates = 7;
  if ($total_templates > $pid) {
    echo "<a href='create.template.php'><img src='create_template.png'></a>";
  } else {
    echo "<b style='color: #CC0000'>Your limit of $pid Templates has been reached";
  }
?>

How do I get the code to convert a blank field in MySQL to “0” in conjunction with the above code?

  • 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-04T22:36:18+00:00Added an answer on June 4, 2026 at 10:36 pm

    If I understand your question, could you not set it to 0 if it is empty()?

    $pid={pid};
    if(empty($pid))
        $pid = 0;
    

    You can also set the default value for that field in mysql. If you are using phpAdmin, go to the table and click the “Change” action and set the default value there. If you need sql command to do this, I can get that for you too.

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

Sidebar

Related Questions

I have created a add input field function which is working fine. I would
In mysql I have a timestamp with the field name added_on . I created
I have a field named 'dealBusinessLocations' (in a table 'dp_deals') which contain some ids
I have created a comment box successfully using PHP with MySQL. The comment table
first of all I'm using MySql. I have to create a advance search field
I have a 'created_date' DATETIME field which I would like to be populated with
We have created a table with a trigger that updates a ModifiedDate field in
I have a model with a datetime field: class MyModel(models.Model): created = models.DateTimeField(auto_now =
I've created a login page and in the db table i have a field
In my addresses table, I have an field named isPrimary. For each address assigned

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.