Jump to content

Recommended Posts

What I'm trying to do is work on how it's going to combine the matchArray and segmentArray into the masterArray. The method for combining both is through the segmentOrder part of the segmentArray. It orders the Introduction and Matches into the masterArray with the Introduction always first followed by the Matches in order THEN IF there are segments it takes the each segment and finds out the value of the segmentOrder and then matches its value to the masterArray where if the value of Segment 1's segmentOrder is Introduction then it tells it to appear after the Introduction inside the masterArray. If the value of Segment 2's segmentOrder is 2 then it tells it to appear after Match 2 inside the masaterArray. If there are two segments that have the same value for the segmentOrder than it orders those two by the segmentNumber.

 

This script works and dumps the following:

 

'0' ...
'type' ...
'0' => "Match"
'1' => "Match"
'matchNum' ...
'0' => "1"
'1' => "2"
'matchtypeID' ...
'0' => "1"
'1' => "1"
'titlesIDList' ...
'0' => "3,2"
'1' => "3,2"
'stipulationsIDList' ...
'0' => "2,1"
'1' => "2,1"
'competitorsIDList' ...
'0' => "10,3"
'1' => "11,1"
'matchWriterID' ...
'0' => "1"
'1' => "1"
'matchTitle' ...
'0' => "match title1"
'1' => "match title2"
'preview' ...
'0' => "preview1"
'1' => "preview2"


'0' ...
'type' ...
'0' => "Segment"
'1' => "Segment"
'segmentNumber' ...
'0' => "1"
'1' => "2"
'segmentWriterID' ...
'0' => "1"
'1' => "1"
'segmentOrder' ...
'0' => "introduction"
'1' => "1"

 

<?php require ('php/bookings.php'); ?>

<script type="text/javascript" src="forms/edit/js/bookings.js"></script>

<script type="text/javascript">
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects 
  for(var item in arr) {
   var value = arr[item];
   
   if(typeof(value) == 'object') { //If it is an array,
    dumped_text += level_padding + "'" + item + "' ...\n";
    dumped_text += dump(value,level+1);
   } else {
    dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
   }
  }
} else { //Stings/Chars/Numbers etc.
  dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}
$(document).ready(function() {
    $('div.message-error').hide();
    $('div.message-success').hide();
    $('li').remove('.titleName');   
    $('li').remove('.stipulationName');
    $('li').remove('.competitorName');
    
    for ( var matchNum = 0; matchNum < <?php echo $numMatches ?>; matchNum++ ) {
        var titlesCount = $('ul#titlesDefended'+ matchNum +' li').size();
        if(titlesCount == 0){$('ul#titlesDefended'+ matchNum).append('<li titleID="0" class="notitle">There are no titles being defended.</li>');}
        var stipulationsCount = $('ul#stipulationsAdded'+ matchNum +' li').size();
        if(stipulationsCount == 0){$('ul#stipulationsAdded'+ matchNum).append('<li stipulationID="0" class="nostipulation">There are no stipulations for this match.</li>');}
        var competitorsCount = $('ul#competitors'+ matchNum +' li').size();
        if(competitorsCount == 0){$('ul#competitors'+ matchNum).append('<li competitorID="0" class="nocompetitor">There are no competitors for this match.</li>');}
    }
    
    $("#bookerForm").validate({ 
        rules: {
            introduction: {
                required: true
            },
            matchtypeID: {
                required: true
            },
            liCompetitors: {
                required: true
            },
            matchwriterID: {
                required: true
            },
            matchTitle: {
                required: true
            },
            preview: {
                required: true
            },
            segment: {
                required: true
            }
        },
        messages: {
            introduction: "Please enter the event introduction!",
            matchtypeID: "Please choose the type of match!",
            liCompetitors: "Please choose atleast 2 competitors!",
            matchwriterID: "Please choose a match writer!",
            matchTitle: "Please enter a match title!",
            preview: "Please enter a preview!",
            segment: "Please choose a segment writer!"
        },
        submitHandler: function(form) {
            var eventName = $("#event").val();
            var eventID = $("#eventID").val();
            var introduction = $("#introduction").val();
            var subArray = new Array;
            var matchArray = new Array;
            var matchArrayIndex = 0;
            var segmentArray = new Array;
            var segmentArrayIndex = 0;
            var matchNumX = new Array;
            var matchTypeIDX = new Array;
            var titlesIDListX = new Array;
            var stipulationsIDListX = new Array;
            var competitorsIDListX = new Array;
            var matchWriterIDX = new Array;
            var matchTitleX = new Array;
            var previewX = new Array; 
            var segmentNumX = new Array;
            var segmentWriterIDX = new Array;
            var segmentOrderX = new Array;
            var typeX = new Array;
            var typeX2 = new Array;
            var i = 0;
            
            for(i=0;i<<?php echo $numMatches ?>; i++) {
                
                var matchNum = i + 1;
                var matchTypeID = $('select#matchTypeDrop'+ matchNum).val();  
                var liTitles = $('ul#titlesDefended'+ matchNum +' li');
                var titlesIDList = "";
                var j = 0;
                $('ul#titlesDefended'+ matchNum +' li').each(function(){
                    var liTitle = $( liTitles[ j ] );
                    
                    // only start appending commas in after the first characterID
                    if( j > 0 ) {
                        titlesIDList += ","; 
                    }
                    
                    // append the current li element's characterID to the list
                    titlesIDList += liTitle.attr( 'titleID' );
                    j++;
                });
                var j = 0;
                var liStipulations = $('ul#stipulationsAdded'+ matchNum +' li');
                //alert(liStipulations);
                var stipulationsIDList = "";
                $('ul#stipulationsAdded'+ matchNum +' li').each(function(){
                    var liStipulation = $( liStipulations[ j ] );
                    //alert(liStipulation);
                    
                    // only start appending commas in after the first characterID
                    if( j > 0 ) {
                        stipulationsIDList += ","; 
                    }
                    
                    // append the current li element's characterID to the list
                    stipulationsIDList += liStipulation.attr( 'stipulationID' );
                    //alert(liStipulation.attr( 'stipulationID' ));
                    j++;
                });
                //alert(stipulationsIDList);
                var j = 0;
                var liCompetitors = $('ul#competitors'+ matchNum +' li');
                var competitorsIDList = "";
                $('ul#competitors'+ matchNum +' li').each(function(){
                    var liCompetitor = $( liCompetitors[ j ] );
                    
                    // only start appending commas in after the first characterID
                    if( j > 0 ) {
                        competitorsIDList += ","; 
                    }
                    
                    // append the current li element's characterID to the list
                    competitorsIDList += liCompetitor.attr( 'competitorID' );
                    j++;
                });
                var matchWriterID = $('select#matchWriter' + matchNum + '').val();
                var matchTitle = $('input#matchTitle'+ matchNum +'').val();
                var preview = $('textarea#preview'+ matchNum +'').val();
                var type = $("input#type").val();
                typeX.push(type);
                matchNumX.push(matchNum);
                matchTypeIDX.push(matchTypeID);
                titlesIDListX.push(titlesIDList);
                stipulationsIDListX.push(stipulationsIDList);
                competitorsIDListX.push(competitorsIDList);
                matchWriterIDX.push(matchWriterID);
                matchTitleX.push(matchTitle);
                previewX.push(preview);
                matchArray[matchArrayIndex] = new Object();
                matchArray[matchArrayIndex]['type'] = typeX;               
                matchArray[matchArrayIndex]['matchNum'] = matchNumX;
                matchArray[matchArrayIndex]['matchtypeID'] = matchTypeIDX;
                matchArray[matchArrayIndex]['titlesIDList'] = titlesIDListX;
                matchArray[matchArrayIndex]['stipulationsIDList'] = stipulationsIDListX;
                matchArray[matchArrayIndex]['competitorsIDList'] = competitorsIDListX;
                matchArray[matchArrayIndex]['matchWriterID'] = matchWriterIDX;
                matchArray[matchArrayIndex]['matchTitle'] = matchTitleX;
                matchArray[matchArrayIndex]['preview'] = previewX;
            }
            for(i=0;i<<?php echo $numSegments ?>; i++) {
                var segmentNum = i + 1;
                var segmentWriterID = $('select#segmentWriter' + segmentNum + '').val();
                var segmentOrder = $('select#segmentOrder' + segmentNum + '').val();
                var type = $("input#type2").val();
                typeX2.push(type);
                segmentNumX.push(segmentNum);
                segmentWriterIDX.push(segmentWriterID);
                segmentOrderX.push(segmentOrder);
                segmentArray[segmentArrayIndex] = new Object();     
                segmentArray[segmentArrayIndex]['type'] = typeX2;          
                segmentArray[segmentArrayIndex]['segmentNumber'] = segmentNumX;
                segmentArray[segmentArrayIndex]['segmentWriterID'] = segmentWriterIDX;
                segmentArray[segmentArrayIndex]['segmentOrder'] = segmentOrderX;
            }
            alert(dump(matchArray));
            alert(dump(segmentArray));
            var dataString = 'masterArray=' + masterArray;
            dataString += '&eventID=' + eventID + '&submitBooking=True';  
            $.ajax({
                type: "POST",
                url: "processes/bookings.php",
                data: dataString, 
                success: function() {
                    $('div.message-error').hide();
                    $("div.message-success").html("<h6>Operation successful</h6><p>" + eventName + " saved successfully.</p>");
                    $("div.message-success").show().delay(10000).hide("slow");
                    return true;
                }
            });
            return false; 
        }    
    });
});
</script>

