Jump to content

marksie1988

Members
  • Posts

    225
  • Joined

  • Last visited

About marksie1988

  • Birthday 01/10/1988

Contact Methods

  • Website URL
    http://hyenaandmonkey.com

Profile Information

  • Gender
    Male
  • Location
    Leeds, UK

marksie1988's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Is no one able to assist with this? Im really struggling to get it working. Or if you can point me in the direction of a similar method to create a dropdown menu that will mark the parent as active when using a sub menu that would be great.
  2. Hi Guys, I have the below code that I am trying to make work correctly, basically it creates a menu structure and then should only make the parent active if the page you are on belongs to that parent. at the moment the structure is wrong as it is adding too many <ul> entries for each menu. this is what it currently does: <ul id="nav"> <li class="active"><a href="admin.php">System Settings</a> <ul id="nav"> <li><a href="reports.php">Reports</a></il> </ul> <ul id="nav"> <li><a href="memblst.php?opt=createuser">Create User</a></il> </ul> </li> </ul> This is what it should be: <ul id="nav"> <li class="active"><a href="admin.php">System Settings</a> <ul> <li><a href="reports.php">Reports</a></il> <li><a href="memblst.php?opt=createuser">Create User</a></il> </ul> </li> </ul> $MENU["SYSTEMS"] = array ( 'parent'=>true, 'enabled'=>true, 'text'=>'System Settings', 'link'=> 'admin.php', 'sub_modules' => array('REPORTS','CREATE_USER') ); $MENU["REPORTS"] = array ( 'parent'=>FALSE, 'enabled'=>true, 'text'=>'Reports', 'link'=> 'reports.php', 'sub_modules' => array() ); $MENU["CREATE_USER"] = array ( 'parent'=>FALSE, 'enabled'=>true, 'text'=>'Create User', 'link'=> 'memblst.php?opt=createuser', 'sub_modules' => array() ); $MENU["MEMBER_LST"] = array ( 'parent'=>FALSE, 'enabled'=>true, 'text'=>'Member List', 'link'=> 'memberlst.php', 'sub_modules' => array() ); $MENU["SYSTEM_LOGS"] = array ( 'parent'=>FALSE, 'enabled'=>true, 'text'=>'System Logs', 'link'=> 'syslog.php', 'sub_modules' => array() ); function show_menu(&$MENU,$subIndex=false){ $menu_string = ''; $menu_string .= '<ul id="nav">'; if(!$subIndex){ foreach($MENU as $item) { if( $item['enabled']&&$item['parent'] ) { $_subString=""; if(!empty($item['sub_modules'])){ foreach($item['sub_modules'] as $sub){ $_subString .= show_menu($MENU,$sub); } } $menu_string .= '<li class="active"><a href="'.$item['link'].'">'.$item['text'].'</a>'.$_subString.'</li>'; } } }else{ if(@$MENU[$subIndex]['enabled']&&!@$MENU[$subIndex]['parent']) { $_subString=""; if(!empty($MENU[$subIndex]['sub_modules'])){ foreach($MENU[$subIndex]['sub_modules'] as $sub){ $_subString .= show_menu($MENU,$sub); } } $menu_string .= '<li><a href="'.$MENU[$subIndex]['link'].'">'.$MENU[$subIndex]['text'].'</a></il>'.$_subString; } } return $menu_string.'</ul>'; } echo show_menu($MENU);
  3. Hi Guys, I have been working on a recursive select box that will allow sub-categories and keep getting the error: <b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>test.php</b> on line <b>22</b><br / i have a table as follows: CREATE TABLE IF NOT EXISTS `ost_help_topic` ( `topic_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `isactive` tinyint(1) unsigned NOT NULL DEFAULT '1', `noautoresp` tinyint(3) unsigned NOT NULL DEFAULT '0', `priority_id` tinyint(3) unsigned NOT NULL DEFAULT '0', `dept_id` tinyint(3) unsigned NOT NULL DEFAULT '0', `CatParent` bigint(11) unsigned DEFAULT NULL, `topic` varchar(32) NOT NULL DEFAULT '', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`topic_id`), UNIQUE KEY `topic` (`topic`), KEY `priority_id` (`priority_id`), KEY `dept_id` (`dept_id`) ) <?php $db_host = "localhost"; $db_un = "user"; $db_pass = "pass"; $Item_DB = "data"; $table = "ost_help_topic"; $link = mysql_connect($db_host, $db_un, $db_pass); $tab = " "; // this is 8 spaces, which works as a pseudo-tab character inside the <option>s $tablvl = 1; function print_kids($pos) { // $pos is the current position inside the hierarchy (curr item's ID) global $link; global $tab; global $tablvl; $pos = ($pos?$pos:null); $query = "SELECT * from $table WHERE isactive=1 AND CatParent".($pos == null ? " IS NULL" : "=".$pos); // NULL parent == top level item. For 0-parents, replace " IS NULL" with "=0" $res = mysql_db_query($Item_DB, $query, $link); if (!$res) print(mysql_error()); while($row = mysql_fetch_array($res)) { $has_kids = mysql_fetch_array(mysql_db_query($Item_DB, "SELECT * from $table where isactive=1 AND CatParent=$row[0]", $link)) != null; print("<option value=\"$row[0]\">"); for ($i=0; $i<$tablvl; $i++) print($tab); print("$row[6]</option>\n"); if ($has_kids) { $tablvl++; print_kids($row[0]); // <span class="posthilit">recursive</span> call $tablvl--; } } } $numrows = 1; $res = mysql_db_query($Item_DB, "SELECT * FROM $table", $link); while (mysql_fetch_array($res)) $numrows++; // Yes, I'm sure there's a more efficient way to do this <img src="./images/smilies/icon_razz.gif" alt="" title="Razz" /> print("<select name=\"hierarchy\" size=\"$numrows\">\n"); print("<option value=\"null\" selected=\"selected\">Root of all items</option>\n"); print_kids(0); print("</select>"); mysql_close($link); ?>
  4. Hi Guys, i have got a script that gets directions from point a to point b etc, i need to also output the distance of the journey which will populate a div further down the page below is my code but i dont know why i cant get the distance to show in the div. function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("svmap_canvas"),{mapTypes:[G_NORMAL_MAP]}); gdir = new GDirections(map, document.getElementById("svmap_directions")); var mapControl = new GMapTypeControl(); map.addControl(mapControl);map.addControl(new GSmallMapControl());map.enableDoubleClickZoom();map.enableScrollWheelZoom();var geocoder = new GClientGeocoder(); var myIcon = new GIcon(); myIcon.image = "http://labs.google.com/ridefinder/images/mm_20_orange.png"; myIcon.iconAnchor = new GPoint((markerImage1.width/2),markerImage1.height); markerOptions = { icon:myIcon, draggable: false, "title":"Drax Solutions LLP" }; var point1 = new GLatLng(53.7726417, -1.7056978); map.setCenter(point1, 10); var marker1 = new GMarker(point1, markerOptions); map.addOverlay(marker1); var distance = gdir.getDistance(); document.getElementById("roundmiles").innerHTML = distance; } }
  5. Hi Guys, i have the below script which works out the driving distance between 2 points i am not great with JS and the google API and cant figure this out! how do I create a poly line on the route that the 2 points has taken? i cant figure out how to get it to display on a map that i put in my html var geocoder, location1, location2, gDir; function initialize() { geocoder = new GClientGeocoder(); gDir = new GDirections(); GEvent.addListener(gDir, "load", function() { var drivingDistanceMiles = (gDir.getDistance().meters / 1609.344).toFixed(1); var drivingDistanceKilometers = gDir.getDistance().meters / 1000; document.getElementById('results').innerHTML = '<strong>Address 1: </strong>' + location1.address + ' (' + location1.lat + ':' + location1.lon + ')<br /><strong>Address 2: </strong>' + location2.address + ' (' + location2.lat + ':' + location2.lon + ')<br /><strong>Driving Distance: </strong>' + drivingDistanceMiles + ' miles (or ' + drivingDistanceKilometers + ' kilometers)'; document.getElementById('miles').value = drivingDistanceMiles * 2; }); } function showLocation() { geocoder.getLocations(document.forms[0].address1.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode the first address"); } else { location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; geocoder.getLocations(document.forms[0].address2.value, function (response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode the second address"); } else { location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address}; gDir.load('from: ' + location1.address + ' to: ' + location2.address); } }); } }); } the html i currently have is: <h2>Calculate Distance</h2> <center> <form action="#" onsubmit="showLocation(); return false;"> <table class="grid_table"> <tr class="grid_row_even"> <td class="grid_cell">From Address: </td><td class="grid_cell"><input type="text" name="address1" class="address_input" size="40" /></td> </tr> <tr class="grid_row_even"> <td class="grid_cell">To Address:</td><td class="grid_cell"> <input type="text" name="address2" class="address_input" size="40" /></td> </tr> </table> <input type="submit" name="find" value="Search" /> </p> </form> <p id="results"></p> </center>
  6. Ok that makes sense, but how would i ensure that each file was the latest version? Would you sugest that i have a DB with each version of each file and if this all matches then they are on the latest version (this would save changing the version in files that havent been changed) then i could have a line in the table for the main version and if the main version changes they must do a full update :S
  7. Hi Guys, Sorry if this is the wrong forum but i wasnt sure the best one. i am trying to see how others control the version of apps they have written and updating. i want to set the version of my app e.g. 1.0 and then have a section where if i release 1.5 it will show up that a new version is available for upgrade. the only thing im not too sure about is when someone goes to upgrade if not all of the updated files are uploaded correctly i want it to say version missmatch. could someone give me examples of how i could achieve this?
  8. Hiu Guys, having a bit ov an issue with this havent had to do anything like this before but here goes below you will see my php code which calls all of the tickets from hd_ticket and then explodes the email address to get the domain.com once it has this i need to select the domain.com from the hd_customers table and update the hd_ticket table company column with the information from the hd_customers table. for some reason when it runs the nested while loop it doesnt loop through all of the results it only displays one on the echo i have also put my table structure to help you out. hd_customers id email company 1 domain.com mycompany hd_tickets ticket_id ticketID dept_id priority_id topic_id staff_id email name subject helptopic phone phone_ext ip_address status source isoverdue isanswered duedate reopened closed lastmessage lastresponse created updated company $sql= 'SELECT * FROM hd_ticket '; $result = mysql_query($sql)or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ $fromco = explode("@",$row[email]); $fromco = $fromco[1]; $sql= 'SELECT * FROM hd_customer WHERE email="'.$fromco.'"' ; $result = mysql_query($sql)or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ $company = $row[company] ; $sql= 'UPDATE hd_ticket ticket SET ticket.company='.$company.''; print $sql; //mysql_query($sql); } } //}
  9. i am fairly sure that the query is wrong: INSERT INTO products SELECT * FROM tempproduct WHERE manf_part_no NOT IN (SELECT manf_part_no FROM products) AND supp_id NOT IN (SELECT supp_id FROM products) i think that it needs to be something along the lines of: INSERT INTO products SELECT * FROM tempproduct WHERE manf_part_no NOT IN (SELECT manf_part_no FROM products) AND supp_id = (SELECT supp_id FROM products) unfortunatly im not sure how to do a command like this could someone help and i think that may fix the error i get with the script
  10. this is MSSQL not MYSQL it works differently and allows you to do it like this but php doesnt seem to like this?
  11. hi i have the script below which copies data from one table to another but will only insert new data update current data or delete old data from tempproducts to products then it will delete the tempproducts from the db however i keep getting this error: Warning: mssql_query() [function.mssql-query]: Query failed in E:\UpdateProducts.php on line 33 updateproducts.php <?php include('../../otherscripts/functions.php'); $log = new Logging(); // create DB connection $host = "localhost"; $user = "user"; $pass = "pass"; $mydb = "db"; $db = mssql_connect($host,$user,$pass); //Select Database mssql_select_db($mydb); // delete all old data $sql0 = "SELECT * FROM tempproduct"; $sql1 = "INSERT INTO products SELECT * FROM tempproduct WHERE manf_part_no NOT IN (SELECT manf_part_no FROM products) AND supp_id NOT IN (SELECT supp_id FROM products)"; $sql2 = "DELETE FROM products WHERE manf_part_no NOT IN (SELECT manf_part_no FROM tempproduct) AND supp_id NOT IN (SELECT supp_id FROM tempproduct)"; $sql3 = "UPDATE p1 SET p1.avail_qty = t1.avail_qty, p1.cost_price = t1.cost_price, p1.rrp = t1.rrp, p1.date_added = t1.date_added, p1.description = t1.description FROM Products p1 INNER JOIN tempproduct t1 ON (p1.manf_part_no = t1.manf_part_no AND p1.supp_id = t1.supp_id)"; $sql4 = "TRUNCATE TABLE tempproduct"; //If tempproduct is empty done Execute Commands if it is full then execute commands $query = mssql_query($sql0) or die($log->lwrite('Failed to select for count from db')); $rowcount = mssql_num_rows($query); if($rowcount == 0){ $log->lwrite('Teh tempproduct am emptyish'); } else{ mssql_query($sql1) or die($log->lwrite('Failed to insert to db'.$sql1)); mssql_query($sql2) or die($log->lwrite('Failed to Delete from db')); mssql_query($sql3) or die($log->lwrite('Failed to Update db')); mssql_query($sql4) or die ($log->lwrite('Failed to TRUNCATE db')); } ?> if i run $sql1 command in the sql manager it runs fine and no errors occur?
  12. ok i now have an issue with the fixed script that if the csv file has a column with e.g. Dell Computer Memory\ it will think that the \ is signifying a new column so it says there the field count is incorrect on the row with the \ is there i way i can str_replace this from the csv file? when i add it to the script where the current str_replace is it doesnt work.
  13. Hi, i have a table which will hold products in it but first the products are imported to tempproducts so that i can update the products where there is a change i created the following update command but i keep getting the following error: Msg 4104, Level 16, State 1, Line 4 The multi-part identifier "dbo.tempproduct.manf_part_no" could not be bound. Msg 4104, Level 16, State 1, Line 5 The multi-part identifier "dbo.tampproduct.supp_id" could not be bound. UPDATE dbo.products SET dbo.products.avail_qty = dbo.tempproduct.avail_qty FROM dbo.products WHERE dbo.products.manf_part_no = dbo.tempproduct.manf_part_no AND dbo.products.supp_id = dbo.tampproduct.supp_id i havent been using mssql for long as i mainly use mysql so am not too sure on some things like this. help appreciated Steve
×
×
  • 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.