webwired's Profile User Rating: -----

Reputation: 33 Craftsman
Group:
Contributors
Active Posts:
339 (0.14 per day)
Joined:
26-August 07
Profile Views:
8,419
Last Active:
User is offline Sep 08 2012 07:13 AM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
AMD
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
100

Latest Visitors

Icon   webwired has not set their status

Posts I've Made

  1. In Topic: Help with loops

    Posted 7 Sep 2012

    View Postmodi123_1, on 07 September 2012 - 09:17 PM, said:

    Everyone relax a bit. webwired - in the future if you are not getting errors, but instead getting odd behavior it's best to also explain what you would like the behavior to do in addition to what you put down (what it is currently doing). Once everyone has a picture then everyone can join arms and skip down the path of help and learning together! (humming Kumbaya is optional) ;)


    You bet :rolleyes:

    View PostCTphpnwb, on 07 September 2012 - 09:07 PM, said:

    It looks like you're trying to use $i to display time slots through the day, but you're doing that before you've got all the time slots. I would read everything into an associative array where the time is the key and then display the array. That way I could initialize the array to all blank values and used the database to fill in whatever it finds.

    By the way, you really should be using prepared statements and not deprecated mysql* functions.


    I'm going to have to meditate on the Associative Array solution... Sounds like a plan, just takes me a while to put it together in my head first...

    As far as the deprecated mysql, I know... It's all I know for now though, this application just has to last a little while before I have it professionally rewritten...
  2. In Topic: Help with loops

    Posted 7 Sep 2012

    View PostCTphpnwb, on 07 September 2012 - 08:50 PM, said:

    So your problem is that the code is doing what you told it to do? The solution then is simple: don't tell it to do that! If it's something else, please tell us. Maybe you could start with why you've put a for loop inside a while loop.


    Well, with the FOR loop I'm creating a scheduling calendar... With the WHILE loop I was pulling from the database any appointments that fall in the calendar's timeline... When I wrote the code I only used one appointment to test it with... after I started adding other appointments on the same day I realized that I had put a loop inside of a loop... but now can't think of a way to write the code so that it's not a loop inside of a loop...

    $BeginningDateTime = date('Y-m-d 00:00:00', strtotime($SelectedDay));
    $EndingDateTime = date('Y-m-d 23:59:59', strtotime($SelectedDay));
    $query = "SELECT OrderTickets.*, Appointments.* FROM Appointments LEFT JOIN OrderTickets ON Appointments.OrderTicketID = OrderTickets.OrderTicketID WHERE Appointments.AppointmentStartDateTime BETWEEN '$BeginningDateTime' AND '$EndingDateTime'";
    $result = mysql_query($query);
    while ($row = mysql_fetch_assoc($result))
    {
        for ($i=1;$i<25;$i+=0.25)
        {
            $rowCounter += 1;
            echo '<tr class="'.OddOrEven2($rowCounter).'">';
            echo '<td class="time"> '; 
            if ($i > 12.5){$e = $i - 12;} else {$e = $i;} 
            $e = number_format($e, 2, '.', ' ');
            list($whole, $decimal) = explode('.', $e);
            if ($decimal == 25){$decimal = 15;}
            if ($decimal == 50){$decimal = 30;}
            if ($decimal == 75){$decimal = 45;}
            if ($whole == 0){$whole = 12;}
            if ($i < 12 || $i == 24){$f = 'am';}else{$f = 'pm';}
            if ($decimal == 00){echo $whole.':'.$decimal.' '.$f;}
            echo '</td>';
    
            $theBeginningTime = date('H:i:s', strtotime($row['AppointmentStartDateTime']));
            $theEndingTime = date('H:i:s', strtotime($row['AppointmentFinishDateTime']));
            $theTime = $whole.':'.$decimal.' '.$f;
            $LoopTime = date('H:i:s', strtotime($theTime));
            if ($LoopTime == $theBeginningTime || $LoopTime == $theEndingTime || ($LoopTime > $theBeginningTime && $LoopTime < $theEndingTime))
            {
                echo '<form id="CalendarCell" action="calendar.php?eventaction" method="post">';
                echo '<input type="hidden" id="AppointmentID" name="AppointmentID" value="'.$row['AppointmentID'].'" />';
                echo '<input type="hidden" id="SelectedTime" name="SelectedTime" value="'.$LoopTime.'" />';
                echo '<td class="appointment" style="background-color: #7C92AA;">';
                if ($LoopTime == $theBeginningTime)
                {
                    echo date('g:i a', strtotime($row['AppointmentStartDateTime'])).' - '.date('g:i a', strtotime($row['AppointmentFinishDateTime'])).'<br />';
                    if (!empty($row['OrderTicketID']))
                    {
                        echo $row['OrderTicketFirstName'].' ' .$row['OrderTicketLastName'].' - '.$row['OrderTicketZipCode'].'<br />
                        '.FetchRequirements($row['OrderTicketID']);
                    }
                    else
                    {
                        echo '<pre>'.$row['WhatsHappening'].'</pre>';
                    }
                }
                else
                {
                    echo '&nbsp;';
                }
                echo '</td>';
                echo '</form>';
            }
            else 
            {
                echo '<form id="CalendarCell" action="calendar.php?eventaction" method="post">';
                echo '<input type="hidden" id="SelectedTime" name="SelectedTime" value="'.$LoopTime.'" />';
                echo '<td class="appointment">&nbsp;</td>';
                echo '</form>';
            }
            echo '</tr>';
        }
    }
    
    
  3. In Topic: Help with loops

    Posted 7 Sep 2012

    View PostCTphpnwb, on 07 September 2012 - 08:35 PM, said:

    You haven't stated what the problem is so you should expect people to start from square one. Of course the for loop will be repeated for every record found in the table. That's what it means to put the for loop inside the while loop.


    If I didn't state what my problem was, then why did you just mention it in your reply?

    BTW: Sho Ke, stay away from my posts.
  4. In Topic: Help with loops

    Posted 7 Sep 2012

    View PostSho Ke, on 07 September 2012 - 08:10 PM, said:

    ..What exactly are you trying to do with those loops?


    Loop

    View PostSho Ke, on 07 September 2012 - 08:10 PM, said:

    Are you getting an error?


    No, if I had, one would think that I would have mentioned that.

    View PostSho Ke, on 07 September 2012 - 08:10 PM, said:

    Is that the full code?


    Let me answer your question with a question, do you typically find full code with open brackets?


    You know, I am, and I'm sure that I can't be the only one... That is sick and tired of someone like you posting the first reply to a post with absolute garbage... For future reference, if you don't have something to contribute to a post, STAY THE F**K AWAY!
  5. In Topic: PHP Loops problems

    Posted 28 Aug 2012

    Thank you Atli for a most excellent and detailed answered, it most appreciated.

    I do have some experience with LEFT JOINs, but lightly so, never doing what you have suggested, so thank you for making me aware of this method...

    EDIT: Added finished code...

    $query = "SELECT rt.RequirementType, (!ISNULL(otr.OrderTicketID)) AS 'checked'
                FROM RequirementTypes AS rt
                LEFT JOIN OrderTicketRequirements AS otr
                ON rt.RequirementType = otr.OrderTicketRequirement
                AND otr.OrderTicketID = '{$row['OrderTicketID']}' 
                ORDER BY rt.RequirementTypeOrder ASC";
    
    $result = mysql_query($query);
    $resultCounter = mysql_num_rows($result);
    $resultCounter = ceil($resultCounter / 2);
    $myCounter = 0;
    while ($row = mysql_fetch_assoc($result))
    {
        $myCounter++;
        if ($myCounter <= $resultCounter)                                                
        {
            echo '<input type="checkbox" name="OrderTicketRequirements[]" value="'.$row['RequirementType'].'"'; if ($row['checked'] == 1){echo ' checked ';} echo '/>'.$row['RequirementType'].'<br />';
        }
    }
    
    

My Information

Member Title:
D.I.C Regular
Age:
41 years old
Birthday:
October 26, 1972
Gender:
Location:
St. Louis, MO
Years Programming:
11
Programming Languages:
VB .NET, C# .NET, ASP .NET, PHP

Contact Information

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://tocodein.net

Friends

Comments

webwired has no profile comments yet. Why not say hello?