<p class="listInfos">
    Card Lineup for <?php echo "".$event." on ".$bookingDate."" ?>
</p>
        
<!-- Form -->
<form action="#" id="bookerForm" >
    <fieldset>
        <legend>Introduction</legend>
        <div class="field required">
            <label for="introduction">Introduction:</label>
            <textarea name="introduction" id="introduction" title="Introduction"></textarea>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
        </div>
    </fieldset>
    <?php for( $i = 0; $i < $numMatches; $i++ ) { ?>
    <fieldset>
        <legend>Match #<?php echo $i+1 ?></legend>
        <div class="field required">
		<label for="matchTypeDrop<?php echo $i+1 ?>">Match Type:</label>
            <select class="dropdown" name="matchTypeDrop<?php echo $i+1 ?>" id="matchTypeDrop<?php echo $i+1 ?>" title="Match Type <?php echo $i+1 ?>">
                <option value="">- Select -</option>
               <?php
                    mysqli_data_seek( $matchtypesResult, 0 );
                    while ( $row = mysqli_fetch_array ( $matchtypesResult, MYSQL_ASSOC ) ) { 
                        print "<option value=\"".$row['ID']."\">".$row['matchType']."</option>\r";
                    }
                ?>
            </select>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
        </div>
        <div class="field required">
		<label for="titlesDefended<?php echo $i+1 ?>">Title On The Line:</label><ul id="titlesDefended<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul>
            <select class="dropdown" name="titlesDrop<?php echo $i+1 ?>" id="titlesDrop<?php echo $i+1 ?>" title="Titles Dropdown <?php echo $i+1 ?>" style="margin-left: 195px;">
                <option value="">- Select -</option>
               <?php
                    mysqli_data_seek( $titlesResult, 0 );
                    while ( $row = mysqli_fetch_array ( $titlesResult, MYSQL_ASSOC ) ) { 
                        print "<option value=\"".$row['ID']."\">".$row['titleName']."</option>\r";
                    }
                ?>
            </select>
            <input type="button" value="Add Title" class="" onclick="TitlesDefended(<?php echo $i+1?>)"/>
        </div>
        <div class="field required">
		<label for="stipulationsAdded<?php echo $i+1 ?>">Stipulation:</label><ul id="stipulationsAdded<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul>
            <select class="dropdown" name="stipulationsDrop<?php echo $i+1 ?>" id="stipulationsDrop<?php echo $i+1 ?>" title="Stipulations Dropown <?php echo $i+1 ?>" style="margin-left: 195px;">
                <option value="">- Select -</option>
               <?php
                    mysqli_data_seek( $stipulationsResult, 0 );
                    while ( $row = mysqli_fetch_array ( $stipulationsResult, MYSQL_ASSOC ) ) { 
                        print "<option value=\"".$row['ID']."\">".$row['stipulation']."</option>\r";
                    }
                ?>
            </select>
            <input type="button" value="Add Stipulation" class="" onclick="StipulationsAdded(<?php echo $i+1 ?>)"/>
        </div>
        <div class="field required">
            <label for="competitors<?php echo $i+1 ?>">Competitors:</label><ul id="competitors<?php echo $i+1 ?>" style="list-style: none; margin-left: 195px;"></ul>
            <select class="dropdown" name="charactersDrop<?php echo $i+1 ?>" id="charactersDrop<?php echo $i+1 ?>" title="Characters Dropdown <?php echo $i+1 ?>" style="margin-left: 195px;">
                <option value="">- Select -</option>
               <?php
                    mysqli_data_seek( $charactersResult, 0 );
                    while ( $row = mysqli_fetch_array ( $charactersResult, MYSQL_ASSOC ) ) { 
                        print "<option value=\"".$row['ID']."\">".$row['characterName']."</option>\r";
                    }
                ?>
            </select>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
            <input type="button" value="Add Character" class="" onclick="Competitors(<?php echo $i+1 ?>)"/>
        </div>
        <div class="field required">
            <label for="matchWriter<?php echo $i+1 ?>">Match Writer:</label>
            <select class="dropdown" name="matchWriter<?php echo $i+1 ?>" id="matchWriter<?php echo $i+1 ?>" title="Match Writer <?php echo $i+1 ?>">
                <option value="0">- Select -</option>
               <?php
                    mysqli_data_seek( $matchwriterResult, 0 );
                    while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) { 
                        print "<option value=\"".$row['ID']."\">".$row['name']."</option>\r";
                    }
               ?>
            </select>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
        </div>
        <div class="field required">
		<label for="matchTitle<?php echo $i+1 ?>">Match Title</label>
		<input type="text" class="text" name="matchTitle<?php echo $i+1 ?>" id="matchTitle<?php echo $i+1 ?>" title="Match Title<?php echo $i+1 ?>"/>
		<span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
	</div>
        <div class="field required">
            <label for="preview<?php echo $i+1 ?>">Preview:</label>
            <textarea name="preview<?php echo $i+1 ?>" id="preview<?php echo $i+1 ?>" title="preview <?php echo $i+1 ?>"></textarea>
            <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
        </div>
        <input type="hidden" name="type" id="type" value="Match" />
    </fieldset>
        <?php
        }
        ?>
    <?php if ($numSegments > 0) { ?>
        <?php for( $i = 0; $i < $numSegments; $i++ ) { ?>
            <fieldset>
                <legend>Segment <?php echo $i+1 ?></legend>
                    <div class="field required">
                        <label for="segmentWriter<?php echo $i+1 ?>">Segment Writer:</label>
                        <select class="dropdown" name="segmentWriter<?php echo $i+1 ?>" id="segmentWriter<?php echo $i+1 ?>" title="Segment Writer <?php echo $i+1 ?>">
                        <option value="0">- Select -</option>
                       <?php
                            mysqli_data_seek( $matchwriterResult, 0 );
                            while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) { 
                                print "<option value=\"".$row['ID']."\">".$row['name']."</option>\r";
                            }
                       ?>
                    </select>
                        <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
                    </div>
                    <div class="field required">
                        <label for="segmentOrder<?php echo $i+1 ?>">Segment After:</label>
                        <select class="dropdown" name="segmentOrder<?php echo $i+1 ?>" id="segmentOrder<?php echo $i+1 ?>" title="Segment Order <?php echo $i+1 ?>">
                        <option value="0">- Select -</option>
                        <option value="introduction">Introduction</option>
                       <?php
                            for( $j = 1; $j <= $numMatches; $j++ ) {
                                print "<option value=$j>Match $j</option>\r";
                            }
                       ?>
                    </select>
                        <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
                    </div>
                    <input type="hidden" name="type2" id="type2" value="Segment" />
            </fieldset>
        <? } ?>
    <?php } ?>
        
    <fieldset>
    <input type="hidden" name="eventID" id="eventID" value="<?php echo $eventID; ?>" />
    <input type="hidden" name="event" id="event" value="<?php echo $event; ?>" />
    <input type="submit" class="submit" name="submitBooking" id="submitBooking" title="Submit Booking" value="Submit Booking"/>
    </fieldset>
