filter_var当用户注册我的网站时,我使用PHP函数来验证电子邮件地址.
我使用帖子中的代码:
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
Run Code Online (Sandbox Code Playgroud)
后来我做了:
if(!$email) {
// return to the form
}
else {
// send registration info
}
Run Code Online (Sandbox Code Playgroud)
现在当我var_dump($email),我得到输出:
string(23) "user."name"@example.com"
Run Code Online (Sandbox Code Playgroud)
我想知道为什么这不会返回错误.我认为双引号是不可接受的,那么为什么PHP说它有效?
我想在我的仪表板中显示前5个产品,在每个产品上我想显示订单总数,视图以及该产品基于其他产品的位置百分比:
Game 1 for Xbox (200 orders / 1000 views) 20%
Game 2 for WII (180 orders / 2100 views) 18%
Game 3 for PS3 (170 orders / 390 views) 17%
Game 4 for PS3 (90 orders / 1400 views) 9%
Game 5 for WII (20 orders / 30 views) 2%
Run Code Online (Sandbox Code Playgroud)
所以1000个订单中的1000个订单中的200个订单是总订单的20%.这意味着,我的产品中有20%是游戏1
这是我的查询:
select
products.name, products.type, products.views, count(*) as orders, ????????
from
products
inner join orders on (products.id = orders.product_id)
group by orders.product_id
Run Code Online (Sandbox Code Playgroud)
我怎么得到这个百分比?
我必须检查我销售的产品(主要是游戏机和游戏)
我想看看哪些产品有哪些类别,这是我的查询:
select * From products left join products_categories on (product_id=id) ;
+------+------+------------+-------------+----------
| id | name | product_id | category_id | and more
+------+------+------------+-------------+----------
| 4 | Xbox | 4 | 2 |
| 5 | PS3 | 5 | 2 |
| 7 | BAD | NULL | NULL |
etc...
+------+------+------------+-------------+---------
Run Code Online (Sandbox Code Playgroud)
在这里,我有一个产品(#7 - BAD),我不想看到,因为我删除了类别,
我不希望看到没有类别的产品?
我对我的汽车系统的数据库设计有一个困境(我父亲拥有经销商,我想建立一个新的系统,用户可以安排测试驱动,apptointmen等...)
我不确定这两种型号:
table car
id int, model_id int, make_id int, price float, year year, millage int, etc...
Run Code Online (Sandbox Code Playgroud)
要么
table car
id int, model enum, make enum, price float, year year, millage intetc...
Run Code Online (Sandbox Code Playgroud)
客户表(id int,name varchar,phone int,street varchar,city等...
salemen表(id int,name varchar等...
schedule table(id int,appt_Date datetime,car_id,customer_id,salemen_id)
现在我的问题是:
我应该使用枚举字段还是应该为每个枚举字段设置一个表?一旦所有人都使用它并重新开始,我不想重新设计系统.
谢谢