hi everyone am a novie in php world. i was asked to creat a database and a table which i did but now i created a form which has the following client,fullnames,commissioning date, expiry date, email, telephone, vehicle type, subsribtion. i inserted the values into mysql database. but now i want to create a search field which when the enter the client name, it will generate the expired field of the table

Recommended Answers

All 8 Replies

Member Avatar for diafol

Why will it generate the expiry date? You have the expiry date in the form so it should be in the DB already, shouldn't it?

exact match

$sql = "SELECT * FROM mytablename WHERE `fullnames` = '$searchname'";

or search by name parts

$sql = "SELECT * FROM mytablename WHERE `fullnames` LIKE '%$searchname%'";

tanx a lot its working

but am having another problem, i want to view all active users from the table database using date that is not more than one year

Member Avatar for diafol

Have you studied SQL syntax? To retrieve use

SELECT ...list of fields you need... FROM ...tablename... WHERE ...fieldname... = ...value...

In your case you'll want the WHERE clause to have a function instead of a simple fieldname...

DATEDIFF(NOW(), expiry_date) <= 365

Maybe something else to take into account leap years.

please can u give me the full php code to that? cuz am a beginner tank u

Member Avatar for diafol

I see that you've opened a new thread to ask the same question again.

http://www.daniweb.com/web-development/php/threads/472595/date-range

Please keep your posts organised. There's no need to open a new thread, even if you do not find a contributor's post useful - that's just rude.

In addition, although we are here to help, it is not our job to give you complete solutions or write all the code for you. We are all volunteers and post what and when we can. It's YOUR job to provide US with the code, telling us where it's going wrong.

ok thank u alot i appreciate ur kind help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.