</form>
<!-- /Form -->

<!-- Messages -->
<div class="message message-error">
    <h6>Required field missing</h6>
    <p>Please fill in all required fields. </p>
</div>
<div class="message message-success">
    <h6>Operation succesful</h6>
    <p>Booking was added to the database.</p>
</div>
<!-- /Messages -->

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/
Share on other sites

I have an idea, but its not relative to the post. In fact it doesn't deal with code at all.. But I can say your post is a bit confusing. Are you trying to sort your arrays before putting them into one master array? are you trying to port them all into one master array then sort them there.. what exactly are you tempting to do?

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215187
Share on other sites

Port them into one master array and then sot them there but its all based off certain criteria on how to sort them.

You should further explain this criteria.  Reading through lines and lines of code is a lot of work when you could just as easily explain better.

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215309
Share on other sites

CoolAsCarlito what did I tell you off the board.. I'm gonna quote Zanus on this one just to reiterate my point as your endlessly ignoring it when I say the same thing.. lol

 

You should further explain this criteria.  Reading through lines and lines of code is a lot of work when you could just as easily explain better.

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215380
Share on other sites

I reposted only the relevant code.

 

 

var introduction = $("#introduction").val();
            var subArray = new Array;
            var matchArray = new Array;
            var matchArrayIndex = 0;
            var segmentArray = new Array;
            var segmentArrayIndex = 0;
            var matchNumX = new Array;
            var matchTypeIDX = new Array;
            var titlesIDListX = new Array;
            var stipulationsIDListX = new Array;
            var competitorsIDListX = new Array;
            var matchWriterIDX = new Array;
            var matchTitleX = new Array;
            var previewX = new Array; 
            var segmentNumX = new Array;
            var segmentWriterIDX = new Array;
            var segmentOrderX = new Array;
            var typeX = new Array;
            var typeX2 = new Array;
            var i = 0;
            
            for(i=0;i<<?php echo $numMatches ?>; i++) {
                
                var matchNum = i + 1;
                var matchTypeID = $('select#matchTypeDrop'+ matchNum).val();  
                var liTitles = $('ul#titlesDefended'+ matchNum +' li');
                var titlesIDList = "";
                var j = 0;
                $('ul#titlesDefended'+ matchNum +' li').each(function(){
                    var liTitle = $( liTitles[ j ] );
                    
                    // only start appending commas in after the first characterID
                    if( j > 0 ) {
                        titlesIDList += ","; 
                    }
                    
                    // append the current li element's characterID to the list
                    titlesIDList += liTitle.attr( 'titleID' );
                    j++;
                });
                var j = 0;
                var liStipulations = $('ul#stipulationsAdded'+ matchNum +' li');
                //alert(liStipulations);
                var stipulationsIDList = "";
                $('ul#stipulationsAdded'+ matchNum +' li').each(function(){
                    var liStipulation = $( liStipulations[ j ] );
                    //alert(liStipulation);
                    
                    // only start appending commas in after the first characterID
                    if( j > 0 ) {
                        stipulationsIDList += ","; 
                    }
                    
                    // append the current li element's characterID to the list
                    stipulationsIDList += liStipulation.attr( 'stipulationID' );
                    //alert(liStipulation.attr( 'stipulationID' ));
                    j++;
                });
                //alert(stipulationsIDList);
                var j = 0;
                var liCompetitors = $('ul#competitors'+ matchNum +' li');
                var competitorsIDList = "";
                $('ul#competitors'+ matchNum +' li').each(function(){
                    var liCompetitor = $( liCompetitors[ j ] );
                    
                    // only start appending commas in after the first characterID
                    if( j > 0 ) {
                        competitorsIDList += ","; 
                    }
                    
                    // append the current li element's characterID to the list
                    competitorsIDList += liCompetitor.attr( 'competitorID' );
                    j++;
                });
                var matchWriterID = $('select#matchWriter' + matchNum + '').val();
                var matchTitle = $('input#matchTitle'+ matchNum +'').val();
                var preview = $('textarea#preview'+ matchNum +'').val();
                var type = $("input#type").val();
                typeX.push(type);
                matchNumX.push(matchNum);
                matchTypeIDX.push(matchTypeID);
                titlesIDListX.push(titlesIDList);
                stipulationsIDListX.push(stipulationsIDList);
                competitorsIDListX.push(competitorsIDList);
                matchWriterIDX.push(matchWriterID);
                matchTitleX.push(matchTitle);
                previewX.push(preview);
                matchArray[matchArrayIndex] = new Object();
                matchArray[matchArrayIndex]['type'] = typeX;               
                matchArray[matchArrayIndex]['matchNum'] = matchNumX;
                matchArray[matchArrayIndex]['matchtypeID'] = matchTypeIDX;
                matchArray[matchArrayIndex]['titlesIDList'] = titlesIDListX;
                matchArray[matchArrayIndex]['stipulationsIDList'] = stipulationsIDListX;
                matchArray[matchArrayIndex]['competitorsIDList'] = competitorsIDListX;
                matchArray[matchArrayIndex]['matchWriterID'] = matchWriterIDX;
                matchArray[matchArrayIndex]['matchTitle'] = matchTitleX;
                matchArray[matchArrayIndex]['preview'] = previewX;
            }
            for(i=0;i<<?php echo $numSegments ?>; i++) {
                var segmentNum = i + 1;
                var segmentWriterID = $('select#segmentWriter' + segmentNum + '').val();
                var segmentOrder = $('select#segmentOrder' + segmentNum + '').val();
                var type = $("input#type2").val();
                typeX2.push(type);
                segmentNumX.push(segmentNum);
                segmentWriterIDX.push(segmentWriterID);
                segmentOrderX.push(segmentOrder);
                segmentArray[segmentArrayIndex] = new Object();     
                segmentArray[segmentArrayIndex]['type'] = typeX2;          
                segmentArray[segmentArrayIndex]['segmentNumber'] = segmentNumX;
                segmentArray[segmentArrayIndex]['segmentWriterID'] = segmentWriterIDX;
                segmentArray[segmentArrayIndex]['segmentOrder'] = segmentOrderX;
            }
            alert(dump(matchArray));
            alert(dump(segmentArray));
            var subArray = $.merge( $.merge([],matchArray), segmentArray);
            alert(dump(subArray));
            var dataString = 'masterArray=' + masterArray;
            dataString += '&eventID=' + eventID + '&submitBooking=True';  

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215386
Share on other sites

