Jump to content

Savizzaviz

Members
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Savizzaviz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well I kind of left this for a couple months here, but when I return to it I see I have the same problem. I think I might have set up my database in a kind of conveluted way, though. Basicly it\'s like this: album_id | track_numb | track_title and then I have another table that has all the other album info. So the album_id coresponds to an album_id in that table and is therefore the same for all the tracks on that album. I cant seem to figure out, though, how to input that properly, all from one submit of a form (with all the tracks). I was thinking I might need an auto incremented track_id, but I\'m not sure how to implement that so it helps with my script. What I have tried is to have the whole form just INSERT into the table with this code: INSERT INTO album_tracks (album_id,track_numb,track_title) VALUES (\'$record\',\'$track_number\',\'$track_title\') but it appears that it just puts in the last row in the form (which would have the highest track number). Any ideas?
  2. Yeah, that\'s what I figured. Just thought I\'d make sure, though, before I get-a-codin\' again. Thanks again. I\'m sure I\'ll be back with more problems later. :roll:
  3. Ah. Okay. I think I can see how to use that. Thanks. But now I have another question. I will be able to submit multiple entries at a time into the table even if they have the same column values, right? \'Cause I\'m going to have track number and album title entering into the table in the same query, over and over again for each track. Will these just be added in order of how they are in the HTML form or will it start overwriting them or get them out of order somehow?
  4. This is going to be kind of a hard one to explain, but here goes... I have a database setup for a CD review script, which will have the track listings in it. I also have a web-based update sytem that allows you to enter in the track info using forms. The best way I could think to make this work was to have a page to ask how many tracks you wanted then it generates another page with that many fields, which you can use to fill in the track information. The problem I found was when I got to the submit part. The CD information and the track information have two seperate tables and the track table has three main columns: The album ID (which matches the album ID of the other table), the track number, and the track title. Now I want it to, when you click submit, to submit each field into the database with the same album ID, accending track numbers, and the titles. I\'m completely lost on how to do this all in one submit. I\'m sure this is a simple SQL code, but I cant seem to come up with it. I guess that\'s all I have to say for now. Thanks for at least reading my post. :wink:
  5. Hmm, good catch... I hadn\'t noticed that (I\'m using Mozilla Firebird and it seems to only happen in IE). It should work now.
  6. Hey, thanks, that did it. I had to change \"ORDER BY story_num\" to \"story_numb\" but it worked. If you want, you can check it out here (You wont be able to add stories, though, obviously ). If you see anything wrong with any of my scripts, I\'d appretiate a message. Thanks for the help.
  7. Oh, and I\'m thinking the method for getting the last story_id might not work properly, since my story_id variables aren\'t all in a 1, 2, 3, 4 order seeing as some of the rows get deleted. I was thinking there\'d be a way to do it within the SQL query so as to select the last row somehow.
  8. Heh... Well I can\'t seem to get it to work properly. I tried it your way and a few other ways, but the only thing that would even slightly work was: [php:1:8a620cf238] } else { $published = date(\"Y-m-d\"); $newstory = mysql_insert_id(); $laststory = $newstory - 1; $getlast = \"SELECT story_numb FROM stories WHERE story_id = $laststory\"; $query = mysql_query($getlast); $getlastnum = mysql_fetch_array($query); $lastnum = $getlastnum[story_numb]; $number = $lastnum + 1; $sql = \"INSERT INTO stories (story_numb,story_title,story_pub,story_desc,story_body) VALUES (\'$number\',\'$title\',\'$published\',\'$desc\',\'$body\')\"; } [/php:1:8a620cf238] That, though, only made the number 1, which it continued to do forever. I think the problem might be in the mysql_insert_id() but I don\'t know how to fix that... Have you sobered up enough to help? :wink:
  9. So I\'m running a mySQL database and using PHP to script an add/update form for the rows in my table, which I do like this: [php:1:2a88340347]if ($submit) { // If ID is present, update the current row if ($id) { $sql = \"UPDATE stories SET story_title=\'$title\',story_desc=\'$desc\',story_body=\'$body\' WHERE story_id=$id\"; // Else create a new one } else { $published = date(\"Y-m-d\"); $sql = \"INSERT INTO stories (story_title,story_pub,story_desc,story_body) VALUES (\'$title\',\'$published\',\'$desc\',\'$body\')\"; } $result = mysql_query($sql);[/php:1:2a88340347] Now what I want to do is make it so that when you create a new row, a story_numb field is automaticly updated to the next number up from the last one in the story_numb field according to the last story_id (auto_increment) number. So basicly generate the next highest number for the new story. Anyone know how I could even do something similar that?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.