Solved

Check database for similar record

Posted on 2013-01-09
3
158 Views
Last Modified: 2013-02-07
I am working on a ticket tracking system for a baseball team. All of their season ticket holders are in the database. Players are assigned ticketholders to sell tickets to so the query pulls up everyone assigned to a player that bought a ticket in 2012.

They can click on Renew and change the year to 2013 and it will show that the ticket holder bought in 2013 and show in a list at the top of the same page.

What I would like to have is when they renew, have a field in database (Renewed) be marked as YES so when the print their call list, they know who has renewed this year.

This is my update SQL...
      $sql = "UPDATE Passes1 SET THID='$THID', MoneyCollectedDate='$MoneyCollectedDate', Year='$Year', Buddy='$Buddy', Charity='$Charity', Comments='$Comments', CheckNumber='$CheckNumber', TicketNumber='$TicketNumber', TicketType='$TicketType', AmtCollected='$AmtCollected' WHERE PassID='$contacts_id'";
            $update_result = mysql_query($sql);
                    if (!($update_result))
                  {
                        echo mysql_error();
                        echo "<br>\n";
                        echo "$sql<br>\n";
                        exit;
                  }

How do I update the row like this as well IF there is a source_id?
$pass_sql = "UPDATE Passes1 SET Renewed='1' WHERE PassID='$source_id'";
0
Comment
Question by:katlees
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 41

Expert Comment

by:Sharath
ID: 38761336
Do you have additional column as 'Renewed' in your table? If yes, you can update that flag in the first UPDATE statement itself. No need of second UPDATE statement.
0
 

Author Comment

by:katlees
ID: 38761343
Yes, there is a column of Renewed... the first update statement creates the NEW record.. the 2nd update statement would update the current record...

So if there is a record of
ID - 56
Name - Smith
Year -  2012
Renewed - 0

If they click on the renewed and change the year to 2013 a new record would be created with
ID - 57
Name - Smith
Year -  2013
Renewed - 0

And the old record would become
ID - 56
Name - Smith
Year -  2012
Renewed - 1
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 38761541
Make a Google search for this exact phrase: Should I Normalize My Database.  There are arguments on both sides of the question and it is part art and part science.  You will find good and thoughtful reading in the pages that are responsive to that query.  

In the instant case, it looks like your answer would be, "yes" because a data base that has a "renewed" column would ignore the year - a design flaw with confusing consequences.  You might want to have a table of clients, a table of seats, a table of clients-and-seats, etc.  This is actually a fairly well understood design pattern (think MLB, NFL, StubHub, etc) and it is not a simple data base design, but if implemented correctly it will work with flawless precision and accountability.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question