Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    increment letters in a loop

    hi all,
    i am looking for a method to increment letters in a loop.
    i am new, but quite confident with a loop with a numerical increment..

    I have an array with the following information contained in it. They are seat is's stored in $seatid.

    a1,a2,a3, b1,b2,b3,c1,c2,c3 etc until p1,p2,p3

    I want to split the array into html rows using a loop, so outputted will be

    a1,a2,a3
    b1,b2,b3
    etc

    appreciate the help,


    dan

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Is that order always the same?
    For example, the 6th element of the array is always C1 (arrays start at 0).

    If that is the case, the array element doesn't have to be C1 ... because you know $seatid[6] is always C1.

    Describe what you're doing ... because I think you might discover a better scheme for doing this.

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts
    mlseim,
    I am to display a theatre seat layout.
    The user of my system will select a checkbox that corresponds to each seat.

    This is my plan:
    http://dl.dropbox.com/u/15253486/mht/theatre_layout.doc


    Cheers!

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    One more question ...
    You say you have an array. But how is the data actually stored permanently, MySQL, XML, or a plain text file?

  • #5
    New Coder
    Join Date
    Dec 2011
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts
    its a mysql table called tbl_seats.
    It has 3 fields SeatID, SeatZoneID, SeatDesignationID

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    This is going to be hard to explain ... but I'll try ...

    Maybe you could create a GUI (graphical user interface)
    that looks like your map? You could give each
    square a CSS class, and use the database to change
    the background color and image within. That image
    would allow them to click to reserve, or it would not
    be a link if the seat was taken ... they could not click
    on if it was reserved, unless they were the person logged-in.

    In this example, a2 and a3 are reserved.

    <div class="row">
    <div class="a1"><a href="reserve.php?id=a1"><img src="reserve_me.png"></a></div>
    <div class="a2" style="background-color:#ee0000";><img src="reserved.php"></div>
    <div class="a3" style="background-color:#ee0000";><img src="reserved.php"></div>
    <div class="a4"><a href="reserve.php?id=a4"><img src="reserve_me.png"></a></div>
    <div class="a5"><a href="reserve.php?id=a5"><img src="reserve_me.png"></a></div>
    </div>
    <div style="clear:both;"></div>
    <div class="row">
    <div class="b1"><a href="reserve.php?id=b1"><img src="reserve_me.png"></a></div>
    <div class="b2"><a href="reserve.php?id=b2"><img src="reserve_me.png"></a></div>
    <div class="b3"><a href="reserve.php?id=b3"><img src="reserve_me.png"></a></div>
    <div class="b4"><a href="reserve.php?id=b4"><img src="reserve_me.png"></a></div>
    <div class="b5"><a href="reserve.php?id=b5"><img src="reserve_me.png"></a></div>
    </div>
    <div style="clear:both;"></div>


    The CSS class as defined in your .css style sheet would look like this:

    .a1{
    width:40px;
    height:50px;
    border:1px solid #000;
    background-color: #00ee00;
    float:left;
    }
    .a2{
    width:40px;
    height:50px;
    border:1px solid #000;
    background-color: #00ee00;
    float:left;
    }
    .a3{
    width:40px;
    height:50px;
    border:1px solid #000;
    background-color: #00ee00;
    float:left;
    }

    All of the HTML/CSS would be generated by the PHP.
    As you loop through the database, it would either put a link there, or
    an image (reserved). You could also affect the background color of the class.
    PHP would add inline CSS to affect changes.

    In summary, the "form" you are creating is actually a GUI (graphical user interface).

    You would also add more columns to each seat, such as customer ID (who reserved it).
    And you would also have duplicate MySQL tables, so you would use the same GUI
    for different shows (each table is a show). When a show is over, that table is deleted.

    And you could use javascripting (JQuery/AJAX) so when the click a seat, it puts
    a different image there until they "check out" and pay for them. My example is
    a link to a PHP script, but it wouldn't have to be (to eliminate a page refresh).

    Well, now I realize how elaborate a GUI would be, but wouldn't it be cool?
    A plain HTML form would be difficult to use.

  • #7
    New Coder
    Join Date
    Dec 2011
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts
    mlseim,

    I appreciate the effort that you have put in, in reply to my post!

    I like the idea of using php generated css and html, but i am unsure what you mean on a couple of areas:

    I take it that the following is an example of code that has been outputted from the server?

    1) <div class="a2" style="background-color:#ee0000";><img src="reserved.php"></div>
    <div class="a3" style="background-color:#ee0000";><img src="reserved.php"></div>

    Should the imgsrc be reserved.png?

    2) I dont understand how i can implement a system that deletes tables after their expiry and still be normalized. The following is a link to my schema..
    http://dl.dropbox.com/u/15253486/mht/schema.docx

    3) I think the GUI idea of yours is the way forward, especially where controlling items on the page i concerned.


    Its worth mentioning at this point that the system is going to be designed as a closed circuit system with an operator at a till, rather than an online booking system. Also it is a not for profit task - it is an end of course project Ive been set!

    Cheers.

    Dan
    Last edited by djt4071; 04-16-2012 at 02:06 PM.

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I have an example for you ....

    Let's call this the "Seat Engine".

    Basically, you will have a table with rows. Each row is a seat.
    There will be a seat ID (location, like E4), and the status of the seat (open, reserved),
    and the cost of the seat, the person who reserved it, etc.

    A PHP script will use a CSS stylesheet to render the graphic seating chart using the database (array).

    Here is my working example with demo on picking one seat at a time.
    It's just a "proof of concept" on making it work.

    See the test page:
    http://www.catpin.com/theater/

    Here is the CSS file:
    http://www.catpin.com/theater/seats.css

    And the icon for the reserve a seat link:
    http://www.catpin.com/theater/icon_checkbox.png

    Here is the main file showing how it will builds the graphic display (index.php).
    Since I'm not using MySQL in this example, I just use a plain array with only seat ID's.
    Scroll around and pick a seat ... you'll see it turn red.

    The real script of course would allow picking multiple seats, and reserved seats would not have the link.

    PHP Code:
    <?php

    $seats
    =array("A1","A2","A3","A4","A5","A6","A7","B1","B2","B3","B4","B5","B6","B7","B8","C1","C2","C3","C4","C5","C6","C7","C8","D1","D2","D3","D4","D5","D6","D7","D8","E1","E2","E3","E4","E5","E6","E7","E8","F1","F2","F3","F4","F5","F6","F7","F8","G1","G2","G3","G4","G5","H1","H2","H3","H4","H5","H6","H7","H8","J1","J2","J3","J4","J5","J6","J7","J8","K1","K2","K3","K4","K5","K6","K7","K8","L1","L2","L3","L4","L5","L6","L7","L8","M1","M2","M3","M4","M5","M6","M7","N1","N2","N3","N4","N5","N6","N7","O1","O2","O3","O4","O5","O6","P1","P2","P3","P4","P5","P6");

    $pick=$_GET['s'];

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Theater Seating</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link href="seats.css" rel="stylesheet" type="text/css" media="all" />
    </head>

    <body>
    <div id="wrapper">

    <div id="largeview">
    <?php
    foreach($seats as $seat){
    $box "<div id=$seat>$seat<br /><a href='index.php?s=$seat'><img src='icon_checkbox.png' alt='Reserve This Seat' title='Reserve This Seat' /></a></div>";

    if(
    $seat==$pick){
    $box "<div id=$seat style='background-color:#ff0000;'>$seat<br /></div>";
    }

    if(
    $seat=="P4" || $seat=="P5" || $seat=="P6"){
    $box "<div id=$seat>$seat<br /></div>";
    }

    echo 
    $box;

    }
    ?>
    </div>

    </div><!-- end wrapper -->
    </body>
    </html>

    I hope this will get you started on some ideas.

    I really think you're making your MySQL tables harder than they need to be.
    One table for user profiles (name, email, address, phone, etc).
    One table for each show ... that table has a row for each seat.
    that's it ... no more tables.

    NOTE:
    And keep in mind that you can design the seating map to fit an iPad.
    Maybe the theater concierge doesn't need to sit behind a desktop PC.


    .
    Last edited by mlseim; 04-16-2012 at 08:04 PM.

  • #9
    New Coder
    Join Date
    Dec 2011
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts
    mlseim,
    Excellent example!

    I had no idea that CSS was so powerful!

    In response to your comments about the tables - i agree that the tables are perhaps over complicated. However due to this being a school project, I have taken extra care to ensure that the information is stored in a database that is normalized. In other words, if I have seat information, and show information and customer information all contained in the one table - surely that is not conforming to normalization standards??

    Now! To integrate with PHP!!!

    Cheers mate!

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You're correct about normalization ... probably a good idea to stay on that road.
    That won't affect the "seating display engine" though. You can do various JOIN's to
    connect relationships with the various tables.

    The "seating display" needs to know:
    The seat number (or ID).
    The status of the seat (open or reserved).
    Special configurations (disabled seating, no seating, special reservations, etc).

    The "seating display" doesn't care who the person is that has purchased the seat.
    Nor does it care what show it is ... but you do have to make sure your query only
    selects results for one show when displaying seats. You don't want to show open
    seats for a show, when in fact the seat is taken.

    To avoid page refreshes on the "seating display", you can also use AJAX (combination
    of PHP and javascripting, or JQuery). It's a bit more work to program though.

    In the end ... make sure you show us what you have (some sort of demo) ...
    I'd be interested to see how it came out.



    .


  •  

    Posting Permissions

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