PHP - Re-ordering Rows And Adjusting Orderid
Hi everyone. I'm putting together a client list for my company and I need to be able to move clients around from day to day and also change the order they are listed. My only problem is I can't figure out a way to adjust the orderid once moving them.
My database is set up something like this:
id | orderid | driverid | day | name | email
1 1 1 Mon - -
2 3 1 Tue - -
3 2 2 Wed - -
4 4 1 Mon - -
I need to be able to edit a rows orderid, lets say from 5 to 3 and re-order everyone so that there are no orderid duplicates and no gaps. I was thinking I need to submit the form with the changed orderid and if the new orderid is different from the old orderid, a query will select and add 1 to the rows with an orderid greater than the new one submitted and only for clients on that drivers day. Once that is done a new query will re-adjust all the orderid's again and re-order them so there are no gaps.
Am I on the right track here? How would I write this code out? I feel as if im doing it all wrong. Any help is greatly appreciated. Thanks
if ($orderid1 != $orderid2) { $result = mysql_query("SELECT * FROM clients WHERE driverid = '$driverid' and day = '$day'") or die (mysql_error()); while($row = mysql_fetch_assoc($result)){ $neworderid = $row['orderid'] + 1; mysql_query("UPDATE clients SET orderid = '$neworderid', WHERE orderid > '$orderid2' and clientid = '$row[clientid]'"); } } Edited by Kinger1613, 13 December 2014 - 11:15 AM. Similar Tutorialshi i have table in my database holding food items. i need users to be able to order those items individually for example...if apples are third from the top..they should be able to move them up or down the list 1 place at a time perhaps with an up and down arrow. i have a field in my table called item_order the only problem is...users are going to be able to insert new items to the database...but i dont know how they can populate the order field...i cant set it to auto increment because the item_id is the primary key auto incrementing...how can i populate the order field? and then once i have this problem sorted how do i then allow users to change this order? im looking for code if possible please because ive spent WAY to long on this now and im struggling to grasp things people advise me to do. terminology and methods of accomplishing this are just going over my head. please help. I've been having problems displaying the correct time when extracting timestamp for a graph. Wasted a lot of time trying to adjust for timezone and then finding that it didn't help. Now trying to add 2 hours to the timestamp and not sure how. Here is the line that needs to be changed I believe.
$Date=substr(mysql_result($result,$i,"Date"),11,5); Can someone help me?
I'm not an expert php programmer and I have been using Dreamweaver to produce PHP webpages. I have run into a problem producing a sql statement. $colname_rsCustomers = "A"; if (isset($_GET['letterID'])) { $colname_rsCustomers = $_GET['letterID']; } mysql_select_db($database_connCid, $connCid); $query_rsCustomers = sprintf("SELECT * FROM customer_tbl WHERE customer_last_name LIKE %s ORDER BY customer_last_name ASC", GetSQLValueString($colname_rsCustomers, "text")); $query_limit_rsCustomers = sprintf("%s LIMIT %d, %d", $query_rsCustomers, $startRow_rsCustomers, $maxRows_rsCustomers); $rsCustomers = mysql_query($query_limit_rsCustomers, $connCid) or die(mysql_error()); $row_rsCustomers = mysql_fetch_assoc($rsCustomers); I have been trying to produce this statement: Code: [Select] SELECT * FROM customer_tbl WHERE customer_last_name LIKE 'A%' ORDER BY customer_last_name ASC The current code works with no errors. I don't know how to add the "%" without getting an error. So, the current code is only pulling last names that are "A" and I want last names that start with "A". I'd appreciate some help. Thanks in advance. I have a working guestbook, but adjusting the time is whats getting me. I am trying to get the time to change depending on the timezone. And I also trying to get the time in the format 1:00 PM, not 21:00. Then on a different note, how can I stop spamming and injections. Index page for guestbook Code: [Select] <HTML> <HEAD> <style type="text/css"> <!-- .style1 {font-size: 12px} body,td,th { font-size: 14px; } a { font-size: 12px; } body { background-color: #CCCCCC; SCROLLBAR-FACE-COLOR: #0066FF; MARGIN: 0px; SCROLLBAR-HIGHLIGHT-COLOR: #0066FF; SCROLLBAR-SHADOW-COLOR: #0066FF; SCROLLBAR-3DLIGHT-COLOR: #0066FF; SCROLLBAR-ARROW-COLOR: #51B0F2; SCROLLBAR-TRACK-COLOR: #51B0F2; Courier New; SCROLLBAR-DARKSHADOW-COLOR: #000000 } a:link { color: #0066FF; text-decoration: none; } a:visited { text-decoration: none; color: #0066FF; } a:hover { text-decoration: underline; color: #0066FF; } a:active { text-decoration: none; } --> </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><BODY> <form method="post" action="addguestbook.php"> <div align="center"></div> <div align="center"></div> <div align="center" class="style1"></div> <div align="center"><span class="style1">Name:</span><br /> <input name="name" type="text" size="30" maxlength="40" /> <br /> <span class="style1"><br /> Email:</span><br /> <input name="email" type="text" size="30" maxlength="40" /> <br /> <br /> <span class="style1">Home Page:</span><br /> <input name="site" type="text" size="30" value="http://" maxlength="40" /> <br /> <br /> <span class="style1">Message:</span><br /> <textarea name="msg" cols="22" rows="6"></textarea> <br /> <br /> <input type="reset" value="Reset" /> <input type="submit" value="Send" /> </div> <div align="center"> <p> </p> <?php $file = "guestbook.txt"; if (fopen($file, "r")) { $fil = "guestbook.txt"; $fo = fopen ($fil, "r"); $con = fread ($fo,filesize ($fil)); fclose ($fo); echo "$con"; } else { echo "<h3>Sorry there was an error please contact us now<h3>"; } ?></div> </BODY> </HTML> addguestbook.php Code: [Select] <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!-- body,td,th { font-size: 12px; color: #000000; } a:link { text-decoration: none; color: #0066FF; } a:visited { text-decoration: none; color: #0066FF; } a:hover { text-decoration: underline; color: #0066FF; } a:active { text-decoration: none; } body { background-color: #CCCCCC; SCROLLBAR-FACE-COLOR: #0066FF; MARGIN: 0px; SCROLLBAR-HIGHLIGHT-COLOR: #0066FF; SCROLLBAR-SHADOW-COLOR: #0066FF; SCROLLBAR-3DLIGHT-COLOR: #0066FF; SCROLLBAR-ARROW-COLOR: #51B0F2; SCROLLBAR-TRACK-COLOR: #51B0F2; Courier New; SCROLLBAR-DARKSHADOW-COLOR: #000000 } --> </style> </HEAD> <BODY> <?php function is_leapyear($year = 2004) { return ($year%4)==0; } $file = "guestbook.txt"; $name = $_POST['name']; $email = $_POST['email']; $site = $_POST['site']; $msg = $_POST['msg']; $site = stripslashes($site); $msg = stripslashes($msg); $email = stripslashes($email); $name = stripslashes($name); $msg = str_replace ("<","<",$msg); $msg = str_replace ("\n","<br>",$msg); $site = str_replace ("<","<",$site); $site = str_replace ("\n","<br>",$site); $email = str_replace ("<","<",$email); $email = str_replace ("\n","<br>",$email); $name = str_replace ("<","<",$name); $name = str_replace ("\n","<br>",$name); if(empty($email) || empty($name) || empty($msg)) { echo "<h3>Sorry all fields are required</h3>"; } else { $fp = fopen($file,"a"); $timestamp=date("M/D/Y h:m:s"); fwrite($fp, ' <font size="3"> <BR><BR> Posted: '.$timestamp.'<br /> Name: '.$name.'<BR> Email: <a href="mailto:'.$email.'">'.$email.'</a><BR> Home Page: <a href="'.$site.'">'.$site.'</a><BR>Message: '.$msg.'<BR> '); fclose($fp); echo '<font size="3"><p align="center">Thank you '.$name.' for singing my guestbook</p></font>'; } ?> <div align="center"></div> <div align="center"></div> <div align="center"></div> <div align="center"></div> <p align="center"><a href="index.php">Back to GuestBook</a></p> <div align="center"></div> </BODY> </HTML> I need some help adjust a search form that uses PHP/MySQL/AJAX/JQuery. I am not sure what area needs to be adjusted, but I think it's in the Query. The search from searches across the MySQL database of sports team info and works fine. the only problem is in the return of one key word when I needed the exact match of two or more words. For instance you type in 'Miami Heat' and the results returned are for 'Miami Heat' and 'Miami Dolphins', so anything with the key word Miami is returned. Here is the PHP code <?php $dbhost = "localhost"; $dbuser = "username"; $dbpass = "pw"; $dbname = "db_name"; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); if(isset($_GET['query'])) { $query = $_GET['query']; } else { $query = ""; } if(isset($_GET['type'])) { $type = $_GET['type']; } else { $query = "count"; } if($type == "count") { $sql = mysql_query("SELECT count(category_id) FROM players WHERE MATCH(sport,first_name,last_name,MVP,team) AGAINST('$query' IN BOOLEAN MODE)"); $total = mysql_fetch_array($sql); $num = $total[0]; echo $num; } if($type == "results") { $sql = mysql_query("SELECT sport,first_name,last_name,MVP,team FROM players WHERE MATCH(sport,first_name,last_name,MVP,team) AGAINST('$query' IN BOOLEAN MODE)"); echo "<table>"; echo "<tr>"; echo "<th>First Name</th><th>Last Name</th><th>Team</th><th>MVP</th>"; while($array = mysql_fetch_array($sql)) { $sport = $array['sport']; $first_name = $array['first_name']; $last_name = $array['last_name']; $team = $array['team']; $MVP = $array['MVP']; echo "<tr><td>" . $first_name . "</td>\n<td>". $last_name ."</td>\n<td>" .$team."</td>\n<td> . $MVP .</td>\n</tr>\n"; } echo "</table>";=\ } mysql_close($conn); ?> what Im basically trying to do is just like a phpmyadmin function... you select rows you want to update with a checkbox and then it takes you to a page where the rows that are clicked are shown in forms so that you can view and edit info in them... and then have 1 submit button to update them all at once. 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? Hello once again, i got this code that takes all images from a folder and displays them close to each other. Heres the code: <?php $dir = 'uploads/thumbs/watermarkedthumbs/'; $file_display = array ('jpg', 'jpeg', 'png', 'gif'); if (file_exists($dir) == false) { echo 'tt'; } else { $dir_contents = scandir($dir); foreach ($dir_contents as $file) { $file_type = strtolower(end(explode('.', $file))); if ($file !== '.' && $file !== '..' && in_array($file_type, $file_display) == true) { echo '<img src="', $dir, '/', $file, '" alt="', $file, '" />'; } } } ?> How do i add margins in between them? i wanna make it smth like 'margin-left:10px, margin-top-10px'. Also, how do i add an 'overflow'? i mean, my images currently are displayed in a div, and i wanna make it so that if the folder has lets say 9 images, it would only display 6 of them, and the rest would be displayed in the same div after i click a button or smth (like '1' for the first div and '2' would appear if theres an overflow, and when i click '2' the rest of the images would appear). To make these adjustments do i need to make a different php file or do i change something in this code? thanks in advance. 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 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 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 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!!! 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....
I've a php "program" that helps me manage sales.
php file in pdf: https://we.tl/t-D4xTtG3Ync 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 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, 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 |