NamePros.Com (http://www.namepros.com/)
-   Programming (http://www.namepros.com/programming/)
-   -   while...this....that.......*goes mad* (http://www.namepros.com/programming/15848-while-this-that-goes-mad.html)

adam_uk 12-19-2003 08:14 AM

while...this....that.......*goes mad*
 
sup people

ok this is begin to drive me barmy so i thought id come here for your help.

ive got a table (mysql) with peoples names in it (max of 30 names per row and im gonna have 5 rows)

now this row will start off with 30 names in it and over time someone may leave meaning that say one of the rows will loose a person.

Ive done all this but now if say another person leaves it will make 28 people in that row.

now i need to make a script so that someone can add a person to that colum

so im not sure if thers a better way to do this but the way i think it needs to be done like this

1. person enters name
2. query checks database for first avallbe feild
3. ends query when it gets to first avalible feild or somehow rmemebers first one
4. enters name into that feild
5. finishes up and closes

now im stuck at number 2

i need to find a way to scan the row for the first avalbile feild but i have no idea how


any ideas?

sorry for the long post

blouis 12-19-2003 08:31 AM

perhaps this will help you

insertData($inputTable, $inputField, $inputValue)

The first parameter is the table name.

The second parameter is the name of the field that will have data added to it. This can be an array of field names if updating more than one field.

The last parameter is the value to add to the table, again if adding more than one value make this parameter an array.
If adding an array of values then the array of field names and the array of values to add should be the same size

let me know if that helps you.

it doesnt really scan like you want it to but its adding a person to a table.

adam_uk 12-19-2003 04:38 PM

thanks ill try that out monday when i get back to work

roy 12-23-2003 04:54 PM

I 'think' I 'might' understand what you mean... So, are these names numbered, like 1 - 30, then say person 5 leaves, then 5 is empty? Person 10 leaves, 10 is emtpy.. so theres like gaps in the rows?

If thats what you mean, then you could do something like this everyone someone is deleted from a table:

update tablename set number=(number -1) where number >(one less than the one you just deleted);

So if you were to delete Name 6, then 7 would become 6... 8 would become 7..etc.. and then you could just add new names on to the end of the table...

just an idea..

if for some reason you didn't want to do that and just wanted to fill in the empty spot, like if 5 isnt taken just stick something in 5, i could probably figure that out too....but i'm going to go get some soda or something now...

adam_uk 12-24-2003 12:49 PM

Quote:
Originally posted by roy
I 'think' I 'might' understand what you mean... So, are these names numbered, like 1 - 30, then say person 5 leaves, then 5 is empty? Person 10 leaves, 10 is emtpy.. so theres like gaps in the rows?

If thats what you mean, then you could do something like this everyone someone is deleted from a table:

update tablename set number=(number -1) where number >(one less than the one you just deleted);

So if you were to delete Name 6, then 7 would become 6... 8 would become 7..etc.. and then you could just add new names on to the end of the table...

just an idea..

if for some reason you didn't want to do that and just wanted to fill in the empty spot, like if 5 isnt taken just stick something in 5, i could probably figure that out too....but i'm going to go get some soda or something now...


i didnt wanna do anything like that delete stuff, to much work et etc


All times are GMT -7. The time now is 12:04 AM.
Site Sponsors
Advertise your business at NamePros

Powered by: vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0