I am only beginner in this. I don't understand all of code, most of it was given to me to work on.

I am trying to do checks on MySQL on workshift table. There is dayshift, eveningshift and nightshift (Other two fields are shiftid, name and date). They are drop down box with y for yes and n for no. They are allowed to work ONE workshift a time. They are NOT allowed to do more than 1 workshift. When inserting data using form from PHP, if I picked y for dayshift and eveningshift, it shouldn't allow me do that maybe pop up box say its not allowed or something.

I don't know how to do that sort of checks.

//$query = "SELECT name,owner,species,sex,birth FROM pet WHERE name!='fluffy' ORDER BY name";
$header = "WORK SHIFTS";
$table = "workshift";
$query = "SELECT * FROM ".$table." ORDER BY DATE ASC";
$query = "SELECT * FROM ".$table." WHERE 'n' NOT IN (DAYSHIFT, EVENINGSHIFT, NIGHTSHIFT)";

Can you help me soon please?

Recommended Answers

All 4 Replies

I think you really have to at least attempt to do your homework not just ask people how to start. First of all try to figure out the logic of it and write it out in pseudocode(words) before even starting. Then give us what you've got cause up there you ain't got anything, even worse you have pointless/confusing comments:

//$query = "SELECT name,owner,species,sex,birth FROM pet WHERE name!='fluffy' ORDER BY name";

I know it doesn't belong but it looks like honestly you don't care about the coding at all, you just want it done.

Member Avatar for diafol

Have to agree. Get a book and work your way through it. You'll need to know the basics in case you need to change the code at a later date.

However, you'll probably want client-side and server-side validation on your form. The javascript should disable the option of too much night shifts automatically (if user has to login - then data can be loaded into the form beforehand). BUT do not rely on client-side validation, this can be circumvented quite easily. Your server-side validation should query the database for a nightshift entry, either prior to the insert query or as a clause in the actual insert query itself.

I think you really have to at least attempt to do your homework not just ask people how to start. First of all try to figure out the logic of it and write it out in pseudocode(words) before even starting. Then give us what you've got cause up there you ain't got anything, even worse you have pointless/confusing comments:

//$query = "SELECT name,owner,species,sex,birth FROM pet WHERE name!='fluffy' ORDER BY name";

I know it doesn't belong but it looks like honestly you don't care about the coding at all, you just want it done.

That code above you put in was given to me in assignment. That bit is on every page for each table. It there for example.

I been at this for hours and can't find anything on internet to do this.

I can't buy a book cos you need order it on internet and get it delievered at home, there not enough time to do that. I had 2 weeks to do this (Other bits was was fine, it only this is problem). Now got last couple of days.

I have done some basic. I learnt all basics from w3schools.com website. It doesn't have any sort of checks entering data into table if it is allowed or not. BTW, I don't need to change code later date. When this is handed in then thats it.

I have been looking for validation on internet but can't find right one to do with this. Can you tell me what sort of validation function for MySQL or PHP then I will try work out the code for it.

Member Avatar for diafol

That code above you put in was given to me in assignment

.

Giving you answers to your assignment questions would be cheating!

You don't have to buy a book on the internet, most good bookshops will sell you a book on pHp/MySQL. In addition, almost everything you need to know will be in electronic format somewhere on the internet in the shape of tutorials.

You just need to make the effort.

I will however give you a clue:

The table needs to have one field for SHIFT. The datatype can vary, but you could choose 'char' with valid entries = 'n' or 'e' or 'd'. You then specify a date and user_id in the same table. If a record exists for a person, you cannot insert only update. If no record, only insert not update.

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.