PHP - "simple" Ordering System
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 Similar TutorialsHi, 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 Hello, I'm in need of assistance trying to get this PHP Script working and I'm hoping you'll be able to find a solution. SQL Table Format: http://pastebin.com/LUuu2pLp Code: [Select] -- -- Table structure for table `hungergames_records` -- CREATE TABLE IF NOT EXISTS `hungergames_records` ( `user_id` int(10) unsigned NOT NULL, `victories` int(32) unsigned NOT NULL DEFAULT '0', `biggest_kill_streak` int(32) unsigned NOT NULL DEFAULT '0', `most_chests_opened` int(32) unsigned NOT NULL DEFAULT '0', `total_chests_opened` int(32) unsigned NOT NULL DEFAULT '0', `lastlogin` int(32) unsigned NOT NULL DEFAULT '0', `longest_lifespan` int(32) unsigned NOT NULL DEFAULT '0', `total_lifespan` int(32) unsigned NOT NULL DEFAULT '0', `total_points` int(32) unsigned NOT NULL DEFAULT '100', `most_points` int(32) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -------------------------------------------------------- -- -- Table structure for table `hungergames_users` -- CREATE TABLE IF NOT EXISTS `hungergames_users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `donor` int(32) unsigned NOT NULL DEFAULT '0', `user` varchar(40) NOT NULL, `donor_cooldown` int(100) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `user` (`user`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=12641 ; PHP Code: http://pastebin.com/aQANz0BL Code: [Select] <?php include("config.php"); $getRankQuery = "SELECT hungergames_users.id, hungergames_records.user_id, hungergames_records.victories, hungergames_records.biggest_kill_streak, hungergames_records.most_chests_opened, hungergames_records.total_chests_opened, hungergames_records.lastlogin, hungergames_records.longest_lifespan, hungergames_records.total_lifespan, hungergames_records.total_points, hungergames_records.most_points, hungergames_users.donor, hungergames_users.user FROM hungergames_records, hungergames_users WHERE hungergames_records.user_id = hungergames_users.id ORDER BY hungergames_records.total_points DESC"; $getRankResult = mysql_query($getRankQuery); //Source From: http://stackoverflow.com/questions/7704311/calculate-rank-with-points function getUserRank($searchedUserID) { $userArray = getAllUsersOrderedByPoints(); $rank = 0; $lastPoints = -1; // Never happens foreach ( $userArray as $user) { if ($user['total_points'] != $lastPoints) $rank++; if ($user['user_id'] == $searchedUserID) break; } return $rank; } while ($data = mysql_fetch_array($result)) { echo getUserRank($data["user_id"]); } ?> What am I trying to accomplish? Simple Ranking System... Basically, The total points is stored into total_points field for each user and whoever has the highest score will be Ranked #1 and count down to a the full database (Currently at 12,641 users) Now the above function getUserRank is the code I pulled from the above source listed, I think my issue relies in the function of getAllUsersOrderedByPoints(); - I've tried doing something like. Code: [Select] $row = mysql_fetch_array($getRankResult); Then adding: $userArray = $row["user_id"]; Didn't work - So if you can help me correct this than I'll be greatly appertiated. Lastly, I've tried doing: Code: [Select] $index = 1; while ($data = mysql_fetch_array($getRankQuery)) { echo $index++ . " " . $data["id"] . " ".$data["user"]." <br>\n"; } This solution works, but this solution would not work for when a "User is Search" it would count them as the highest rank 1,2,3 and wouldn't work, so either the function up there needs to be corrected or please help get a working solution, I've been googleing this issue and seems too be a common code issue with a lot people are having and not many solutions. The application that records data (Not PHP) doesn't store any data with a "Rank" table otherwise this would be a simple echo'ed out data. For a better understanding of what I'm trying to do - You may take a look at: http://justonemoreblock.com/lb/leaderboards.php Regards, Cory Hi i did post this on another forum which i think was the wrong place so ive posted it here aswell hope that's ok Hi i am trying to implement a simple recomendation system where the user will select an answer usign Check boxes and each box will have a value 1 -4 Those values are then passed onto the next page. I am only trying to do it based on the Price firstly to break it down bit by bit as i am not a expert im realitvely new to PHP. I am having a error with this line while {$row = mysql_fetch_array($results,MYSQL_NUM)} //get the information from the database and store in a array THE FULL CODE SO IT CAN BE SEEN IN CONTEXT WITH THE REST IS : <?php $dbh = mysql_connect("localhost", "root")//THIS CONNECTS TO THE SERVER WITH YOUR DETAILS or die ('I cannot connect to the database because: ' . mysql_error());//IF IT CANNOT CONNECT, THIS ERROR MESSAGE WILL SHOW $results = mysql_select_db ("Computers");//THIS SELECTS THE CORRECT DATABASE FROM YOUR SERVER @$price = $_POST['price']; ?> <?PHP $total_price = 0; $total_ram = 0; $number_of_items = 0; $total_items=$number_of_items + 1 while {$row = mysql_fetch_array($results,MYSQL_NUM)} //get the information from the database and store in a array { $total_price = $row["Computer_price"] + $total_price ; // this should then start with 0 and keep adding the row up $total_items = $number_of_items = $number_of_items + 1; // this should do the same but with the item number }; $av_price = $total_price/$total_items ; //gives an average of the price attribute print $av_price //Price $lowav_price = 0; //sets the low price to 0 $medav_price = 0.75 * $av_price; // sets the next level to 75 % of the avarage $highav_price = 1.25 * $av_price; // sets the next level to 125% of the average <HTML> <BODY> // for the follwing bit the user will select a check box which will have a value and these are the cases for each option. //each option is set ot be either 0 - 75% of the average or 75%- 125 % of the average or 125% and above based ont he average of the Data in the table switch ($price) { case '1' : $price_low = 0; $price_high = >= $lowav_price ; print " (I would like to pay less and get less specifications) < ".$price_low."-".$price_high.">"; break; case '2' : $price_low = >=$lowav_price; $price_high = >=$highav_price; print " (I would like to pay for what I get so what I get is equivalent to the price) < ".$price_low."-".$price_high.">"; break; case '3' : $price_low = >=$highav_price ;$price_high = >=$highav_price; print " (I would prefer to Pay as much as possible to get the best computer) < ".$price_low."-".$price_high.">"; break; case '4' : $price_low = 0; $price_high = >=$highav_price ; " (I have no preference) < ".$price_low."-".$price_high.">"; break; } print ' price option = '.$price; print "<br>"; //gives the different vaules for each selection button on the input form for price ?> <strong> SELECTED CAMCORDERS </strong> <br> <table width="75%" border="1"> <tr> <td>Model</td> <td>Price</td> <td>Stabilization</td> <td>Optical zoom</td> <td>Image</td> </tr> <?PHP while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { if (($row["price"] >= $price_low) && ($row["price"] <= $price_high)) //price // if ($row["stabilization"] == $stabilizer_present) //stabilizer // if (($row["optical_zoom"] >= $zoom_low ) // && ($row["optical_zoom"]<= $zoom_high ) // && ($row_number < 5) ) //price //{ $row_number++; ?> <tr> <td align="center"><?php print $row["price"]; ?> </td> </tr> <?php //mysql_data_seek($result, 0); }//if }//while ?> </table> </body> </html> i AHVE TRIED TO ANNOTATE it so that you can see what i am trying to do wether i am or not is another question thanx for any replies Hello, I have a simple dice system script I am using in a chat program for a website and I was wondering if someone could simply tell me how to limit the number of dice being rolled. Here are the two chunks of script that make it work: if($irc_cmd == '/d') { if($irc_cmd == $txt) { // this can only happen with a no dice - '/d' - a help request // return an explanation of the correct format $text = "dice command is /d [[n]D]s[Xm|+a|-d|/q]*"; $this->sendToUser(null, new Message($type, $this->userid, null, $text, $this->color)); return 'ok'; } // create standard failure message $invalid_msg = new Message($type, $this->userid, null, 'ERROR: invalid dice command - '.$txt.' - enter /d for help', $this->color); // remove the original command from the dice string $dicestring = str_replace($irc_cmd,'', $txt); // use lowercase versions of D and X to make parsing simpler $dicestring = strtolower($dicestring); // remove any user entered spaces $dicestring = str_replace(' ', '', $dicestring); // note that all modifiers will follow the dice spec 'nDs' // number of dice is optional e.g. 1d4 d4 and 4 all represent a single 4-sided die // if the first token is blank, then the user intended for one die e.g. /d d20 means /d 1d20 // if the is no 'd' then the user intended one die e.g. /d 20 means /d 1d20 $parts = explode('d', $dicestring); if(count($parts)>2) { // only one 'd' is allowed $this->sendToUser(null, $invalid_msg); return 'ok'; } elseif(count($parts)==1) { // if no 'D' assume '1' die $number = 1; } else { $number = (int)$parts[0]; if ($parts[0] == "") { // if $number == 0 // if no number assume '1' die $number=1; } elseif ("$number" != "$parts[0]") { // only integers allowed $this->sendToUser(null, $invalid_msg); return 'ok'; } $dicestring = $parts[1]; } if($number < 1) { // can't allow a negative number of dice $this->sendToUser(null, $invalid_msg); return 'ok'; } // check for sides and modifiers // expand the string to put spaces around all the tokens we want $dicestring = str_replace('+', ' + ', $dicestring); $dicestring = str_replace('-', ' - ', $dicestring); $dicestring = str_replace('x', ' x ', $dicestring); $dicestring = str_replace('/', ' / ', $dicestring); // explode the whole thing to create tokens $parts = explode(' ', $dicestring); // the only other tokens should be integers // allowed formats from here are s[Xm][+a][-d][/q] // we should allow any series of these in any order, applying them left to right // the first part must be the sides $sides = (int)$parts[0]; if ("$sides" != "$parts[0]") { $this->sendToUser(null, $invalid_msg); return 'ok'; } if($sides < 1) { // can't allow a negative number of sides $this->sendToUser(null, $invalid_msg); return 'ok'; } // get the user's name //$user = ChatServer::getUser($this->userid); //$name= $user['login']; // start writing the reply string $text = '*rolls* '.$number.'d'.$sides.': '; // seed the randomizer srand(time()); // with number and sides, roll the dice, adding them up $total = 0; for($i = 0; $i < $number; $i++) { $roll = (rand()%$sides)+1; if($i != 0) $text .= '+'; $text .= $roll; $total += $roll; } // now apply all the modifiers to the roll, in the order the user specified them for ($i = 1; $i < count($parts); $i+=2) { // the value needs to be an integer $value = (int)$parts[$i+1]; $v = $parts[$i+1]; if ("$value" != "$v") { $this->sendToUser(null, $invalid_msg); return 'ok'; } // the token needs to be one of the operators - otherwise abort $token = $parts[$i]; switch ($token) { case '+': // add $total += $value; break; case '-': // subtract $total -= $value; // make minimum 1 - remove this like to allow 0 and lower if ($total<1) $total=1; break; case 'x': // multiply $total *= $value; break; case '/': // divide - round up so 1d6/3 will be the same as 1d2 $total = ceil($total/$value); break; default: $this->sendToUser(null, $invalid_msg); return 'ok'; } // add the modifier to the display string $text .= $token.$value; } // and display the final result $text .= ': '.$total; // gets sent to particular room, but with users name tacked on, so a user could spoof it // at least 'msgu' looks different $this->sendToRoom(null, new Message('rpg', $this->userid, $this->roomid, $text)); return 'ok'; } and function Message($command, $userid = null, $roomid = null, $txt = null, $color = null) { $this->command = $command; if ($command == 'rpg') $this->command = 'msgu'; $this->userid = $userid; $this->roomid = $roomid; $this->color = htmlColor($color); if($command != 'rpg') { $txt = str_replace('*rolls*', 'rolls', $txt); } if(isset($txt)) { $this->txt = $this->parse($txt); } } So again all I want it to do is limit the number of dice being rolled because right now someone can do a /d 1000000d100000 and completely crash the chat for everyone. I am thinking 100 on either variable would be plenty. Thanks for your help! Hey guys first of all I got 3 files - index.php require_once('/libs/template.class.php'); $template = new Template; $template->assign("title","test"); template.php <?php echo $title; ?> template.class.php function assign($var, $val) { $var = $val; } I'm trying to assign a variable in index.php, then recall it in the template.php, how would I go about this? Thank you! I'm attempting to implement a simple social networking system but at the moment am confused about how to create a multiple query which will display a certain user's friends list. The database contains four tables, the two tables that I'm using at the moment at 'usersTable' and 'friendshipsTable' are detailed below. usersTable | Table that stores all the user data UserID | Default primary key Forename | Surname | Username | Password | Email Address | friendshipTable | Table that stores information about friendships between users FriendshipID | Default primary key userID_1 | UserID userID_2 | UserID Status | Either Pending or Confirmed. The user's id is parsed into the url, and then saved into a variable. blah.com/userprofile.php?id=6 $id = $_GET['id']; I am familiar with creating simple queries, but can't quite work out how to set up multiple table queries. What the query needs to do is to check the userID that is parsed with the url, and then check the friendshipsTable by checking if either the userID_1 or userID_2 field matches the userID to grab the records from the table where there is a match. The next step is to check to see if the friendship is 'Confirmed' or 'Pending' and if it is 'Pending' to ignore it. Once the records have then been chosen I need the query to then check the value in either userID_1 or userID_2 that doesn't match userID and then pull the user's username and name from the usersTable so it can be displayed on a webpage. I've no idea hoe much I may or may not be overcomplicating this, an example of the code that I've got so far for this query can be found below, but that's as far as I've got at the moment. $displayFriends = mysql_query("SELECT * FROM friendshipTable, usersTable WHERE friendshipTable.userID_1='$id' OR friendshipTable.userID_2='$id' "); Cheers for any help. hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 I am ordering a table by 2 different functions and am having a lot of trouble ORDER BY Level DESC, Won/(Won+Lost) ASC 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 --> 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 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'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. 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
I've a php "program" that helps me manage sales.
php file in pdf: https://we.tl/t-D4xTtG3Ync |