Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Adding from two different fields
Old 10-06-2004, 05:26 AM Adding from two different fields
Junior Talker

Posts: 3
Trades: 0
Hi,

I'm currently developing a database on my site and I ran into a little bit of a problem. Actually its more of I'm trying to make something more convienient. The database is a list of all the movies that I own and I want to make it so that the field "mplayernum" automatically gets it's number by using the field "mdiscnum" from the previous entry and adds 1. I'm not sure how easy this is, but if anyone can help it would be greatly appriciated.

Thanks,

FallenRayne
fallenrayne is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-06-2004, 07:16 AM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
you need to select the mdiscnum and instead of looping around all the results just call fetch_row (mysql's eqiuv).

so instead of calling

while ($row = mysql_fetch_row())){

}

just call $row = mysql_fetch_row()

$id = $row['mdiscnum']

this then return the last row in the table and hey presto you have your last mdiscnum.

Now simply update your new entry

update TABLE set mplayernum = $row['mdiscnum'] +1;

You could also make the mplayernum 'auto increment' so that you just keep adding 1 to it anyway.

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 10-06-2004, 07:25 AM
Junior Talker

Posts: 3
Trades: 0
Thanks for the quick reply on that. I will try it and see how it works. Still new to PHP so it will probably take me a bit to figure this one out

FallenRayne
fallenrayne is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Adding from two different fields
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11242 seconds with 12 queries