Maybe this will help. Here is the before and after of what I'm expecting.

BEFORE ORDERING

Introduction
Type- Introduction
segmentTitle- Introduction
preview- This is just a test preview for the next event. Hope you all come out to see us wrestle!

Match #1
type- Match
matchNum- 1
matchTitle- Match Title 1
competitorsIDList- 1,2
matchwriterID- 1
preview- This is the preview for match #1.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 0

Match #2
type- Match
matchNum- 1
matchTitle- Match Title 2
competitorsIDList-1,2,3
matchwriterID- 1    
preview- This is the preview for match #2.
stipulationsIDList- 2,3
matchTypeID- 3
titlesIDList- 1

Match #3
type- Match
matchNum- 1
matchTitle- Match Title 3
competitorsIDList- 1,2
matchwriterID- 3
preview- This is the preview for match #3.
stipulationsIDList- 4,6
matchTypeID- 1
titlesIDList- 2

Match #4
type- Match
matchNum- 1
matchTitle- Match Title 4
competitorsIDList- 1,2
matchwriterID- 1
preview- This is the preview for match #4.
stipulationsIDList- 4,6
matchTypeID- 1
titlesIDList- 0

Match #5
type- Match
matchNum- 1
matchTitle- Match Title 5
competitorsIDList- 1,2
matchwriterID- 2
preview- This is the preview for match #5.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 3

Match #6
type- Match
matchNum- 1
matchTitle- Match Title 6
competitorsIDList- 1,2
matchwriterID- 2
preview- This is the preview for match #6.
stipulationsIDList- 3,5
matchTypeID- 1
titlesIDList-2

Match #7
type- Match
matchNum- 1
matchTitle- Match Title 7
competitorsIDList- 1,2
matchwriterID- 3
preview- This is the preview for match #7.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 1

Segment #1
type- Segment
segmentNum- 1
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)- introduction

Segment #2
type- Segment
segmentNum- 2
segmentWriterID- 2 
segmentOrder (matchNum or Introduction)- 1

Segment #3
type- Segment
segmentNum- 3
segmentWriterID- 2 
segmentOrder (matchNum or Introduction)- 1

Segment #4
type- Segment
segmentNum- 4
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)- 3

Segment #5
type- Segment
segmentNum- 5
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)-6



AFTER ORDERING

Introduction
Type- Introduction
segmentTitle- Introduction
preview- This is just a test preview for the next event. Hope you all come out to see us wrestle!

Segment #1
type- Segment
segmentNum- 1
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)- introduction

Match #1
type- Match
matchNum- 1
matchTitle- Match Title 1
competitorsIDList- 1,2
matchwriterID- 1
preview- This is the preview for match #1.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 0

Segment #2
type- Segment
segmentNum- 2
segmentWriterID- 2 
segmentOrder (matchNum or Introduction)- 1

Segment #3
type- Segment
segmentNum- 3
segmentWriterID- 2 
segmentOrder (matchNum or Introduction)- 1

Match #2
type- Match
matchNum- 1
matchTitle- Match Title 2
competitorsIDList-1,2,3
matchwriterID- 1    
preview- This is the preview for match #2.
stipulationsIDList- 2,3
matchTypeID- 3
titlesIDList- 1

Match #3
type- Match
matchNum- 1
matchTitle- Match Title 3
competitorsIDList- 1,2
matchwriterID- 3
preview- This is the preview for match #3.
stipulationsIDList- 4,6
matchTypeID- 1
titlesIDList- 2

Segment #4
type- Segment
segmentNum- 4
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)- 3

Match #4
type- Match
matchNum- 1
matchTitle- Match Title 4
competitorsIDList- 1,2
matchwriterID- 1
preview- This is the preview for match #4.
stipulationsIDList- 4,6
matchTypeID- 1
titlesIDList- 0

Match #5
type- Match
matchNum- 1
matchTitle- Match Title 5
competitorsIDList- 1,2
matchwriterID- 2
preview- This is the preview for match #5.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 3

Match #6
type- Match
matchNum- 1
matchTitle- Match Title 6
competitorsIDList- 1,2
matchwriterID- 2
preview- This is the preview for match #6.
stipulationsIDList- 3,5
matchTypeID- 1
titlesIDList-2

Segment #5
type- Segment
segmentNum- 5
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)-6

