Jump to content

craygo

Staff Alumni
  • Posts

    1,972
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by craygo

  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, 4, 0.5, 4, 0.5, 4, 0.5, 36, 26, 36, 4.0, 0.0, 10.00, 0), (8, 1, 202, 4, 0.5, 4, 1.0, 4, 1.0, 5, 0.0, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 37, 25, 37, 5.0, 0.0, 12.00, 0), (9, 1, 193, 4, 1.0, 5, 0.0, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 37, 31, 37, 4.5, 0.0, 6.00, 0), (10, 1, 199, 5, 0.0, 4, 1.0, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 4, 0.5, 37, 31, 37, 4.5, 0.0, 6.00, 0), (11, 1, 194, 4, 0.5, 4, 0.0, 5, 0.0, 4, 0.5, 4, 0.5, 4, 0.0, 4, 0.5, 4, 0.5, 4, 0.0, 37, 25, 37, 2.5, 0.0, 12.00, 0), (12, 1, 200, 4, 0.5, 4, 1.0, 4, 1.0, 4, 0.5, 4, 0.5, 4, 1.0, 4, 0.5, 4, 0.5, 4, 1.0, 36, 20, 36, 6.5, 0.0, 16.00, 0), (13, 1, 195, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 1.0, 45, 37, 45, 5.0, 0.0, 8.00, 0), (14, 1, 197, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 5, 0.5, 6, 0.0, 46, 38, 46, 4.0, 0.0, 8.00, 0), (15, 1, 196, 5, 0.5, 5, 0.0, 5, 0.0, 5, 0.5, 5, 0.5, 5, 0.0, 5, 0.5, 5, 0.5, 5, 0.0, 45, 31, 45, 2.5, 0.0, 14.00, 0), (16, 1, 198, 5, 0.5, 5, 1.0, 5, 1.0, 5, 0.5, 5, 0.5, 5, 1.0, 5, 0.5, 5, 0.5, 5, 1.0, 45, 27, 45, 6.5, 0.0, 18.00, 0); 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
  15. can use $_SERVER['HTTP_USER_AGENT']; Also you can use that in conjunction with get_browser(). Read here http://www.php.net/manual/en/function.get-browser.php Ray
  16. Help US help you!!! Need a little more info. Do you know how to query the database?? do you know how to loop through the results and make a list?? do you know how to create forms for update?? I mean we can't build the site for you here so some you will have to create. Where are you stuck?? Ray
  17. Looking at your code you have just assigned the value from the GET to the variable $ID. You have not echoed $ID. Also I am assuming you are actually getting the ID from the database. May want to echo $row['ID'] to make sure. <?php $ID = 0; if (isset($_GET['ID'])) { $ID = $_GET['ID']; } ?> <?php echo $ID; echo $_GET['price']; // outputs: 1 ?>
  18. I am using a script from another developer. I have it working great in FireFox and Chrome, but will not work with IE9. I have a from which pops up using another javascript, the form takes the file name and a short description of the file So i can store the description and the filename in a database table(just the name not the image). I am also using codeigniter so lookout for the functions Here is the form page <script src="https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js"></script> <script type="text/javascript" src="http://192.168.20.13/wquality/assets/scripts/fileup.js"></script> <script> window.addEvent('domready', function(){ $("filesubmit").addEvent('click', function(){ var upload = new File.Upload({ url: '/wquality/wq/do_upload', data: { CALLID: $('CALLID').value, DESC: $('DESC').value }, images: ['userfile'], onComplete: function(response) { $('loading').setStyle('display','none'); if(response == 'OK') { document.getElementById('fileUpload').reset(); $('fstatus').set('html', '<div >File Uploaded!</div>'); } else { $('fstatus').set('html', '<div >'+response+'</div>'); } } }); upload.send(); }); }); </script> <div class="sample_popup" id="lab_list" /> <div class="lab_list_header" /> <a href="#" onClick="hide_lab('lab_list');" /><img class="menu_form_exit" src="<?=base_url()?>assets/img/form_exit.png" alt="exit" border="0" /></a> File Upload </div> <div style="width:300px;margin:0 auto 0 auto;" /> <div id="fstatus"></div> <?php echo form_open_multipart(base_url()."wq/do_upload", array("class" => "", "name" => "fileUpload", "id" => "fileUpload")).' <input type="hidden" name="CALLID" value="'.$cid.'" id="CALLID" /> <p>Name '.form_input(array("name" => "DESC", "id" => "DESC")).'</p> <p style="margin-left: 48px;" >'.form_upload(array("name" => "userfile", "id" => "userfile")).'</p> <p style="margin-left: 48px;" >'.form_button(array("name" => "btn", "value" => "true", "id" => "filesubmit", "content" => "Upload File")).'</p> '.form_close(); //<p style="margin-left: 48px;" >'.form_submit(array("value" => "Upload File", "id" => "filesubmit")).'</p> //<p style="margin-left: 48px;" >'.form_button(array("name" => "btn", "value" => "true", "id" => "filesubmit", "content" => "Upload File")).'</p> ?> <div id="loading" style="display: none;" ><img align="absmiddle" src="http://192.168.20.13/wquality/assets/img/spinner.gif"> Processing...</div> </div> </div> Here is the js file File.Upload = new Class({ Implements: [Options, Events], options: { onComplete: function(){} }, initialize: function(options){ var self = this; this.setOptions(options); this.uploadReq = new Request.File({ onComplete: function(){ self.fireEvent('complete', arguments); this.reset(); } }); if(this.options.data) this.data(this.options.data); if(this.options.images) this.addMultiple(this.options.images); }, data: function(data){ var self = this; if(this.options.url.indexOf('?') < 0) this.options.url += '?'; Object.each(data, function(value, key){ if(self.options.url.charAt(self.options.url.length - 1) != '?') self.options.url += '&'; self.options.url += encodeURIComponent(key) + '=' + encodeURIComponent(value); }); }, addMultiple: function(inputs){ var self = this; inputs.each(function(input){ self.add(input); }); }, add: function(input){ var input = document.id(input), name = input.get('name'), file = input.files[0]; this.uploadReq.append(name, file); }, send: function(input){ if(input) this.add(input); this.uploadReq.send({ url: this.options.url }); } }); Request.File = new Class({ Extends: Request, options: { emulation: false, urlEncoded: false }, initialize: function(options){ this.xhr = new Browser.Request(); this.formData = new FormData(); this.setOptions(options); this.headers = this.options.headers; }, append: function(key, value){ this.formData.append(key, value); return this.formData; }, reset: function(){ this.formData = new FormData(); }, send: function(options){ var url = options.url || this.options.url; this.options.isSuccess = this.options.isSuccess || this.isSuccess; this.running = true; var xhr = this.xhr; xhr.open('POST', url, true); xhr.onreadystatechange = this.onStateChange.bind(this); Object.each(this.headers, function(value, key){ try{ xhr.setRequestHeader(key, value); }catch(e){ this.fireEvent('exception', [key, value]); } }, this); this.fireEvent('request'); xhr.send(this.formData); if(!this.options.async) this.onStateChange(); if(this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this); return this; } }); The error I get in IE 9 is this When I first load the page I get a 'File' is undefined error. This points to the first line, "File.Upload = new Class({". The second error comes, probably because of the first. On the line "var upload = new File.Upload({" on the form page. I am a novice Javascript person so sorry if this may be a minor error. I did not include the page to upload the image because that works fine. I am just starting my Javascript/Ajax studies so please excuse my novice skills. Thanks for the help Ray
  19. You will not be able to do it with a single query. Multiple rows can only be updated if you are applying the same value to a particular column. You will have to use a loop to update rows independently. Ray
  20. can use this <?php $complete = array("Horse", "Dog", "Cat", "Elephant"); $partial = array("Cat", "Elephant", "Dog"); foreach ($complete as $item){ if(in_array($item, $partial)){ echo $item." x<br>"; } else { echo $item."<br>"; } } ?> Ray
  21. You should try Barands Baaselect. It creates linked select boxes using ajax. can find it here http://www.phpclasses.org/package/1637-PHP-Generate-dynamically-linked-select-inputs.html may need to sign up to download it but it is free and the site has alot of classes.
  22. I have a page which searches a database. on the page you can select the fields you would like to see and then there is a section where you can add search keywords. I have 1 ajax script which uses chained select boxes. the first box shows the available fields in the table to search with then depending on the selection it will show another select box if that field has only certain values you can use or just a text input to put what you like in. this works fine on it's own. I also want the option to click a button and add another set of search boxes so the user may search on more than one field. This also works fine, when you click the button another select box will fade in. The problem I have is when I use the script to add another select line the script to chain the select boxes breaks and it will not show the second select box. I have attached screen shots. I am using codeigniter I have not gotten the Ajax module down yet so I am just working with the javascripts and ajax files independently. han_assets.php this is main page. pretty just echoing basic html code for the area. <tr> <td> <div id="form_data"> <!-- the form fields will be loaded here via ajax --> </div> <div> <span id="loading"></span> <input type="button" id="add_item" value="Add Search Field"> </div> </td> </tr> here is the ajax call <script type="text/javascript"> var $j = jQuery.noConflict(); $j(document).ready(function() { $j('#wait_1').hide(); $j('#drop_1').change(function(){ $j('#wait_1').show(); $j('#result_1').hide(); $j.get("/reports/func.php", { func: "drop_1", drop_var: $j('#drop_1').val() }, function(response){ $j('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { var $j = jQuery.noConflict(); $j('#wait_1').hide(); $j('#'+id).html(unescape(response)); $j('#'+id).fadeIn(); } </script> func.php <?php //************************************** // Page load dropdown results // //************************************** function getTierOne($table) { $ret = ''; $array = s_arrays($table); foreach($array as $key => $val){ $ret .= '<option value="'.$key.'">'.$val."</option>\n"; } return $ret; } //************************************** // First selection results // //************************************** if(@$_GET['func'] == "drop_1" && isset($_GET['func'])) { drop_1($_GET['drop_var']); } function drop_1($drop_var, $i=0) { $text_fields = array("UNITID", "ADDRQUAL", "ADDRESS", "MAPNO", "INSTDATE", "STATPRES", "STATDATE", "RETIRED", "PIPELEN", "DIAM", "MISCDESC", "RETDDATE", "VALVESZ", "NOTURNS" ); $stype = array("LIKE" => "LIKE", "=" => "=", "!=" => "!=", "NOT LIKE" => "NOT LIKE", "IS NULL" => "IS NULL"); $array = s_arrays($drop_var); echo '<select name="keyword['.$i.'][op]" id="tier_">'; foreach($stype as $k => $v){ echo '<option value="'.$k.'">'.$v.'</option>'; } echo '</select>'; if(empty($array)){ echo ' <input type="text" name="keyword['.$i.'][value] id="tier_two">'; } else { echo '<select name="keyword['.$i.'][value]" id="tier_two"> <option value=" " disabled="disabled" selected="selected">Choose one</option>'; foreach($array as $key => $val){ echo '<option value="'.$key.'">'.$val.'</option>'; } echo '</select> '; } } function s_arrays($array) { $text_fields = array("UNITID", "ADDRQUAL", "ADDRESS", "MAPNO", "INSTDATE", "STATPRES", "STATDATE", "RETIRED", "PIPELEN", "DIAM", "MISCDESC", "RETDDATE", "VALVESZ", "NOTURNS" ); $cont = 1; foreach($text_fields as $f){ if(strstr($array, $f)){ $ret = "noarray"; $cont = 0; } } if($cont == 1){ if(strpos($array, ".")){ $ret = str_replace(".", "_", $array); } else { $ret = $array; } } $noarray = ''; $oper = array("LIKE" => "LIKE", "=" => "=", "!=" => "!=", "NOT LIKE" => "NOT LIKE", "IS NULL" => "IS NULL"); $COMPHY_SERVSTAT = array("I" => "In Service", "O" => "Out of Service", "CNU" => "Closed Non Use", "N" => "New Install", "T" => "Temp Out of Service"); $COMPHY_AREA = array("CRAN" => "Cranston", "NPROV" => "North Providence", "PROV" => "Providence", "JOHN" => "Johnston", "SCIT" => "Scituate", "WESTCRAN" => "Western Cranston"); $COMPHY_LOC = array("CR" => "Cranston", "JO" => "Johnston", "LI" => "Lincoln", "NP" => "North Providence", "PR" => "Providence", "SC" => "Scituate"); $COMPHY_UNITTYPE = array("BR" => "Breakaway", "P" => "Post"); $COMPWMN_SERVSTAT = array("I" => "In Service", "O" => "Out of Service", "CNU" => "Closed Non Use", "N" => "New Install", "T" => "Temp Out of Service"); $COMPWMN_AREA = array("CRAN" => "Cranston", "NPROV" => "North Providence", "PROV" => "Providence", "JOHN" => "Johnston", "SCIT" => "Scituate", "WESTCRAN" => "Western Cranston"); $COMPWMN_LOC = array("CR" => "Cranston", "JO" => "Johnston", "LI" => "Lincoln", "NP" => "North Providence", "PR" => "Providence", "SC" => "Scituate"); $COMPWMN_PIPETYPE = array("AC" => "Asbestos Cement", "CI" => "Cast Iron", "CIR" => "Cast Iron Relined", "DI" => "Ductile Iron", "PC" => "PreStressed Concrete", "ST" => "Steel", "UN" => "Unknown"); $COMPWMS_SERVSTAT = array("I" => "In Service", "O" => "Out of Service", "CNU" => "Closed Non Use", "N" => "New Install", "T" => "Temp Out of Service"); $COMPWMS_AREA = array("CRAN" => "Cranston", "NPROV" => "North Providence", "PROV" => "Providence", "JOHN" => "Johnston", "SCIT" => "Scituate", "WESTCRAN" => "Western Cranston"); $COMPWMS_LOC = array("CR" => "Cranston", "JO" => "Johnston", "LI" => "Lincoln", "NP" => "North Providence", "PR" => "Providence", "SC" => "Scituate"); $COMPWMS_UNITTYPE = array("AIR" => "Air Release", "BLEED" => "Bleeder", "BLOFF" => "Blow Off", "SPH" => "Sprinkler Hydrant"); $COMPWSL_SERVSTAT = array("I" => "In Service", "O" => "Out of Service", "CNU" => "Closed Non Use", "N" => "New Install", "T" => "Temp Out of Service"); $COMPWSL_AREA = array("CRAN" => "Cranston", "NPROV" => "North Providence", "PROV" => "Providence", "JOHN" => "Johnston", "SCIT" => "Scituate", "WESTCRAN" => "Western Cranston"); $COMPWSL_LOC = array("CR" => "Cranston", "JO" => "Johnston", "LI" => "Lincoln", "NP" => "North Providence", "PR" => "Providence", "SC" => "Scituate"); $COMPWSL_SERVTYPE = array("COM" => "Commercial", "P" => "Public", "R" => "Residential", "SAMP" => "Sampling Station", "WHOL" => "Wholesale"); $COMPWSL_PIPETYPE = array("COPPER" => "Copper", "LEAD" => "Lead", "AC" => "Asbestos Cement", "CI" => "Cast Iron", "DI" => "Ductile Iron"); $COMPWSL_LINETYPE = array("COMB" => "Combination", "DOM" => "Domestic", "FS" => "Fire Service", "SFS" => "Special Fire Service", "WHOLE" => "Wholesale"); $COMPWV_SERVSTAT = array("I" => "In Service", "O" => "Out of Service", "CNU" => "Closed Non Use", "N" => "New Install", "T" => "Temp Out of Service"); $COMPWV_AREA = array("CRAN" => "Cranston", "NPROV" => "North Providence", "PROV" => "Providence", "JOHN" => "Johnston", "SCIT" => "Scituate", "WESTCRAN" => "Western Cranston"); $COMPWV_LOC = array("CR" => "Cranston", "JO" => "Johnston", "LI" => "Lincoln", "NP" => "North Providence", "PR" => "Providence", "SC" => "Scituate"); $COMPWV_UNITTYPE = array("B" => "Butterfly", "CHV" => "Check Valve", "GV" => "Gate Valve", "H" => "Horizontal", "PRV" => "Pressure Reducing", "TSV" => "Tapping Sleeve & Valve", "V" => "Vertical", "X" => "Bypass on Divisional"); $COMPWV_VALVESTAT = array("O" => "Open", "C" => "Closed", "P" => "Partially Opened"); $COMPHY = get_fields("COMPHY"); $COMPWMN = get_fields("COMPWMN"); $COMPWMS = get_fields("COMPWMS"); $COMPWSL = get_fields("COMPWSL"); $COMPWV = get_fields("COMPWV"); return $$ret; } function get_fields($table) { $fields = array("$table.UNITID" => "Unit ID", "$table.ADDRQUAL" => "Qualifier", "(ADDRESS.STNO || ' ' || ADDRESS.STNAME || ' ' || ADDRESS.SUFFIX) AS ADDRESS" => "Address", "$table.AREA" => "Area", "$table.LOC" => "Loc", "$table.MAPNO" => "Map#", "$table.INSTDATE" => "Install Date", "$table.SERVSTAT" => "Status"); switch($table) { case "COMPHY": $fields[$table.'.UNITTYPE'] = "Hydrant Type"; $fields['VARHY.STATPRES'] = "Static Pressure"; $fields['VARHY.STATDATE'] = "Static Date"; $fields['VARHY.RETIRED'] = "Retired Date"; break; case "COMPWMN": $fields['COMPTYPE.COMPCODE COMP1'] = "Comp Type"; $fields[$table.'.UNITID2'] = "Unit ID 2"; $fields['COMPTYPE2.COMPCODE COMP2'] = "Comp Type 2"; $fields[$table.'.UNITTYPE'] = "Main Type"; $fields[$table.'.PIPELEN'] = "Pipe Length"; $fields[$table.'.PIPETYPE'] = "Pipe Type"; $fields['VARWMN.RETIRED'] = "Retired Date"; break; case "COMPWMS": $fields[$table.'.UNITTYPE'] = "Misc Type"; $fields[$table.'.MISCDESC'] = "Description"; $fields[$table.'.DIAM'] = "Diameter"; break; case "COMPWSL": $fields[$table.'.UNITTYPE'] = "Service Type"; $fields[$table.'.PIPELEN'] = "Length of Service"; $fields[$table.'.PIPETYPE'] = "Pipe Type"; $fields[$table.'.DIAM'] = "Diameter"; $fields['VARWSL.RETDDATE'] = "Retired Date"; break; case "COMPWV": $fields[$table.'.UNITTYPE'] = "Valve Type"; $fields[$table.'.VALVESZ'] = "Valve Size"; $fields[$table.'.VALVESTAT'] = "Valve Position"; $fields[$table.'.NOTURNS'] = "# Turns"; $fields['VARWV.RETIRED'] = "Retired Date"; } return $fields; } ?> and here is the ajax call to add the select box: addfield.js window.addEvent('domready', function() { var counter=0; function new_rows(){ counter=counter+1; var myHTMLRequest = new Request({ url:'/reports/load.ajax.php', method:'get', autoCancel:true, data: {'type':'item','field_name':'add',num:counter}, onRequest: function() { $('loading').set('html','<img src=\"images/ajax-loader.gif\">'); }, onComplete: function(responseText) { var new_rows = new Element('div', { 'html': responseText }); // inject new fields at bottom new_rows.inject($('form_data'),'bottom'); // remove loading image $('loading').set('text',''); // scroll down to new form fields var myFx = new Fx.Scroll(window).toElement('table_'+counter); } }).send(); } $('add_item').addEvent('click', function(e){ e.stop(); // stop the default submission of the form new_rows(); }); //load first set of rows - all rows are loaded via ajax new_rows(); }); Hope I explained it correctly Thanks Ray [attachment deleted by admin]
  23. why not check the HTTP_HOST then set the session variable accordingly. <?php if($_SERVER['HTTP_HOST'] != "www.domain.com"){ $_SESSION['Var'] = 1; } else { $_SESSION['Var'] = 0; } ?> I am not sure what you code is like but something like above should work. Ray
  24. $sql = "SELECT COUNT(`OWNER`) AS `o_count`, `OWNER`, `Title`, `POST` FROM `tablename` GROUP BY `OWNER` ORDER BY `o_count` DESC LIMIT 10"; Think that should do it, not tested though 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.