Results 1 to 11 of 11

Thread: [RESOLVED] Need help with code

Threaded View

  1. #10

    Thread Starter
    Addicted Member
    Join Date
    May 2009
    Posts
    166

    Re: Need help with code

    No problem about the long post. Sorry to make you go through all that though. I've read through it three times now, trying to grasp it all. I wasn't even close to having it set up right.

    The original code in my update.php file was:

    PHP Code:
    $query_2 "update books set price = "4.99" where isbn = '1-010-23456-1'"
    They must have wanted me to update books for that one single isbn but I didn't know how it related to making selections on my form. Maybe they were trying to show me that the variables could equal those values if I choose '1-010-23456-1' and type in a price of 4.99. My query would give me the error message that query faild, then when I changed my line to:

    PHP Code:
    $query_2 "update books set price = 'value' where isbn ='$result_2'"
    I was at least getting "Query Successful" message.

    I forgot it was there, but the include of connect.php was in that file. It was at the top and not in the code I pasted. There were queries for insert, update and select and I was only working with the update query. So my query was actually accessing MySQL but not really doing anything without the $_Post in front of the ['ISBN']. I'm still a little foggy on that but I will just accept that it needs to be like that or rather than just a string.

    I knew what the price was for that ISBN before I tried to update it and when I went into MySQL just to see if it did change I found that it hadn't. It makes sense though about using the function you mentioned, mysql_affected_rows() to get confirmation if anything actually changed.

    I wasn't even thinking about the aspect that people familiar with html could still bypass the drop down menu and submit a different isbn. I think my text was just trying to tell me that having a drop down list was superior then having someone type a selection in. The drop down list doesn't give the user an opportunity to mistype something. Someone like me with terrible typing skills would easily leave out a dash or be off a digit in the sequence.

    Thanks for showing me the while loop. I'm still trying to sort it out but anything to make it easier to read is helpful.

    I tried inserting the code you showed me and I successfully updated the price on the isbn I selected. That was great! It was sure easy to take things for granted on the Internet when you don't really know what is taking place behind the scenes like what you just walked me through and that's probably as easy as it gets. Am I right? Wow!!

    Again, sorry you had to go through so much. I'll keep going over this and hopefully it will make sense.
    Thank you.
    Last edited by Blue1974; Apr 10th, 2010 at 09:46 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width