Match #7
type- Match
matchNum- 1
matchTitle- Match Title 7
competitorsIDList- 1,2
matchwriterID- 3
preview- This is the preview for match #7.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 1    

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215392
Share on other sites

Ok, so what you're saying is.

This script





<br />
function dump(arr,level) {<br />
 var dumped_text = "";<br />
 if(!level) level = 0;<br />
 <br />
 //The padding given at the beginning of the line.<br />
 var level_padding = "";<br />
 for(var j=0;j<level+1;j++) level_padding += "    ";<br />
 <br />
 if(typeof(arr) == &#039;object&#039;) { //Array/Hashes/Objects <br />
  for(var item in arr) {<br />
   var value = arr[item];<br />
   <br />
   if(typeof(value) == &#039;object&#039;) { //If it is an array,<br />
    dumped_text += level_padding + "&#039;" + item + "&#039; ...\n";<br />
    dumped_text += dump(value,level+1);<br />
   } else {<br />
    dumped_text += level_padding + "&#039;" + item + "&#039; => \"" + value + "\"\n";<br />
   }<br />
  }<br />
 } else { //Stings/Chars/Numbers etc.<br />
  dumped_text = "===>"+arr+"<===("+typeof(arr)+")";<br />
 }<br />
 return dumped_text;<br />
}<br />
$(document).ready(function() {<br />
    $(&#039;div.message-error&#039;).hide();<br />
    $(&#039;div.message-success&#039;).hide();<br />
    $(&#039;li&#039;).remove(&#039;.titleName&#039;);   <br />
    $(&#039;li&#039;).remove(&#039;.stipulationName&#039;);<br />
    $(&#039;li&#039;).remove(&#039;.competitorName&#039;);<br />
    <br />
    for ( var matchNum = 0; matchNum < <?php echo $numMatches ?>; matchNum++ ) {<br />
        var titlesCount = $(&#039;ul#titlesDefended&#039;+ matchNum +&#039; li&#039;).size();<br />
        if(titlesCount == 0){$(&#039;ul#titlesDefended&#039;+ matchNum).append(&#039;<li titleID="0" class="notitle">There are no titles being defended.&#039;);}<br />
        var stipulationsCount = $(&#039;ul#stipulationsAdded&#039;+ matchNum +&#039; li&#039;).size();<br />
        if(stipulationsCount == 0){$(&#039;ul#stipulationsAdded&#039;+ matchNum).append(&#039;<li stipulationID="0" class="nostipulation">There are no stipulations for this match.&#039;);}<br />
        var competitorsCount = $(&#039;ul#competitors&#039;+ matchNum +&#039; li&#039;).size();<br />
        if(competitorsCount == 0){$(&#039;ul#competitors&#039;+ matchNum).append(&#039;<li competitorID="0" class="nocompetitor">There are no competitors for this match.&#039;);}<br />
    }<br />
    <br />
    $("#bookerForm").validate({ <br />
        rules: {<br />
            introduction: {<br />
                required: true<br />
            },<br />
            matchtypeID: {<br />
                required: true<br />
            },<br />
            liCompetitors: {<br />
                required: true<br />
            },<br />
            matchwriterID: {<br />
                required: true<br />
            },<br />
            matchTitle: {<br />
                required: true<br />
            },<br />
            preview: {<br />
                required: true<br />
            },<br />
            segment: {<br />
                required: true<br />
            }<br />
        },<br />
        messages: {<br />
            introduction: "Please enter the event introduction!",<br />
            matchtypeID: "Please choose the type of match!",<br />
            liCompetitors: "Please choose atleast 2 competitors!",<br />
            matchwriterID: "Please choose a match writer!",<br />
            matchTitle: "Please enter a match title!",<br />
            preview: "Please enter a preview!",<br />
            segment: "Please choose a segment writer!"<br />
        },<br />
        submitHandler: function(form) {<br />
            var eventName = $("#event").val();<br />
            var eventID = $("#eventID").val();<br />
            var introduction = $("#introduction").val();<br />
            var subArray = new Array;<br />
            var matchArray = new Array;<br />
            var matchArrayIndex = 0;<br />
            var segmentArray = new Array;<br />
            var segmentArrayIndex = 0;<br />
            var matchNumX = new Array;<br />
            var matchTypeIDX = new Array;<br />
            var titlesIDListX = new Array;<br />
            var stipulationsIDListX = new Array;<br />
            var competitorsIDListX = new Array;<br />
            var matchWriterIDX = new Array;<br />
            var matchTitleX = new Array;<br />
            var previewX = new Array; <br />
            var segmentNumX = new Array;<br />
            var segmentWriterIDX = new Array;<br />
            var segmentOrderX = new Array;<br />
            var typeX = new Array;<br />
            var typeX2 = new Array;<br />
            var i = 0;<br />
            <br />
            for(i=0;i<<?php echo $numMatches ?>; i++) {<br />
                <br />
                var matchNum = i + 1;<br />
                var matchTypeID = $(&#039;select#matchTypeDrop&#039;+ matchNum).val();  <br />
                var liTitles = $(&#039;ul#titlesDefended&#039;+ matchNum +&#039; li&#039;);<br />
                var titlesIDList = "";<br />
                var j = 0;<br />
                $(&#039;ul#titlesDefended&#039;+ matchNum +&#039; li&#039;).each(function(){<br />
                    var liTitle = $( liTitles[ j ] );<br />
                    <br />
                    // only start appending commas in after the first characterID<br />
                    if( j > 0 ) {<br />
                        titlesIDList += ","; <br />
                    }<br />
                    <br />
                    // append the current li element&#039;s characterID to the list<br />
                    titlesIDList += liTitle.attr( &#039;titleID&#039; );<br />
                    j++;<br />
                });<br />
                var j = 0;<br />
                var liStipulations = $(&#039;ul#stipulationsAdded&#039;+ matchNum +&#039; li&#039;);<br />
                //alert(liStipulations);<br />
                var stipulationsIDList = "";<br />
                $(&#039;ul#stipulationsAdded&#039;+ matchNum +&#039; li&#039;).each(function(){<br />
                    var liStipulation = $( liStipulations[ j ] );<br />
                    //alert(liStipulation);<br />
                    <br />
                    // only start appending commas in after the first characterID<br />
                    if( j > 0 ) {<br />
                        stipulationsIDList += ","; <br />
                    }<br />
                    <br />
                    // append the current li element&#039;s characterID to the list<br />
                    stipulationsIDList += liStipulation.attr( &#039;stipulationID&#039; );<br />
                    //alert(liStipulation.attr( &#039;stipulationID&#039; ));<br />
                    j++;<br />
                });<br />
                //alert(stipulationsIDList);<br />
                var j = 0;<br />
                var liCompetitors = $(&#039;ul#competitors&#039;+ matchNum +&#039; li&#039;);<br />
                var competitorsIDList = "";<br />
                $(&#039;ul#competitors&#039;+ matchNum +&#039; li&#039;).each(function(){<br />
                    var liCompetitor = $( liCompetitors[ j ] );<br />
                    <br />
                    // only start appending commas in after the first characterID<br />
                    if( j > 0 ) {<br />
                        competitorsIDList += ","; <br />
                    }<br />
                    <br />
                    // append the current li element&#039;s characterID to the list<br />
                    competitorsIDList += liCompetitor.attr( &#039;competitorID&#039; );<br />
                    j++;<br />
                });<br />
                var matchWriterID = $(&#039;select#matchWriter&#039; + matchNum + &#039;&#039;).val();<br />
                var matchTitle = $(&#039;input#matchTitle&#039;+ matchNum +&#039;&#039;).val();<br />
                var preview = $(&#039;textarea#preview&#039;+ matchNum +&#039;&#039;).val();<br />
                var type = $("input#type").val();<br />
                typeX.push(type);<br />
                matchNumX.push(matchNum);<br />
                matchTypeIDX.push(matchTypeID);<br />
                titlesIDListX.push(titlesIDList);<br />
                stipulationsIDListX.push(stipulationsIDList);<br />
                competitorsIDListX.push(competitorsIDList);<br />
                matchWriterIDX.push(matchWriterID);<br />
                matchTitleX.push(matchTitle);<br />
                previewX.push(preview);<br />
                matchArray[matchArrayIndex] = new Object();<br />
                matchArray[matchArrayIndex][&#039;type&#039;] = typeX;               <br />
                matchArray[matchArrayIndex][&#039;matchNum&#039;] = matchNumX;<br />
                matchArray[matchArrayIndex][&#039;matchtypeID&#039;] = matchTypeIDX;<br />
                matchArray[matchArrayIndex][&#039;titlesIDList&#039;] = titlesIDListX;<br />
                matchArray[matchArrayIndex][&#039;stipulationsIDList&#039;] = stipulationsIDListX;<br />
                matchArray[matchArrayIndex][&#039;competitorsIDList&#039;] = competitorsIDListX;<br />
                matchArray[matchArrayIndex][&#039;matchWriterID&#039;] = matchWriterIDX;<br />
                matchArray[matchArrayIndex][&#039;matchTitle&#039;] = matchTitleX;<br />
                matchArray[matchArrayIndex][&#039;preview&#039;] = previewX;<br />
            }<br />
            for(i=0;i<<?php echo $numSegments ?>; i++) {<br />
                var segmentNum = i + 1;<br />
                var segmentWriterID = $(&#039;select#segmentWriter&#039; + segmentNum + &#039;&#039;).val();<br />
                var segmentOrder = $(&#039;select#segmentOrder&#039; + segmentNum + &#039;&#039;).val();<br />
                var type = $("input#type2").val();<br />
                typeX2.push(type);<br />
                segmentNumX.push(segmentNum);<br />
                segmentWriterIDX.push(segmentWriterID);<br />
                segmentOrderX.push(segmentOrder);<br />
                segmentArray[segmentArrayIndex] = new Object();     <br />
                segmentArray[segmentArrayIndex][&#039;type&#039;] = typeX2;          <br />
                segmentArray[segmentArrayIndex][&#039;segmentNumber&#039;] = segmentNumX;<br />
                segmentArray[segmentArrayIndex][&#039;segmentWriterID&#039;] = segmentWriterIDX;<br />
                segmentArray[segmentArrayIndex][&#039;segmentOrder&#039;] = segmentOrderX;<br />
            }<br />
            alert(dump(matchArray));<br />
            alert(dump(segmentArray));<br />
            var dataString = &#039;masterArray=&#039; + masterArray;<br />
            dataString += &#039;&eventID=&#039; + eventID + &#039;&submitBooking=True&#039;;  <br />
            $.ajax({<br />
                type: "POST",<br />
                url: "processes/bookings.php",<br />
                data: dataString, <br />
                success: function() {<br />
                    $(&#039;div.message-error&#039;).hide();<br />
                    $("div.message-success").html("<h6>Operation successful<p>" + eventName + " saved successfully.");<br />
                    $("div.message-success").show().delay(10000).hide("slow");<br />
                    return true;<br />
                }<br />
            });<br />
            return false; <br />
        }    <br />
    });<br />
});<br />




    Card Lineup for 

        

</pre>
<form action="#" id="bookerForm">
    
        Introduction
        
            Introduction:
            
            Required
        
    
    
    
        Match #
        
Match Type:
            
                - Select -
                                   mysqli_data_seek( $matchtypesResult, 0 );
                    while ( $row = mysqli_fetch_array ( $matchtypesResult, MYSQL_ASSOC ) ) { 
                        print "".$row['matchType']."\r";
                    }
                ?>
            
            Required
        
        
Title On The Line:
            
                - Select -
                                   mysqli_data_seek( $titlesResult, 0 );
                    while ( $row = mysqli_fetch_array ( $titlesResult, MYSQL_ASSOC ) ) { 
                        print "".$row['titleName']."\r";
                    }
                ?>
            
            
        
        
Stipulation:
            
                - Select -
                                   mysqli_data_seek( $stipulationsResult, 0 );
                    while ( $row = mysqli_fetch_array ( $stipulationsResult, MYSQL_ASSOC ) ) { 
                        print "".$row['stipulation']."\r";
                    }
                ?>
            
            
        
        
            Competitors:
            
                - Select -
                                   mysqli_data_seek( $charactersResult, 0 );
                    while ( $row = mysqli_fetch_array ( $charactersResult, MYSQL_ASSOC ) ) { 
                        print "".$row['characterName']."\r";
                    }
                ?>
            
            Required
            
        
        
            Match Writer:
            
                - Select -
                                   mysqli_data_seek( $matchwriterResult, 0 );
                    while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) { 
                        print "".$row['name']."\r";
                    }
               ?>
            
            Required
        
        
Match Title

Required

        
            Preview:
            
            Required
        
        
    
                }
        ?>
     0) { ?>
        
            
                Segment 
                    
                        Segment Writer:
                        
                        - Select -
                                                   mysqli_data_seek( $matchwriterResult, 0 );
                            while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) { 
                                print "".$row['name']."\r";
                            }
                       ?>
                    
                        Required
                    
                    
                        Segment After:
                        
                        - Select -
                        Introduction
                                                   for( $j = 1; $j                                 print "Match $j\r";
                            }
                       ?>
                    
                        Required
                    
                    
            
         } ?>
    
        
    
    
    
    
    
</form>
<br><br><br><br><div class="message message-error">
    Required field missing
    
Please fill in all required fields. 
</div>
<br><div class="message message-success">
    Operation succesful
    
Booking was added to the database.
</div>
<b

outputs this

'0' ...
'type' ...
'0' => "Match"
'1' => "Match"
'matchNum' ...
'0' => "1"
'1' => "2"
'matchtypeID' ...
'0' => "1"
'1' => "1"
'titlesIDList' ...
'0' => "3,2"
'1' => "3,2"
'stipulationsIDList' ...
'0' => "2,1"
'1' => "2,1"
'competitorsIDList' ...
'0' => "10,3"
'1' => "11,1"
'matchWriterID' ...
'0' => "1"
'1' => "1"
'matchTitle' ...
'0' => "match title1"
'1' => "match title2"
'preview' ...
'0' => "preview1"
'1' => "preview2"


'0' ...
'type' ...
'0' => "Segment"
'1' => "Segment"
'segmentNumber' ...
'0' => "1"
'1' => "2"
'segmentWriterID' ...
'0' => "1"
'1' => "1"
'segmentOrder' ...
'0' => "introduction"
'1' => "1"

but you want it to output this?

BEFORE ORDERING

Introduction
Type- Introduction
segmentTitle- Introduction
preview- This is just a test preview for the next event. Hope you all come out to see us wrestle!

Match #1
type- Match
matchNum- 1
matchTitle- Match Title 1
competitorsIDList- 1,2
matchwriterID- 1
preview- This is the preview for match #1.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 0

Match #2
type- Match
matchNum- 1
matchTitle- Match Title 2
competitorsIDList-1,2,3
matchwriterID- 1    
preview- This is the preview for match #2.
stipulationsIDList- 2,3
matchTypeID- 3
titlesIDList- 1

Match #3
type- Match
matchNum- 1
matchTitle- Match Title 3
competitorsIDList- 1,2
matchwriterID- 3
preview- This is the preview for match #3.
stipulationsIDList- 4,6
matchTypeID- 1
titlesIDList- 2

Match #4
type- Match
matchNum- 1
matchTitle- Match Title 4
competitorsIDList- 1,2
matchwriterID- 1
preview- This is the preview for match #4.
stipulationsIDList- 4,6
matchTypeID- 1
titlesIDList- 0

Match #5
type- Match
matchNum- 1
matchTitle- Match Title 5
competitorsIDList- 1,2
matchwriterID- 2
preview- This is the preview for match #5.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 3

Match #6
type- Match
matchNum- 1
matchTitle- Match Title 6
competitorsIDList- 1,2
matchwriterID- 2
preview- This is the preview for match #6.
stipulationsIDList- 3,5
matchTypeID- 1
titlesIDList-2

Match #7
type- Match
matchNum- 1
matchTitle- Match Title 7
competitorsIDList- 1,2
matchwriterID- 3
preview- This is the preview for match #7.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 1

Segment #1
type- Segment
segmentNum- 1
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)- introduction

Segment #2
type- Segment
segmentNum- 2
segmentWriterID- 2 
segmentOrder (matchNum or Introduction)- 1

Segment #3
type- Segment
segmentNum- 3
segmentWriterID- 2 
segmentOrder (matchNum or Introduction)- 1

Segment #4
type- Segment
segmentNum- 4
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)- 3

Segment #5
type- Segment
segmentNum- 5
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)-6



AFTER ORDERING

Introduction
Type- Introduction
segmentTitle- Introduction
preview- This is just a test preview for the next event. Hope you all come out to see us wrestle!

Segment #1
type- Segment
segmentNum- 1
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)- introduction

Match #1
type- Match
matchNum- 1
matchTitle- Match Title 1
competitorsIDList- 1,2
matchwriterID- 1
preview- This is the preview for match #1.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 0

Segment #2
type- Segment
segmentNum- 2
segmentWriterID- 2 
segmentOrder (matchNum or Introduction)- 1

Segment #3
type- Segment
segmentNum- 3
segmentWriterID- 2 
segmentOrder (matchNum or Introduction)- 1

Match #2
type- Match
matchNum- 1
matchTitle- Match Title 2
competitorsIDList-1,2,3
matchwriterID- 1    
preview- This is the preview for match #2.
stipulationsIDList- 2,3
matchTypeID- 3
titlesIDList- 1

Match #3
type- Match
matchNum- 1
matchTitle- Match Title 3
competitorsIDList- 1,2
matchwriterID- 3
preview- This is the preview for match #3.
stipulationsIDList- 4,6
matchTypeID- 1
titlesIDList- 2

Segment #4
type- Segment
segmentNum- 4
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)- 3

Match #4
type- Match
matchNum- 1
matchTitle- Match Title 4
competitorsIDList- 1,2
matchwriterID- 1
preview- This is the preview for match #4.
stipulationsIDList- 4,6
matchTypeID- 1
titlesIDList- 0

Match #5
type- Match
matchNum- 1
matchTitle- Match Title 5
competitorsIDList- 1,2
matchwriterID- 2
preview- This is the preview for match #5.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 3

Match #6
type- Match
matchNum- 1
matchTitle- Match Title 6
competitorsIDList- 1,2
matchwriterID- 2
preview- This is the preview for match #6.
stipulationsIDList- 3,5
matchTypeID- 1
titlesIDList-2

Segment #5
type- Segment
segmentNum- 5
segmentWriterID- 1 
segmentOrder (matchNum or Introduction)-6

Match #7
type- Match
matchNum- 1
matchTitle- Match Title 7
competitorsIDList- 1,2
matchwriterID- 3
preview- This is the preview for match #7.
stipulationsIDList- 0
matchTypeID- 1
titlesIDList- 1    

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215396
Share on other sites

So what I'm saying is the subArray should look something like this. This is just is what would show if I used the alert dump. I hope this helps. However its the point of being able to use the matchArray and segmentArray to help make the subArray.  There is still info that is inside of the matchArray and segmentArray that will be needed. I hope this helps.

 

The reason there are spots that don't have data is because at this point in working with this script there won't be data for this.

 

 

'0'

'type' ...

'0' => "Introduction"

'1' => "Match"

'2' => "Match"

'3' => "Segment"

'4' => "Match"

'segmentTitle' ...

'0' => "Introduction"

'1' => "Westler 1 vs. Wrestler 2"

'2' => "Westler 3 vs. Wrestler 4"

'3' => ""

'4' => "Westler 5 vs. Wrestler 6"

'matchwriterID' ...

'0' => "1"

'1' => "1"

'2' => "2"

'3' => "2"

'4' => "1"

'sortOrder' ...

'0' => "1"

'1' => "2"

'2' => "3"

'3' => "4"

'4' => "5"

'preview' ...

'0' => "This is the preview for the introduction of the event"

'1' => "Wrestler 1 takes on Wrestler 2. Should be a good match."

'2' => "Wrestler 3 takes on Wrestler 4. Should be a good match."

'3' => ""

'4' => "Wrestler 5 takes on Wrestler 6. Should be a good match."

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215424
Share on other sites

Ok, if I'm right on this one, you want to do something like this.. in which everything is ... congruent.

'0'

'type' ...

'0' => "Introduction"

'1' => "Match"

'2' => "Match"

'3' => "Segment"

'4' => "Match"

'segmentTitle' ...

'0' => "Introduction"

'1' => "Westler 1 vs. Wrestler 2"

'2' => "Westler 3 vs. Wrestler 4"

'3' => ""

'4' => "Westler 5 vs. Wrestler 6"

'matchwriterID' ...

'0' => "1"

'1' => "1"

'2' => "2"

'3' => "2"

'4' => "1"

'sortOrder' ...

'0' => "1"

'1' => "2"

'2' => "3"

'3' => "4"

'4' => "5"

'preview' ...

'0' => "This is the preview for the introduction of the event"

'1' => "Wrestler 1 takes on Wrestler 2. Should be a good match."

'2' => "Wrestler 3 takes on Wrestler 4. Should be a good match."

'3' => ""

'4' => "Wrestler 5 takes on Wrestler 6. Should be a good match."

In which the bolded fields are all mashed together somehow and make a complete message or something. 

Now my question is... why did you create this data in Javascript?  It shouldn't be that hard to create 5 arrays and merge them with PHP.

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215426
Share on other sites

You really, really need to clarify what you have and what you're trying to do.  So:

 

1. List your arrays.  Do it in a clear, concise manner.  You refer to a match array, segment array, and some sort of master array, but all I can see is a segmentTitle array and matchwriterID array.  Are these what you're referring to?

 

2. What are you trying to sort them on?

 

I really can't help but think you're going about this in the absolute worst way.  You should really be shaping your data on the back end, either in the database itself or in PHP.  You really only need JavaScript if you're trying to show the data sorted according to different criteria without a page refresh, and even then the bulk of the work would still be done on the back end.

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215429
Share on other sites

This still doesnt tell us what criteria that sorting occurs on, how exactly your trying to sort stuff, by what means so to speak whats the "sortable" value of them all.. Its like going to a library and saying I need a book, but have no title or no reference to what its about. Then going to the librarian and asking where you should look for it?.. Your saying heres the before, heres the after but really not applying any logic to why it or how it should be sorted.. your also saying its two different arrays that need to be sorted for the bigger array its going to form. But you don't specify if you want each independant array sorted prior to merging them or after.. and again that falls in line with what your trying to sort everything by.. circles of cluelessness..

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215435
Share on other sites

subArray:

'0'
'type' ...
'0' => "Introduction"
'1' => "Match"
'2' => "Match"
'3' => "Segment"
'4' => "Match"
'segmentTitle' ...
'0' => "Introduction"
'1' => "Westler 1 vs. Wrestler 2"
'2' => "Westler 3 vs. Wrestler 4"
'3' => ""
'4' => "Westler 5 vs. Wrestler 6"
'matchwriterID' ...
'0' => "1"
'1' => "1"
'2' => "2"
'3' => "2"
'4' => "1"
'sortOrder' ...
'0' => "1"
'1' => "2"
'2' => "3"
'3' => "4"
'4' => "5"
'preview' ...
'0' => "This is the preview for the introduction of the event"
'1' => "Wrestler 1 takes on Wrestler 2. Should be a good match."
'2' => "Wrestler 3 takes on Wrestler 4. Should be a good match."
'3' => ""
'4' => "Wrestler 5 takes on Wrestler 6. Should be a good match."

 

matchArray:

'0' ...
'type' ...
'0' => "Match"
'1' => "Match"
'matchNum' ...
'0' => "1"
'1' => "2"
'matchtypeID' ...
'0' => "1"
'1' => "1"
'titlesIDList' ...
'0' => "3,2"
'1' => "3,2"
'stipulationsIDList' ...
'0' => "2,1"
'1' => "2,1"
'competitorsIDList' ...
'0' => "10,3"
'1' => "11,1"
'matchWriterID' ...
'0' => "1"
'1' => "1"
'matchTitle' ...
'0' => "match title1"
'1' => "match title2"
'preview' ...
'0' => "preview1"
'1' => "preview2"

 

segmentArray:

'0' ...
'type' ...
'0' => "Segment"
'1' => "Segment"
'segmentNumber' ...
'0' => "1"
'1' => "2"
'segmentWriterID' ...
'0' => "1"
'1' => "1"
'segmentOrder' ...
'0' => "introduction"
'1' => "1"

 

DB Structure is as follows:

Table Name: eventSegments

Fields: ID, matchwriterID, type, sortOrder, segmentTitle, preview

 

Then for every entry in that table that is has a type of Match then somehow it uses the matchArray to work with the other data.

 

The following is used for the charactersIDList for each match so each new row inside this table will have a value for each character in the match.

Table: matchCharacters

Fields: ID, eventSegmentID (last_insert_id from eventSegment Query), characterID

 

 

The following is used for the matchTypeID for each match so each new row inside this table will have a value for matchtype.

Table: matchMatchTypes

Fields: ID, eventSegmentID (last_insert_id from eventSegment Query), matchTypeID

 

The following is used for the stipulationsIDList for each match so each new row inside this table will have a value for stipuplationID.

Table: matchStipulations

Fields: ID, eventSegmentID (last_insert_id from eventSegment Query), stipulationID

 

The following is used for the titlesIDList for each match so each new row inside this table will have a value for titleID.

Table: matchTitles

Fields: ID, eventSegmentID (last_insert_id from eventSegment Query), titleID

 

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215438
Share on other sites

I'm just going to repeat myself and Nightslyr, you should not be doing this with JS, especially since you have this stuff in a database already.  It sounds to me like you could very easily fix whatever issue it is that you're having with a few JOINs and some HTML to make it look cool.

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215441
Share on other sites

What sorts is based on the segmentOrder. It finds the the value of this inside the segmentArray and places that segment after what the value says so if it says introduction then places that individual segment after the Introduction. If it has a numerical value it is placed after that match number so if it says 5 then it is placed after match 5. If two or more have the same value for segmentOrder then they are placed after that match number sorted inside of the subArray and then sorted based on their segmentNum.

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215442
Share on other sites

So, wouldn't the user supplied data be stored in the db before you attempted to show it all on the screen anyway?  I'm not sensing any logic behind your design decision.

 

You're trying to force a really bad design to work.  You'd be much better off doing the data manipulation on the back end than to continue down this path.  JavaScript is best used as a UI scripting language.  It shouldn't be doing the heavy lifting of sorting your data.

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215446
Share on other sites

so this is data to be stored in a DB? whats the point of sorting it at this point when you can dump it all in the DB one by one.. and then when you query the DB you pull it out as needed for display and sort it server side for the display purpose.. there is no reason to sort something in this type of case just to ultimately dump it into the db there after where the sorting wont matter none when quering anyway..

Link to comment
https://forums.phpfreaks.com/topic/236234-ordering/#findComment-1215454
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.