PHP - Ordering Array
Hi
I have an array which pull data from a DB (which I didn't create nor can modify) I need to be able to export it to an excel sheet with the data in a specified order. how do I do this? eg run sql queries and end up with array which would be - a [1] - b [2] - c [3] - d [4] - e how would I be able to specify the order eg d , a, c, e, b. to match it up with the column headers on the excel sheet? To make it more of a challenge, I can't amend the column headers either. I can only manipulate the array. I will be pulling multiple arrays out and not all have all the value is them!!! Deep Deep Joy!!! Similar TutorialsHi guys, I'm trying to modify a Joomla listings directory component to have a sorting capability on category pages that list listings. A bit like eBay, price high to low etc. The basic code that outputs each listing is as follows... foreach ($this->links AS $link) { $fields = $this->fields[$link->link_id]; include $this->loadTemplate('sub_listingSummary.tpl.php'); } I have so far been able to get the contents of an extra field into an array within this foreach loop like this: $sleeps_array = array(); foreach ($this->links AS $link) { $fields = $this->fields[$link->link_id]; $sleeps = $fields->getFieldById(51); if(!is_null($sleeps) && $sleeps->hasValue()){ $sleeps = $sleeps->getOutput(1); $sleeps_array[] = $sleeps; } include $this->loadTemplate('sub_listingSummary.tpl.php'); } sort($sleeps_array); foreach ($sleeps_array as $key => $val) { echo "sleeps_array[" . $key . "] = " . $val . "\n"; } I've got this far but simply adding the include file to the new loop for "sleeps" does not work. I think I need to some how link the 2 arrays so that I can sort listings by the custom field... Can anyone point me in the correct direction? Thanks! RJP1 I have a code Code: [Select] <?php include('dbcon.php'); $sql = mysql_query("select * from money ORDER BY sno DESC "); $num=mysql_num_rows($sql); $snumb=0; echo '<form method="post" action="edit.php?action=trunc">'; echo '<input type="submit" value="TRUNCATE TEABLE">'; echo '</form>'; echo '<form method="post" action="del_mul.php">'; echo "<table border='1' id=hor-minimalist-a style=width:1200px> <tr> <th> S No. </th> <th> Act. ID </th> <th>Jisne Diye</th> <th>Kisko diye</th> <th>Kitne Diye </th> <th>Wajah </th> <th>Kisne bhare iss site main </th> <th>Kiss time pe </th> <th>Delete Entry</th> <th>Sel for Operation</th> </tr>"; while($row = mysql_fetch_array($sql)) { ++$snumb; echo "<tr>"; echo "<td>" . $snumb. "</td>"; echo "<td>" . $row['sno'] . "</td>"; echo "<td>" . $row['name1'] . "</td>"; echo "<td>" . $row['name2'] . "</td>"; echo "<td>" . $row['amm'] . "</td>"; echo "<td>" . $row['rea'] . "</td>"; echo "<td>" . $row['usname'] . "</td>"; echo "<td>" . $row['time'] . "</td>"; echo "<td><a href=edit.php?id=" . $row['sno'] . "&action=del>DELETE</a></td>"; echo '<td><input type="checkbox" name="mul_arr[]" value='.$row[sno].'></td>'; echo "</tr>"; } echo '<input type="submit" value="DELETE SELECTED">'; echo '</form>'; ?> In this i thought that the "DELETE SELECTED" button should be below to the table but the button is getting printed above the Table... Why is it so.......?????????????? And how to fix it ???????????? - Pranshu Agrawal pranshu.a.11@gmail.com I am ordering a table by 2 different functions and am having a lot of trouble ORDER BY Level DESC, Won/(Won+Lost) ASC What I'm trying to figure out how to do is near the bottom of the script where it has a for loop for numSegments and the dropdown for the sortOrder for each one. What the options are supposed to fill is the amount of matches or the event. So the option text would be "Match 1" or however many down with the numMatches variable I guess. And the option would just be the number of the match. Code: [Select] <?php require ('php/bookings.php'); ?> <script type="text/javascript"> function Competitors(matchNum) { function isDupe(which) { var result = false; $('ul#competitors'+ matchNum +' li').each(function(i, e) { if ($(e).attr('characterID') == which) { result = true; return false; // break out of .each() } }); return result; } var characterID = $('#charactersDrop'+ matchNum +' option:selected').val(); var characterName = $('#charactersDrop'+ matchNum +' option:selected').text(); if (characterID > 0 && !isDupe(characterID)) { // Create the anchor element var anchor = $( '<a href="#">Remove</a>' ); // Create a click handler for the anchor element anchor.click( function() { $( this ).parent().remove(); return false; // makes the href in the anchor tag ignored } ); // Create the <li> element with its text, and then append the anchor inside it. var li = $( '<li>' + characterName + ' </li>' ).append( anchor ); li.attr ('characterID', characterID ); // Append the new <li> element to the <ul> element $('#competitors'+ matchNum).append( li ); } } function TitlesDefended(matchNum) { function isDupe(which) { var result = false; $('ul#titlesDefended'+ matchNum +' li').each(function(i, e) { if ($(e).attr('titleID') == which) { result = true; return false; // break out of .each() } }); return result; } var titleID = $('#titlesDrop'+ matchNum +' option:selected').val(); var titleName = $('#titlesDrop'+ matchNum +' option:selected').text(); if (titleID > 0 && !isDupe(titleID)) { // Create the anchor element var anchor = $( '<a href="#">Remove</a>' ); // Create a click handler for the anchor element anchor.click( function() { $( this ).parent().remove(); return false; // makes the href in the anchor tag ignored } ); // Create the <li> element with its text, and then append the anchor inside it. var li = $( '<li>' + titleName + ' </li>' ).append( anchor ); li.attr( 'titleID', titleID ); // Append the new <li> element to the <ul> element $( '#titlesDefended'+ matchNum ).append( li ); } } function StipulationsAdded(matchNum) { function isDupe(which) { var result = false; $('ul#stipulationsAdded'+ matchNum +' li').each(function(i, e) { if ($(e).attr('stipulationID') == which) { result = true; return false; // break out of .each() } }); return result; } var stipulationID = $('#stipulationsDrop'+ matchNum +' option:selected').val(); var stipulationName = $('#stipulationsDrop'+ matchNum +' option:selected').text(); if (stipulationID > 0 && !isDupe(stipulationID)) { // Create the anchor element var anchor = $( '<a href="#">Remove</a>' ); // Create a click handler for the anchor element anchor.click( function() { $( this ).parent().remove(); return false; // makes the href in the anchor tag ignored } ); // Create the <li> element with its text, and then append the anchor inside it. var li = $( '<li>' + stipulationName + ' </li>' ).append( anchor ); li.attr( 'stipulationID', stipulationID ); // Append the new <li> element to the <ul> element $( '#stipulationsAdded'+ matchNum ).append( li ); } } $(document).ready(function() { $('div.message-error').hide(); $('div.message-success').hide(); $('li').remove('.titleName'); $('li').remove('.stipulationName'); $('li').remove('.characterName'); $("#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 type = $("#type").val(); 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 segmentArrayX = new Array; var masterIndex = 0; var masterArray = []; 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'); var stipulationsIDList = ""; $('ul#stipulationsAdded'+ matchNum +' li').each(function(){ var liStipulation = $( liStipulations[ j ] ); // 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' ); j++; }); 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( 'characterID' ); j++; }); var matchWriterID = $('select#matchWriter' + matchNum + '').val(); var matchTitle = $('input#matchTitle'+ matchNum +'').val(); var preview = $('textarea#preview'+ matchNum +'').val(); matchNumX.push(matchNum); matchTypeIDX.push(matchTypeID); titlesIDListX.push(titlesIDList); stipulationsIDListX.push(stipulationsIDList); competitorsIDListX.push(competitorsIDList); matchWriterIDX.push(matchWriterID); matchTitleX.push(matchTitle); previewX.push(preview); masterArray[masterIndex] = new Object(); masterArray[masterIndex]['matchNum'] = matchNumX; masterArray[masterIndex]['matchtypeID'] = matchTypeIDX; masterArray[masterIndex]['titlesIDList'] = titlesIDListX; masterArray[masterIndex]['stipulationsIDList'] = stipulationsIDListX; masterArray[masterIndex]['competitorsIDList'] = competitorsIDListX; masterArray[masterIndex]['matchWriterID'] = matchWriterIDX; masterArray[masterIndex]['matchTitle'] = matchTitleX; masterArray[masterIndex]['preview'] = previewX; } var dataString = 'masterArray=' + masterArray; dataString += '&eventID=' + eventID + '&introduction=' + introduction + '&submitBooking=True'; console.log( masterArray ); $.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<?php echo $i+1 ?>:</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">Segment After:</label> <select class="dropdown" name="sortOrder" id="sortOrder" title="Sort Order"> <option value="0">- Select -</option> </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="type" id="type" 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 --> Here is question: i have db articles and categories. Now at categories i have: - id - name - info and at articles there a - id - cat_id - name - description - date Now i wonna get all articles like "SELECT * FROM articles", but i wonna order it by categories name, how can i do that? Hi everyone, I'm making an admin page which will contain a number of articles. Unlike most sites, these articles won't be ordered based on date, but however the admin wishes. To do this I've added an order column to the mysql, in the admin page all the articles are displayed and next to them a text input, with the value set to their current order number (1,2,3, 4 etc) Here's selections of the code <?php $o = $_GET['o']; if($o == 'new') { $order1 = $_POST['order1']; $update = "UPDATE `content` SET `order` = '$order1' WHERE `id` = '1'"; $result=mysql_query($update) or die(mysql_error()); } ?> <form method="post" action="?o=new" name="order_form"> <!-- CONTENT --> <div id="content"> <?php $sql="SELECT * FROM `content` ORDER BY `order` ASC"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> <ul> <li class="article_left"> <input type="text" value="<?php echo $rows['order']; ?>" name="order<?php echo $rows['id']; ?>" class="order"> </li> <li class="article_left_title"> <?php echo $rows['title']; ?> </li> <li <?php if ($rows['live'] == '1') { echo 'class="live"'; }else echo 'class="launch"'; ?>> <?php if ($rows['live'] == '1') { echo 'Now Live'; }else { echo 'Launch'; } ?> </li> <div class="clear"></div> </ul> <?php } ?> </div> <!-- END CONTENT --> <div id="submit_order"> <input type="submit" name="submit" value="Submit Re-Order"> </div> </form> My problem is hard to explain, but as you can tell $update only does it for the first article. How can I make it change the `order` column for all the articles. Feel free to ask more questions. Would really appreciate any help! I have a lottery PHP script which i have been creating. The lottery contains four different numbers in which are four different fields in my database. On the random ticket buy the code for the four numbers are like this $ticketone = rand(1,25); $tickettwo = rand(1,25); $ticketthree = rand(1,25); $ticketfour = rand(1,25); I am wanting to do it so they can be put in order and then imported into my database in that right order. For example, If ticketone was 20, an tickettwo was 13, i would want it to be imported into the database so that ticketone would be 13. (being put into order) and ticket two would be 20 etc.... Hi there! I'm still getting use to using multiple rows when ordering in SQL, but I have a question. How can I display topics that are stickied first, then display all the threads below ordered by lastpost? I tried: //thread details $query = mysql_query("SELECT `date`,`lock`,`sticky`,`status`,`title`,`username`,`id`,`lastposter`,`lastpost` FROM threads WHERE parent = '{$_GET['forum']}' ORDER BY lastpost, sticky DESC LIMIT $start,$per_page") or die(mysql_error()); And the stickies do show up first, but all the regular threads aren't showing ordered by laspost DESC. Why is that? :/ Lastpost = datetime I've got a file that I haven't worked on in awhile and am needing to make a little change to it. Not too sure of how to do it though. The portion of the script I am looking at should be this: Code: [Select] $indexH[$var][] = array('firstname' => "$r2[firstname]", 'lastname' => "$r2[lastname]", 'number' => "$r2[number]", 'id' => "$r2[id]", 'q1' => "$r2[q1]", 'q2' => "$r2[q2]", 'q3' => "$r2[q3]", 'q1rt' => "$r2[q1rt]", 'q2rt' => "$r2[q2rt]", 'q3rt' => "$r2[q3rt]", 'q1s' => "$r2[q1s]", 'q2s' => "$r2[q2s]", 'q3s' => "$r2[q3s]", 'regid' => "$r2[regid]", 'eventid' => "$r2[eventid]"); Code: [Select] $ir = 0; foreach ( $indexH[$var] as $val ){ $q1 = $val[q1]; $q2 = $val[q2]; $q3 = $val[q3]; $var2 = substr($var,0,5); $var2 = substr_replace($var2, "0", 4, 1); if ($q1 < "$var2") { $q1 = '99.999'; } else { $q1 = $val[q1]; } if ($q2 < "$var2") { $q2 = '99.999'; } else { $q2 = $val[q2]; } if ($q3 < "$var2") { $q3 = '99.999'; } else { $q3 = $val[q3]; } if (($q1 == $q2) && ($q1 == $q3)) { $indexH[$var][$ir][bq] = "$q1"; } elseif (($q1 <= $q2) && ($q1 <= $q3)) { $indexH[$var][$ir][bq] = "$q1"; } elseif ($q2 <= $q3) { $indexH[$var][$ir][bq] = "$q2"; } else { $indexH[$var][$ir][bq] = "$q3"; } $ir++; } foreach ($indexH[$var] as $key => $value) { uasort($indexH[$var], 'compare'); } This is taking three dfferent values (q1, q2, q3) getting the best value of the three and then sorting the array based on the best value chosen. Now the addition. If two entries in the array have the same best value resulting in a tie, I need to compare their qXs from that best value, higher qXs gets put above the lower. X = 1,2,3 depending on which is best value. If any more information is needed let me know, sort of hard to explain. Hi, i have been thinking on ways to make an ordering system for my web site. The code bellow shows how i populate the page. i desplay the pizza's from the data base. i want at the end of each line a box thati allows the user to pick howmany pizzas they want. from they when they click order i want it to send all the information of what they want so they can double check it and when they click the final order button it will send to a diffrent order table. Code: [Select] <? session_start(); if ($_SESSION['userName']) {} else { header('location:../index.php'); } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Deliver-Pizza Topping</title> <link href="css/pizza-topping.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"> <img src="images/logo.jpg" alt="logo" /> <a href="log-off.php" id="logg-off" >log off</a> <ul id="nav"> <li><a href="home.php" target="_self">Home</a></li> <span> | </span> <li><a href="Pizza-Topping.php" target="_self">Pizza Topping</a></li> <span> | </span> <li><a href="order.php" target="_self">Order</a></li> <span> | </span> <li><a href="Account.php" target="_self">Account Details</a></li> <span> | </span> </ul> </div> <div id="Featured"> <img src="images/banner1.jpg" alt="banner" name="banner"" ID="banner"></div><!--end Featured--> <div class="featuredimage" id="main"> <div id="content" class="tiles"> <h1>Pizza-Topping</h1><hr /> <p>Please select the pizza you would like bellow</p> <div id ="staff"><div style="width:970px; height:300px; overflow:auto" <left> <table> <tr> <th>Type</th> <th>Size</th> <th>Topping</th> <th>Cost</th> <th>Information</th> <th>Order</th> </tr> <tr> <form name="input" action="order.php" method="post"> <?php mysql_connect("localhost", "root", "")or die("cannot connect"); mysql_select_db("deliverpizza")or die("cannot select DB"); $sql="SELECT * FROM `pizzatopping` "; $result= mysql_query($sql); while($row =mysql_fetch_assoc($result)) { ?> <td><?php echo $row['type'] ?></td> <td><?php echo $row['size'] ?></td> <td><?php echo $row['topping'] ?></td> <td><?php echo $row['cost'] ?></td> <td><?php echo $row['info'] ?></td> <td> <input type:"text" name:"pizza<?php echo $row['id'] ?>" /></td> </tr></left> <?php } ?> <input type="submit" value="Order" /> </table> </div> </div> </div> </div> <!--end content--> <div id="footer"><span><p>Created By Ryan Williams</p></span></div><!--end footer--> </div><!--end container--> </body> </html> Help please There has to be a simple solution for this problem that I am apparently too dense to figure out... Say on a single page, I have code like this... Code: [Select] <div id="stuff"> //stuff </div> and then further down on the page, I have code that runs and produces a variable ($i) that is a number. I then want to check to see if that number is 10 or higher, or not, (which I can handle doing ) and if it is 10 or higher, then I want to hide the "stuff" div that is further up on the page. What is the best way to do this? It's like I need the code to run and then go back and add something to the "stuff" div to make it not show, if the variable is 10 or higher. Any thoughts? This has to be easy so I"m feeling particularly newbie tonight Code: [Select] if ($i >=10) { //the number is 10 or higher so let's somehow hide the "stuff" div that is further up on the page. but how? :) } else { // the number is less than 10 so it's cool to continue to display the "stuff" div } Hi, I am using multiple rows in my table and I want to order it in ascending order from a column. With SQL statement it is simple as saying ORDER BY column but how I can do this with just numbers? So I want for example: (goes in correct order) Col 1 Col 2 Col3 # 5 # # 43 # # 87 # # 113 # instead of: Col 1 Col 2 Col3 # 113 # # 43 # # 87 # # 5 # Thanks for any help!! Hi Guys, I am to ordering list things by date from my database i.e. from 01/08/2011 to 31/08/2011. I now have dates which are next years date such as 05/01/2012 and 09/01/2011 and this is causing problems it doesnt order correctly. The date 05/01/2012 come right after 04/08/2011 and 09/01/2012 comes right after 08/08/2011 which is not what I want it to do. Is there any way I can put the dates in the proper order so the dates for next year appear mixed up with these years dates. Thanks Hi all, I've got a couple of these event entries with dates attached to them in the format of day-month-year (example: 31-01-2001) and I've got a script to display the name+date in a list. How could I go about making it so that it orders by the oldest on top like: Event A October 5, 2011 - October 8, 2011 Event B October 6, 2011 - October 7, 2011 Event C October 9, 2011 - December 1, 2011 Any help would be appreciated
I've a php "program" that helps me manage sales.
php file in pdf: https://we.tl/t-D4xTtG3Ync I have an Job, which i need some help with.
Its an ordering system.
its probably really simple to do, and i even know how i want it set up.
all databases are setup.
i cant pay much but my payment will be : 178.59 dollar
which in this point of time is calculated from 1000 dkk
the task:
an ordering system which contains:
selection menu - to select an activity, stored in an database an starting time textfield. just a normal textfield i guess a selection menu - for package selection- wich will find the packages in the package database with the matching target id for the selected Activity a textfield for amount of people participating, as a multiplier for the price. a selection menu - for additions selecting. same as the Package selector. and an price field this is in one row, where there should be a way to add these, so that its possible to get more acticity orderes + an Total amount field all this data should then be viewable in a table, which ill create, and after that be able to be send through an email that is setup in html, which ill make:) Why i need help: i took my hands full with this project, and im leaving soon for thailand, and that is why im a bit screwed;/ hope to hear from somone fast many thanks Joachim Gerber Hi i am trying to order data however i get a problem. The problem is that it orders the data but only by the first number! Example: (Place 1) Freid001: 981 (Place 2) mark: 90000 (Place 3) Tom: 5 (Place 4) Ash 1000 Here is the code i am using: $query = "SELECT * FROM Game ORDER BY XP"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo "<table border='0'>"; echo "<tr> <th>User</th> <th>XP</th> </tr>"; while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "</td><td>"; echo $row['User'] ; echo "</td><td>"; echo $row['XP']; } echo "</table>"; ?> Thanks Hi,
I'm having a bit of trouble. I want to order the same 9 results by RAND(). Currently I have them ordered by 'avg' (average views) and that's working fine, but when I add a sub query to make those 9 results scatter by random it's causing some trouble.
Code I currently have that works:
$sql = "SELECT *, views / HOUR(TIMEDIFF(NOW(), date)) as avg FROM content WHERE date BETWEEN CURDATE() - INTERVAL 30 DAY AND NOW() - INTERVAL 2 HOUR AND views > 600 AND live = '0' ORDER BY avg DESC LIMIT 9"; Hi there, Firstly this is a link to my working code/script http://www.nexus-guild.eu/adornments/index.php When you click on one of the body images it pulls all the data from the database for that particular slot and feeds it into a table. I am wondering how i can make it so when you click on the table column descriptions such as the Name/Effect/Quality/Level/Colour/Faction Name/Faction Value it will reorder all the information in ascending order or descending order. Ive looked around quite a bit for this but i cant find anything on this. This is the code im currently using. It has alot of repeating code which makes up the majority of the file Code: [Select] <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>neXus - Adornments Calculator</title> <style type="text/css"> <!-- body { background-color: #2f2626; } body,td,th { color: #000; font-family: Trebuchet MS, Arial, Helvetica, sans-serif; } --> </style></head> <body text="#FFFFFF" link="#ff8000" vlink="#ff8000" alink="#ff8000"> <center> <p> </p> <p> </p> <p><img src="character.png" border="0" usemap="#Map"/> <map name="Map" id="Map"> <area shape="rect" coords="2,2,44,44" href="index.php?slot=head" /> <area shape="rect" coords="45,2,85,44" href="index.php?slot=cloak" /> <area shape="rect" coords="2,46,44,86" href="index.php?slot=chest" /> <area shape="rect" coords="45,45,85,86" href="index.php?slot=shoulders" /> <area shape="rect" coords="45,87,85,129" href="index.php?slot=forearms" /> <area shape="rect" coords="2,87,44,129" href="index.php?slot=legs" /> <area shape="rect" coords="45,130,85,170" href="index.php?slot=hands" /> <area shape="rect" coords="3,130,44,170" href="index.php?slot=feet" /> <area shape="rect" coords="46,172,86,216" href="index.php?slot=charm" /> <area shape="rect" coords="3,172,45,215" href="index.php?slot=charm" /> <area shape="rect" coords="45,216,85,257" href="index.php?slot=drink" /> <area shape="rect" coords="3,216,44,256" href="index.php?slot=food" /> <area shape="rect" coords="362,2,403,43" href="index.php?slot=waist" /> <area shape="rect" coords="405,2,443,43" href="index.php?slot=neck" /> <area shape="rect" coords="362,45,403,86" href="index.php?slot=ear" /> <area shape="rect" coords="405,45,444,87" href="index.php?slot=ear" /> <area shape="rect" coords="363,88,402,129" href="index.php?slot=finger" /> <area shape="rect" coords="405,89,444,128" href="index.php?slot=finger" /> <area shape="rect" coords="363,131,402,171" href="index.php?slot=wrist" /> <area shape="rect" coords="405,130,443,170" href="index.php?slot=wrist" /> <area shape="rect" coords="362,174,404,213" href="index.php?slot=ranged" /> <area shape="rect" coords="405,173,443,212" href="index.php?slot=ammo" /> <area shape="rect" coords="362,216,404,256" href="index.php?slot=primary" /> <area shape="rect" coords="405,216,444,256" href="index.php?slot=secondary" /> </map> <br> <br> <p> <?php include 'db_connect.php'; if (isset($_GET["slot"])) { $slot = $_GET["slot"]; } else { $slot=startpage; }; $color1 = "#E1FAE2"; $color2 = "#ffffff"; $row_count = 0; //////////////////////////////////////////////////////////////////////////////// /////////////////////////////STARTPAGE - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// if ( $slot == "startpage" ) { echo "This is still in beta. If you find any bugs please send them to <a href=\"mailto:sosia@nexus-guild.eu\">Sosia</a>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////STARTPAGE - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////HEAD SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "head" ) { $sql = "SELECT * FROM $db_table WHERE for_head = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////HEAD SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////CLOAK - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "cloak" ) { $sql = "SELECT * FROM $db_table WHERE for_cloak = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////CLOAK SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////CHEST SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "chest" ) { $sql = "SELECT * FROM $db_table WHERE for_chest = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////CHEST SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////SHOULDERS SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "shoulders" ) { $sql = "SELECT * FROM $db_table WHERE for_shoulders = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////SHOULDERS SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////FOREARMS SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "forearms" ) { $sql = "SELECT * FROM $db_table WHERE for_forearms = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////FOREARMS SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////LEGS SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "legs" ) { $sql = "SELECT * FROM $db_table WHERE for_legs = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////LEGS SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////HANDS SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "hands" ) { $sql = "SELECT * FROM $db_table WHERE for_hands = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////HANDS SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////FEET SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "feet" ) { $sql = "SELECT * FROM $db_table WHERE for_feet = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////FEET SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////WAIST SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "waist" ) { $sql = "SELECT * FROM $db_table WHERE for_waist = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////WAIST SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////NECK SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "neck" ) { $sql = "SELECT * FROM $db_table WHERE for_head = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////NECK SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////EAR SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "ear" ) { $sql = "SELECT * FROM $db_table WHERE for_head = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////EAR SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////FINGER SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "finger" ) { $sql = "SELECT * FROM $db_table WHERE for_finger = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////FINGER SLOT - END//////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// /////////////////////////////WRIST SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "wrist" ) { $sql = "SELECT * FROM $db_table WHERE for_head = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////WRIST SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////CHARM SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "charm" ) { $sql = "SELECT * FROM $db_table WHERE for_charm = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////CHARM SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////PRIMARY SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "primary" ) { $sql = "SELECT * FROM $db_table WHERE for_primary = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////PRIMARY SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////SECONDARY SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "secondary" ) { $sql = "SELECT * FROM $db_table WHERE for_head = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////SECONDARY SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////RANGED SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "ranged" ) { $sql = "SELECT * FROM $db_table WHERE for_head = '1' ORDER BY name"; $result = mysql_query ($sql,$db); echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"90%\" bgcolor=\"#FFDCCC\">"; echo "<tr> <th align=\"left\">Name</th> <th align=\"left\">Effect</th> <th align=\"left\">Quality</th> <th align=\"left\">Level</th> <th align=\"left\">Colour</th> <th align=\"left\">Faction Name</th> <th align=\"left\">Faction Value</th></tr>"; while($row = mysql_fetch_array( $result )) { $row_color = ($row_count % 2) ? $color1 : $color2; // Print out the contents of each row into a table echo " <tr> <td bgcolor=\"$row_color\">" . $row["name"] . "</td> <td bgcolor=\"$row_color\">" . $row["effect"] . "</td> <td bgcolor=\"$row_color\">" . $row["quality"] . "</td> <td bgcolor=\"$row_color\">" . $row["level"] . "</td> <td bgcolor=\"$row_color\">" . $row["colour"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionname"] . "</td> <td bgcolor=\"$row_color\">" . $row["factionvalue"] . "</td> </tr> "; $row_count++; } echo "</table>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////RANGED SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////FOOD SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "food" ) { echo "<font color=#ffffff>Dream on sunshine there aint no food adorns yet</font>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////FOOD SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////DRINK SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "drink" ) { echo "<font color=#ffffff>Dream on sunshine there aint no drink adorns yet</font>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////DRINK SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /////////////////////////////DRINK SLOT - START////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// elseif ( $slot == "ammo" ) { echo "<font color=#ffffff>Dream on sunshine there aint no ammo adorns yet</font>"; } //////////////////////////////////////////////////////////////////////////////// /////////////////////////////DRINK SLOT - END//////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// else { echo "<font color=#ffffff>Either you have clicked something stupidly or edited the url or there is a bug with this script. You should never see this error message. If you do please contact Sosia :No Slot Choosen</font>"; } ?> </center> </body> </html> How can I order this query of zip codes within the radius by nearest? /** * Get Zipcode By Radius * @param string $zip US zip code * @param ing $radius Radius in miles * @return array List of nearby zipcodes */ protected function get_zipcodes_by_radius ( $zip, $radius ) { $sql = 'SELECT distinct(zip) FROM zip_codes WHERE (3958*3.1415926*sqrt((latitude-'.$zip->latitude.')*(latitude-'.$zip->latitude.') + cos(latitude/57.29578)*cos('.$zip->latitude.'/57.29578)*(longitude-'.$zip->longitude.')*(longitude-'.$zip->longitude.'))/180) <= '.$radius.';'; $zip_codes = array(); if ( $result = $this->db->query( $sql ) ) { while( $row = $result->fetch_object() ) { array_push( $zip_codes, $row->zip ); } $result->close(); } return $zip_codes; }
|