Jump to content

craygo

Staff Alumni
  • Posts

    1,972
  • Joined

  • Last visited

  • Days Won

    1

craygo last won the day on April 26 2013

craygo had the most liked content!

About craygo

  • Birthday 04/14/1970

Contact Methods

  • AIM
    craygo69
  • Website URL
    http://theelders.net

Profile Information

  • Gender
    Male
  • Location
    Rhode Island

craygo's Achievements

Member

Member (2/5)

2

Reputation

  1. Thanks Psycho, It's so simple I just didn't even think of it. Appreciate your help. Ray
  2. Yes i have heard of normalization and use it quite extensively. At the time this seemed like a decent way to hold the data, which was quite a while ago and since it has been in use for over 4 years I don't really feel like reinventing the wheel. Everything worked fine up until the new scoring piece was implemented. So just trying to work with what I got. Ray
  3. Forgot here is a dump of the table. DROP TABLE IF EXISTS `scorecards`; CREATE TABLE IF NOT EXISTS `scorecards` ( `sc_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `dateid` int(11) NOT NULL DEFAULT '0', `playid` int(11) NOT NULL DEFAULT '0', `h1` int(2) NOT NULL DEFAULT '0', `h1p` float(2,1) NOT NULL DEFAULT '0.0', `h2` int(2) NOT NULL DEFAULT '0', `h2p` float(2,1) NOT NULL DEFAULT '0.0', `h3` int(2) NOT NULL DEFAULT '0', `h3p` float(2,1) NOT NULL DEFAULT '0.0', `h4` int(2) NOT NULL DEFAULT '0', `h4p` float(2,1) NOT NULL DEFAULT '0.0', `h5` int(2) NOT NULL DEFAULT '0', `h5p` float(2,1) NOT NULL DEFAULT '0.0', `h6` int(2) NOT NULL, `h6p` float(2,1) NOT NULL DEFAULT '0.0', `h7` int(2) NOT NULL, `h7p` float(2,1) NOT NULL DEFAULT '0.0', `h8` int(2) NOT NULL, `h8p` float(2,1) NOT NULL DEFAULT '0.0', `h9` int(2) NOT NULL, `h9p` float(2,1) NOT NULL DEFAULT '0.0', `gross` int(2) NOT NULL DEFAULT '0', `net` int(2) NOT NULL DEFAULT '0', `adj_gross` int(2) NOT NULL DEFAULT '0', `tpoints` float(4,1) NOT NULL DEFAULT '0.0', `ppoints` float(4,1) NOT NULL, `schandicap` float(5,2) NOT NULL DEFAULT '0.00', `fill_in` int(1) NOT NULL DEFAULT '0', PRIMARY KEY (`sc_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ; -- -- Dumping data for table `scorecards` -- INSERT INTO `scorecards` (`sc_id`, `dateid`, `playid`, `h1`, `h1p`, `h2`, `h2p`, `h3`, `h3p`, `h4`, `h4p`, `h5`, `h5p`, `h6`, `h6p`, `h7`, `h7p`, `h8`, `h8p`, `h9`, `h9p`, `gross`, `net`, `adj_gross`, `tpoints`, `ppoints`, `schandicap`, `fill_in`) VALUES (1, 1, 189, 4, 0.5, 4, 0.0, 5, 0.0, 4, 1.0, 5, 0.5, 4, 1.0, 3, 1.0, 5, 0.5, 5, 0.5, 39, 34, 39, 5.0, 0.0, 5.00, 0), (2, 1, 203, 4, 0.5, 4, 1.0, 5, 1.0, 5, 0.0, 5, 0.5, 5, 0.0, 4, 0.0, 5, 0.5, 5, 0.5, 42, 35, 42, 4.0, 0.0, 7.00, 0), (3, 1, 190, 4, 0.5, 4, 0.0, 4, 0.0, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.0, 4, 1.0, 36, 30, 36, 3.5, 0.0, 6.00, 0), (4, 1, 204, 5, 0.5, 4, 1.0, 4, 1.0, 4, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 4, 1.0, 6, 0.0, 42, 28, 42, 5.5, 0.0, 14.00, 0), (5, 1, 191, 4, 0.5, 4, 0.0, 4, 0.0, 3, 1.0, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 5, 0.0, 36, 31, 36, 3.5, 0.0, 5.00, 0), (6, 1, 201, 4, 0.5, 4, 1.0, 4, 1.0, 4, 0.0, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 1.0, 36, 29, 36, 5.5, 0.0, 7.00, 0), (7, 1, 192, 4, 0.5, 4, 0.0, 4, 0.0, 4, 1.0, 4, 0.5, 4, 0.5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h1, h2, etc are the strokes for each hole.
  4. All this data starts off as arrays from the scorcard(form). The data gets inserted into the database earlier in the script. I am pretty good at queries but haven't been able to think of a way to get this one to work. I figured since I had the data already why not try using the arrays. If you have an idea on a query that would work I'm all ears. I can definatly go back to the database to get the data. Thanks Ray
  5. I am writing a golf league management system and one request is to give points for lowest net score. Simple enough. Now when there is a tie I need to go back starting at the first hole and get the lowest score and if a tie move to the next hole and so on. Also there can be more than one division so I have the division seperated. Here is the array containing the players that have tied. In the example below A is the division the next is the Players unique id and ppoints is what they would have gotten if there was no tie. Not all this information is needed but have it in the array until the script is complete. The s_id is needed to update the database which has already been populated with the scores. Array ( [A] => Array ( [193] => Array ( [s_id] => 9 [pid] => 193 [ppoints] => 6 [net] => 31 [tie] => yes ) [199] => Array ( [s_id] => 10 [pid] => 199 [ppoints] => 7 [net] => 31 [tie] => yes ) [191] => Array ( [s_id] => 5 [pid] => 191 [ppoints] => 5 [net] => 31 [tie] => yes ) ) [B] => Array ( [202] => Array ( [s_id] => 8 [pid] => 202 [ppoints] => 6 [net] => 25 [tie] => yes ) [194] => Array ( [s_id] => 11 [pid] => 194 [ppoints] => 7 [net] => 25 [tie] => yes ) ) ) This array is the strokes achieved by each golfer. So you have the unique id and then h1 is hole1 and so on. Array ( [189] => Array ( [h1] => 4 [h2] => 4 [h3] => 5 [h4] => 4 [h5] => 5 [h6] => 4 [h7] => 3 [h8] => 5 [h9] => 5 ) [203] => Array ( [h1] => 4 [h2] => 4 [h3] => 5 [h4] => 5 [h5] => 5 [h6] => 5 [h7] => 4 [h8] => 5 [h9] => 5 ) [190] => Array ( [h1] => 4 [h2] => 4 [h3] => 4 [h4] => 4 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 4 ) [204] => Array ( [h1] => 5 [h2] => 4 [h3] => 4 [h4] => 4 [h5] => 5 [h6] => 5 [h7] => 5 [h8] => 4 [h9] => 6 ) [191] => Array ( [h1] => 4 [h2] => 4 [h3] => 4 [h4] => 3 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 5 ) [201] => Array ( [h1] => 4 [h2] => 4 [h3] => 4 [h4] => 4 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 4 ) [192] => Array ( [h1] => 4 [h2] => 4 [h3] => 4 [h4] => 4 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 4 ) [202] => Array ( [h1] => 4 [h2] => 4 [h3] => 4 [h4] => 5 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 4 ) [193] => Array ( [h1] => 4 [h2] => 5 [h3] => 4 [h4] => 4 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 4 ) [199] => Array ( [h1] => 5 [h2] => 4 [h3] => 4 [h4] => 4 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 4 ) [194] => Array ( [h1] => 4 [h2] => 4 [h3] => 5 [h4] => 4 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 4 ) [200] => Array ( [h1] => 4 [h2] => 4 [h3] => 4 [h4] => 4 [h5] => 4 [h6] => 4 [h7] => 4 [h8] => 4 [h9] => 4 ) [195] => Array ( [h1] => 5 [h2] => 5 [h3] => 5 [h4] => 5 [h5] => 5 [h6] => 5 [h7] => 5 [h8] => 5 [h9] => 5 ) [197] => Array ( [h1] => 5 [h2] => 5 [h3] => 5 [h4] => 5 [h5] => 5 [h6] => 5 [h7] => 5 [h8] => 5 [h9] => 6 ) [196] => Array ( [h1] => 5 [h2] => 5 [h3] => 5 [h4] => 5 [h5] => 5 [h6] => 5 [h7] => 5 [h8] => 5 [h9] => 5 ) [198] => Array ( [h1] => 5 [h2] => 5 [h3] => 5 [h4] => 5 [h5] => 5 [h6] => 5 [h7] => 5 [h8] => 5 [h9] => 5 ) ) So here's what needs to happen. Those 3 in the first division who have ties need to compare scores. So first hole 193 and 191 got 4 sonot they move to the second hole. 191 got a 4 so he ranks first so 193 would rank second and 199 would be third. I need a loop to compare all thrugh the 9 holes just in case it goes till the end. Hope I explained it well enough. Thanks in advance for the help.
  6. are you sure you have a row in stores that links to a row in depthour? you can try using the depthour table storeid to query on rather that the stores table $sql1 ="SELECT depthour.storeid, depthour.day, depthour.hour, SUM(depthour.qty) AS 'Total Quantity', SUM(depthour.value) AS 'Total Value', AVG(depthour.qty) AS 'Average Quantity', AVG(depthour.value) AS 'Average Value', SUM(depthour.value) / SUM(depthour.qty) AS 'Average Value Per Item', stores.storename, stores.storeID, stores.accountref FROM depthour INNER JOIN stores ON stores.storeID = depthour.storeID WHERE accountref = '1234' AND day='$day1' AND depthour.storeid = '$storeid'"; With an inner join you should at least get the data in the depthour table even if there is no associated row in the stores table. If your main table is stores you may want to switch the query up to get at least the stores even if there is no depthour data associated with it. $sql1 ="SELECT depthour.storeid, depthour.day, depthour.hour, SUM(depthour.qty) AS 'Total Quantity', SUM(depthour.value) AS 'Total Value', AVG(depthour.qty) AS 'Average Quantity', AVG(depthour.value) AS 'Average Value', SUM(depthour.value) / SUM(depthour.qty) AS 'Average Value Per Item', stores.storename, stores.storeID, stores.accountref FROM stores INNER JOIN depthour ON stores.storeID = depthour.storeID WHERE accountref =1234 AND day='$day1' AND stores.storeid = '$storeid'"; Ray
  7. i think you running into a problem with your quotes. You should also make sure your post values are being checked before submiting them to your query. also passe the store id rather than the store name to the query <?php require_once 'MySQLcon.php'; //connect to db with creds from this file $get=mysql_query("SELECT storeid, storename FROM stores WHERE accountref='1234'"); echo "<center>"; echo "<select name='storeid' type='int' id='storename'>"; while($row = mysql_fetch_assoc($get)) { echo '<option value="'.$row['storeid'].'" >'.$row['storename'].'</option>'; } echo "</select></center>"; ?> Now run your query $day1 = $_POST['day1']; $storeid = $_POST['storeid']; $sql1 ="SELECT depthour.storeid, depthour.day, depthour.hour, SUM(depthour.qty) AS 'Total Quantity', SUM(depthour.value) AS 'Total Value', AVG(depthour.qty) AS 'Average Quantity', AVG(depthour.value) AS 'Average Value', SUM(depthour.value) / SUM(depthour.qty) AS 'Average Value Per Item', stores.storename, stores.storeID, stores.accountref FROM depthour INNER JOIN stores ON stores.storeID = depthour.storeID WHERE accountref =1234 AND day='$day1' AND stores.storeid = '$storeid'"; try that
  8. I have a pretty simple list which comes from a table. I initially show only a couple fields in the list but have an icon which when clicked will load a div with all the details for that row. it works fine but for some reason everytime I click the link it requests the page exponentialy. here is the link <a href="/media/pdet/'.$r->PID.'" class="load" /><img src="/assets/media/img/info.png" alt="edit" title="Details" border="0" /></a> here is the jquery function $(function(){ $("a.load").click(function (e) { e.preventDefault(); $("#pdetails").show("slow"); $("#projd").load($(this).attr("href")); }); }); #pdetails is the main div and #projd is the div the page gets loaded into. And here is the web console from firefox showing what happens [08:44:55.653] GET http://192.168.20.13/media/pdet/10 [HTTP/1.1 200 OK 63ms] [08:44:59.672] GET http://192.168.20.13/media/pdet/13 [HTTP/1.1 200 OK 62ms] [08:44:59.751] GET http://192.168.20.13/media/pdet/13 [HTTP/1.1 200 OK 62ms] [08:45:02.472] GET http://192.168.20.13/media/pdet/11 [HTTP/1.1 200 OK 62ms] [08:45:02.555] GET http://192.168.20.13/media/pdet/11 [HTTP/1.1 200 OK 62ms] [08:45:02.625] GET http://192.168.20.13/media/pdet/11 [HTTP/1.1 200 OK 61ms] [08:45:02.699] GET http://192.168.20.13/media/pdet/11 [HTTP/1.1 200 OK 62ms] [08:45:05.677] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 65ms] [08:45:05.754] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 63ms] [08:45:05.825] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 63ms] [08:45:05.892] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 62ms] [08:45:05.967] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 62ms] [08:45:06.037] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 62ms] [08:45:06.106] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 61ms] [08:45:06.182] GET http://192.168.20.13/media/pdet/12 [HTTP/1.1 200 OK 62ms] as you can see when I click on a link the first time it request once, then click another it request twice, the third time it runs four times and so on. If I refresh the page it resets. Thanks in advance for your help. Ray
  9. no need to sort by ID since this is the page that will retrieve the id from your previous list. You would sort that list by ID. <?php $ID = mysql_real_escape_string($_GET['ID']); $sql = "SELECT * FROM articles WHERE ID = '$ID'; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($res); // no need to loop since you are retrieving only one row $num_rows = mysql_num_rows($res); // check to see if any results were found, just in case someone puts an ID in the url without clicking on your link if($num_rows > 0) { echo $row['ID'].' '.$row['title'].' '.$row['intro']; } else { echo "No results found"; } ?> Try it out Ray
  10. So you want a dropdown list with all the rows. <form method="post" action="myEditPage.php" /> <select name="id" /> <?php $resultt = $myDBClass->get_results("SELECT * from Assignment "); $sayi = 0; while (($resultt[$sayi]->Name)!= null) { echo ' <option value="'.$resultt[$sayi]->ID.'">'.$resultt[$sayi]->Name.'--'.$resultt[$sayi]->Surname.'</option>'; } ?> </select> </form> now on your edit page you can query the table and get the existing data $id = mysql_real_escape_string($_POST['id']); $resultt = $myDBClass->get_results("SELECT * from Assignment where ID = '$id'"); Now you can set the values in your form <input name="name" value="<?php echo $resultt[0]->Name; ?>" /> Not sure how your class is working but I think you get the idea. Ray
  11. give me a the names of the fields in your table. and I will help you out.
  12. you should just be sending the ID, that is all that is needed. Then you use the example above to retrieve the rest of the information out of the database. No need to put all kinds of data in the url. Ray
  13. the price needs to be retrieve from the database in order to get the price $productid = $_GET['product_id']; $sql = "SELECT * FROM table WHERE productid = '$productid'"; $query = mysql_query($sql); $row = mysql_fetch_assoc($query) echo $row['productid'].' '.$row['price']; Will have to change the vales to match your field names but should be enough to get you started. Ray
  14. I would use an array rather than a comma separated string. Problem you are having is you don't know what options(like shirt size) go with which product. I have not test this but you should be able to get the idea session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'empty': if($cart) { unset($cart); } break; case 'add': $cart[] = array("product_id" => $_GET['product_id'], "qty" => $qty, "size" => $size); break; $_SESSION['cart'] = $cart; By putting it into an array each product will have its own row in the array and you can also add options to the row as I have added above. Now you should be able to loop through the array and show the cart function showCart() { global $db; if (!empty($_SESSION['cart'])) { foreach ($_SESSION['cart'] as $item) { // show your results below echo $item['product_id'], $item['qty'], $item['size']; } } } Hope that helps Ray
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.