Table of Contents
Question 2. 如何判断一个字符串符合数据表中的哪条规则?
Question 1. 如何判断一个数值在数据表的一条范围中
回复内容:
Home Backend Development PHP Tutorial 微信 - php+mysql问题.怎么判断一个字符串符合数据表中的哪条正则表达式值得数据?

微信 - php+mysql问题.怎么判断一个字符串符合数据表中的哪条正则表达式值得数据?

Jun 06, 2016 pm 08:27 PM
mysql php WeChat Micro-channel public platform

Question 2. 如何判断一个字符串符合数据表中的哪条规则?

微信公众平台开发,

以课表开头 ,即 ^课表 由function1处理(当然这是设置在数据库中,现在举例将其固定化),

以 2015开头,即^2015 由function2处理,

完全等于报名,即^报名$ 由 function3处理。

在数据表中就是

rule function priority(优先级)
^课表 function1 1
^2015 function2 1
^报名$ function3 1
…… …… ……

如何拿到值判断其对应哪一条呢(假设不考虑优先级问题)?

Question 1. 如何判断一个数值在数据表的一条范围中

会员表,
ID,USERNAME,PASSWORD,TRUENAME,AVATAR,SCORE,BALANCE,ADD_TIME,REGIP

等级表,
0-100是 level1
101-500 level2
501-1500 level3

现在获取到用户的积分了,比如说是299.如何判断其是level2呢?

循环的确实是可以。但是效率不高。而且这是由用户设置的不固定。

回复内容:

Question 2. 如何判断一个字符串符合数据表中的哪条规则?

微信公众平台开发,

以课表开头 ,即 ^课表 由function1处理(当然这是设置在数据库中,现在举例将其固定化),

以 2015开头,即^2015 由function2处理,

完全等于报名,即^报名$ 由 function3处理。

在数据表中就是

rule function priority(优先级)
^课表 function1 1
^2015 function2 1
^报名$ function3 1
…… …… ……

如何拿到值判断其对应哪一条呢(假设不考虑优先级问题)?

Question 1. 如何判断一个数值在数据表的一条范围中

会员表,
ID,USERNAME,PASSWORD,TRUENAME,AVATAR,SCORE,BALANCE,ADD_TIME,REGIP

等级表,
0-100是 level1
101-500 level2
501-1500 level3

现在获取到用户的积分了,比如说是299.如何判断其是level2呢?

循环的确实是可以。但是效率不高。而且这是由用户设置的不固定。

你两个问题,可不可以换位思考一下,举例来说,问题一
0-100是 level1
101-500 level2
501-1500 level3
你在会员表里面记录用户的积分字段,299就是一个数值,然后你对这些等级,做一个配置文件,这个可以是你定义或者交给用户去定义生成的配置文件,符合某个数值断的,就是哪个等级,不需要额外的判断

Q1 可以做个常量数组或者通过后台配置一个config文件,每次取到信息后去数组里取一下level就好了

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? Apr 01, 2025 pm 03:03 PM

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

A summary of the top ten digital virtual currency exchange apps apps in 2025 A summary of the top ten digital virtual currency exchange apps apps in 2025 Mar 27, 2025 pm 07:18 PM

The top ten digital virtual currency trading apps in 2025 are as follows: 1. OKX, 2. Binance, 3. Gate.io, 4. Bybit, 5. Kraken, 6. KuCoin, 7. Bitget, 8. HTX, 9. MEXC, 10. Coinbase. This ranking is based on comprehensive evaluations such as security, liquidity, user experience and feature richness.

The latest rankings of the top ten virtual currency app exchanges in the 2025 currency circle The latest rankings of the top ten virtual currency app exchanges in the 2025 currency circle Mar 27, 2025 pm 07:27 PM

The top ten virtual currency trading apps in 2025 are as follows: 1. OKX, 2. Binance, 3. Gate.io, 4. Bybit, 5. Kraken, 6. KuCoin, 7. Bitget, 8. HTX, 9. MEXC, 10. Coinbase. This ranking is based on comprehensive evaluations such as security, liquidity, user experience and feature richness.

How to efficiently integrate Node.js or Python services under LAMP architecture? How to efficiently integrate Node.js or Python services under LAMP architecture? Apr 01, 2025 pm 02:48 PM

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

PHP optimistic locking combined with transaction deduction balance failed: How to ensure that the balance is correctly deducted in concurrency situations? PHP optimistic locking combined with transaction deduction balance failed: How to ensure that the balance is correctly deducted in concurrency situations? Mar 31, 2025 pm 11:42 PM

Detailed explanation of the problem of deducting balances in combination with PHP optimistic locks and transactions in this article will analyze in detail a balance deduction using PHP, optimistic locks and database transactions, only...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What should I do if the company's security software conflicts with applications? How to troubleshoot HUES security software causes common software to fail to open? What should I do if the company's security software conflicts with applications? How to troubleshoot HUES security software causes common software to fail to open? Apr 01, 2025 pm 10:48 PM

Compatibility issues and troubleshooting methods for company security software and application. Many companies will install security software in order to ensure intranet security. However, security software sometimes...

How to share the same page on the PC and mobile side and handle cache issues? How to share the same page on the PC and mobile side and handle cache issues? Apr 01, 2025 pm 01:57 PM

How to share the same page on the PC and mobile side and handle cache issues? In the nginx php mysql environment built using the Baota background, how to make the PC side and...

See all articles