PHP - Complicated Database And Php Ordering And Combining
I have 5 tables.
1 is which a user specifies another partner id. The other 4 are different attributes of the partner id, with times for each. Now what I want to do is pull the data from ALL 4 different tables and then 'mix' them together and order by their respective times (and only choose the values matching the partner id). I'm getting mighty confused trying left joins, wheres and anything else I know. It seems too complex to be done :s Similar TutorialsThis topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=347091.0 I have inherited this database and can't change the design. I need to perform a SELECT query and group certain records together for matching employeeID values. The fields: employeeID field1 field2 date (1) field1 can be 1,2,3,4 or 5 only (2) field2 can be a,b,c or a number from 1-100 (varchar though) (3) if field1 and field2 are blank/empty then group together So: employeeID / field1 / field2 / date 32 / 3 / / 1297184426 45 / / b / 1248723499 32 / 3 / / 1258762988 20 / / / 20 / / / 1268722384 So record 1 and 3 above will be grouped, and so will 4 and 5. When I mean grouped, I mean so that only one record will be returned / displayed. Also, when it displays only one record due to being 'grouped', I would like it to return the highest 'date' field value (UNIX Timestamp value) (so the newest / latst date) OR if one of the records is empty then show this instead. So in the above example, record 1 & 3 will return a date of 1297184426 and records 4 and 5 will return nothing for date. <?php echo $myname; $myname = "Bradery"; ?> That does not work.. is there any way to get it to work without doing this <?php $myname = "Bradery"; echo $myname; ?> Quote Parse error: syntax error, unexpected '"', expecting ']' in /homepages/27/d193007783/htdocs/maddogmania/new_application/roster.php on line 41 $text=''; for($i=1; $i<=$roster_max; $i++){ $text .= " LINE41 `player" . $i . "_number` = '$_POST[player" . $i ."_number]' , `player" . $i . "_name` = '$_POST[player" . $i ."_name]' , `player" . $i . "_grade` = '$_POST[player" . $i ."_grade]' , `player" . $i . "_phone` = '$_POST[player" . $i ."_phone]' , `player" . $i . "_email` = '$_POST[player" . $i ."_email]' , `player" . $i . "_parents` = '$_POST[player" . $i ."_parents]' , "; } Thanks for the help! I am ordering a table by 2 different functions and am having a lot of trouble ORDER BY Level DESC, Won/(Won+Lost) ASC 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 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? 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 --> Ok i have been after the solution for this for a while and I have finally got it in a state where it is producing results but....... they are wrong so I will start from the beginning with what I have and what I am trying to do. I have these tables Members Id Name Clubs ID Name Permission ID Name Link MemberID PermissionID ClubID When a member joins a club thier ID ant the ID of the club are entered into the link table along with their permission (as a number) so MemberID PermissionID ClubID 01 02 01 I have a loop which is going to echo the clubs a member is a part of. So for my querys function GetUser($user) { $qFindUser = "SELECT * FROM members WHERE email = '$user'"; $rFindUser = mysql_query($qFindUser); $UserInfo = mysql_fetch_array($rFindUser); return $UserInfo; } function GetLinkByMemberID($link) { $qLink = mysql_query("SELECT * FROM link WHERE memberID = '$link'"); $Link = mysql_fetch_array($qLink); return $Link; } function GetClub1($clubs) { $qFindClub = mysql_query("SELECT * FROM clubs WHERE clubID = '$clubs'"); return $qFindClub; } function GetPermission($per) { $qPermission = mysql_query("SELECT * FROM `permissions` WHERE permissionID = '$per'"); $permission = mysql_fetch_array($qPermission); return $permission; } $User = GetUser($_SESSION['Username']); // returns as array from the login details all member details $Link = GetLinkByMemberID($User['memberID']); // returns as a fetch array all clubs the member is a part of $Club = GetClub1($Link['clubID']); // returns as the query $permission = GetPermission($Link['permission']); //returns as array so I can echo the permission word not ID Now the loop is limited by 3 so <?php $Club = mysql_fetch_array($Club); $stack3 = ($Club+$Link); for($i = 0; ($CP = ($stack3)) && $i < 3; $i++ ){ ?> <tr> <th scope="col"><img name="" src="" width="32" height="32" alt="" /></th> <th scope="col"><?php echo $CP['name']; //from the club table ?><span class="ownertext"> <?php echo $CP['permission']; //from the link table ?> The problem I'm having the the loop is returning the first record its selects 3 times and not echoing each club once. I have worked on it for so long I can no longer make sense of it. Can anyone see my errors and point out just how to fix it? Im guessing it involves something to do with how Im finding my permission but I really dont know. As im sure you can see from the code Im a php beginner so Im struggling to make sense of this. 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! 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 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 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, 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
I've a php "program" that helps me manage sales.
php file in pdf: https://we.tl/t-D4xTtG3Ync 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!!! 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 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 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 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!! |