Jump to content

nita

Members
  • Posts

    86
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

nita's Achievements

Member

Member (2/5)

0

Reputation

  1. Have basic article directory and i'm busy with pagination. And i want to have it shortlinked. Structure of the link looks like this: Without pagination <a href='moving-articles/category/$sublink/'>$sublink</a> rewrite rule in .htaccess look like this RewriteRule moving-articles/(.*)/(.*)/$ /moving-articles.php?$1=$2 That works perfectly fine. So the problem i have here, one i try to add pagination. Link structure is like this for example: <a href='moving-articles/category/$sublink/page/2/'>2</a> rewrite rule in .htaccess: RewriteRule moving-articles/(.*)/(.*)/(.*)/(.*)/$ /moving-articles.php?$1=$2&$3=$4 And piece of php code responsible for calling variables: if(isset($_GET['category']) && isset($_GET['page'])) { $sublink=$_GET['category']; $page=$_GET['page']; ..... } What do i do wrong here? Thanks for your help in advance!
  2. improved version: <? include "connectdb.php"; $driver = 5; $datestamp = '2013/05/07'; $result2 = mysql_query("SELECT * FROM drivers WHERE id='$driver' LIMIT 1") or die(mysql_error()); while($row2 = mysql_fetch_array( $result2 )) { $garage_lon=$row2['lon']; $garage_lat=$row2['lat']; } $result = mysql_query("SELECT * FROM quotedb WHERE moveday='$datestamp' AND driver='$driver' AND cleared='Not Cleared' AND status='Done' ORDER BY moveday, timeday") or die(mysql_error()); function calculate_distance($lon1, $lat1, $lon2, $lat2) { return (3958 * 3.1415926 * sqrt(($lat2 - $lat1) * ($lat2 - $lat1) + cos($lat2 / 57.29578) * cos($lat1 / 57.29578) * ($lon2 - $lon1) * ($lon2 - $lon1)) / 180);} $previous_lon = $garage_lon; $previous_lat = $garage_lat; $distance = 0; // accumulate the distance while($row = mysql_fetch_assoc( $result )) { $lon1 = $row['lon1']; $lat1 = $row['lat1']; $lon2 = $row['lon2']; $lat2 = $row['lat2']; if ( $previous_lon && $previous_lat ) { // calculate the distance from the Garage to the first point of the first row $distance += calculate_distance($lon1, $lat1, $previous_lon, $previous_lat); } // calculate the distance for each row (segment) in the route $distance += calculate_distance($lon1, $lat1, $lon2, $lat2); $previous_lon = $lon2; $previous_lat = $lat2; } // calculate the distance from the second point of the last row to the Garage $distance += calculate_distance($garage_lon, $garage_lat, $lon2, $lat2); $distance = round($distance,0); echo "$distance<br> "; ?>
  3. Ok. I worked it out. All calculations are done as i wish. My code below: <? include "connectdb.php"; $driver = 5; $datestamp = '2013/05/07'; $result2 = mysql_query("SELECT * FROM drivers WHERE id='$driver' LIMIT 1") or die(mysql_error()); while($row2 = mysql_fetch_array( $result2 )) { $lon=$row2['lon']; $lat=$row2['lat']; } $result = mysql_query("SELECT * FROM quotedb WHERE moveday='$datestamp' AND driver='$driver' AND cleared='Not Cleared' AND status='Done' ORDER BY moveday, timeday") or die(mysql_error()); $distance = 0; // accumulate the distance $first_pass = true; // flag to detect the first row inside the loop while($row = mysql_fetch_assoc( $result )) { $lon2a=$lon2; $lat2a=$lat2; $lon1=$row['lon1']; $lat1=$row['lat1']; $lon2=$row['lon2']; $lat2=$row['lat2']; // calculate the distance from the Garage to the first point of the first row if($first_pass){ $distance += (3958*3.1415926*sqrt(($lat-$lat1)*($lat-$lat1) + cos($lat/57.29578)*cos($lat1/57.29578)*($lon-$lon1)*($lon-$lon1))/180); $first_pass = false; } // calculate the distance for each row (segment) in the route $distance += (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180); if ( $lon2a == "" or $lat2a =="" ) { } else { // calculate the distance from the second point of the first row to the first point of the next row $distance += (3958*3.1415926*sqrt(($lat2a-$lat1)*($lat2a-$lat1) + cos($lat2a/57.29578)*cos($lat1/57.29578)*($lon2a-$lon1)*($lon2a-$lon1))/180); } } // calculate the distance from the second point of the last row to the Garage $distance += (3958*3.1415926*sqrt(($lat2-$lat)*($lat2-$lat) + cos($lat2/57.29578)*cos($lat/57.29578)*($lon2-$lon)*($lon2-$lon))/180); echo "$distance<br> "; ?> Don't get me wrong, but i think it can be done more proffesional way.. that is what i try to achive .. and still have a lot to learn - i realize that. Do you guys have some suggestion to improve this piece of code ..(will aplay Haversine method for calculations). THX
  4. guess you right, working on it, manual (on paper thats easy) - missing logic in my code ...
  5. There is proggres. Code calculates distance beetween garage and starting point of 1st location. Then calculates well distances between starting points and finishing points of locations. Also calculate well distance between dinishing point of the last location and garage. What im missing is: distances between finishig pont of 1st location and starting point of 2nd location and so on ... (Garage + D1) + (D1 + D2) + (D2 + E1) + (E1 + E2) + E2 + Garage)
  6. how do i aplay: $distance += calc_distance($lat1,$lon1,$lat2,$lon2); should i use function: function calc_distance ($lat1, $lon1, $lat2, $lon2) { return (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180); } but then what about $distance += calc_distance($lat2,$lon2,$lat,$lon); the variables are different ????
  7. i will aplay other calculation method for sure. My problem here at the moment is to que up calculations. Thank for a tip.
  8. Came up with following code: <? include "connectdb.php"; $driver = 5; $datestamp = '2013/05/07'; $result2 = mysql_query("SELECT * FROM drivers WHERE id='$driver' LIMIT 1") or die(mysql_error()); while($row2 = mysql_fetch_array( $result2 )) { $lon=$row2['lon']; $lat=$row2['lat']; } ?> <? $distance = 0; // accumulate the distance $result = mysql_query("SELECT * FROM quotedb WHERE moveday='$datestamp' AND driver='$driver' AND cleared='Not Cleared' AND status='Done' ORDER BY moveday, timeday") or die(mysql_error()); while($row = mysql_fetch_assoc( $result )) { $first_pass = true; // flag to detect the first row inside the loop $lon1=$row['lon1']; $lat1=$row['lat1']; $lon2=$row['lon2']; $lat2=$row['lat2']; echo "$lon, $lat<br>$lon1, $lat1, $lon2, $lat2<br>"; // calculate the distance from the Garage to the first point of the first row if($first_pass){ $distance += (3958*3.1415926*sqrt(($lat-$lat1)*($lat-$lat1) + cos($lat/57.29578)*cos($lat1/57.29578)*($lon-$lon1)*($lon-$lon1))/180); $first_pass = false; } // calculate the distance for each row (segment) in the route $distance += (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180); } // calculate the distance from the second point of the last row to the Garage $distance += (3958*3.1415926*sqrt(($lat2-$lat)*($lat2-$lat) + cos($lat2/57.29578)*cos($lat/57.29578)*($lon2-$lon)*($lon2-$lon))/180); echo "$distance"; ?>
  9. I would like to calculate the total distance of driving beetween multiple locations (loop), including the distance (starting point (garage) - first location sarting point) and (last location finishig point - finishing point (garage)). Example: (Garage + D1) + (D1 + D2) + (D2 + E1) + (E1 + E2) + E2 + Garage) I'm having a problem with the correct looping. Here's my simplified code: <? $driver = 5; $result2 = mysql_query("SELECT * FROM test WHERE id='$driver' LIMIT 1") or die(mysql_error()); while($row2 = mysql_fetch_array( $result2 )) { $lon=$row2['lon']; $lat=$row2['lat']; echo "$lon, $lat"; } $result = mysql_query("SELECT * FROM test1 WHERE driver='$driver'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $lon1=$row['lon1']; $lat1=$row['lat1']; $lon2=$row['lon2']; $lat2=$row['lat2']; ////////// distance between driver address and starting address $distancecalc = (3958*3.1415926*sqrt(($lat-$lat1)*($lat-$lat1) + cos($lat/57.29578)*cos($lat1/57.29578)*($lon-$lon1)*($lon-$lon1))/180); ////////// distance between statring address and finishing address - multiple adsresses $distancecalc1 = $distancecalc1 + (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180); ////////// distance between finishing address and driver address $distancecalc2 = (3958*3.1415926*sqrt(($lat2-$lat)*($lat2-$lat) + cos($lat2/57.29578)*cos($lat/57.29578)*($lon2-$lon)*($lon2-$lon))/180); $distancetotal = $distancecalc + $distancecalc1 +$distancecalc2; echo "$distancecalc<br> $distancecalc1<br> $distancecalc2<br>"; } echo "$distancetotal"; ?> I'm aware that code posted above doesnt't do what it meant to .. i just want to keep it clear.. there is some things i tried but no correct resoults. I would appreciate some help on this one. Thank you very much.
  10. function validateForm(){ var inputs = document.getElementsByTagName('input'); var noneZeroFound = false; for(var i=0;i< inputs.length;i++){ var input = inputs[i]; if(input.value != '0'){ noneZeroFound = true; break; } } if(!noneZeroFound ){ alert('MUST ENTER VALUE...'); return false; } return true; } <form name='packaging' action="packaging.php" method='post' onSubmit="return validateForm()"> Found the solution on another forum.
  11. Hi Everyone. I'm working on a basic ordering form. What i'm trying to achive is to get javascript to return alert when all the inputs fields are with values 0. At least 1 of the inputs has to be filled in with value more then 0 in order to proceed with a ordering form. I have to mention that products list / input fields are generated dynamicly so their number might vary. Basic code: <form name='packaging' action="packaging.php" method='post'> <? $result = mysql_query("SELECT * FROM packaging_items") or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo " <input type='text' style='width:20px' name='$row[prodno]' id='$row[prodno]' maxlength='4' value="0" onblur="if (this.value == '') {this.value = '0';}" onfocus="if (this.value == '0') {this.value = '';}" onkeypress='validate(event)' > "; } ?> </form> Any suggetions .. i really have no clue where to start ... Thank you in advance
  12. Certainly will take your advice in mind, will look into JOIN mysql, could you give me some link with basic example that i can look into and learn, that is what i need ! Thank you
  13. got it fixed ... $result1=mysql_query("SELECT ".$data1." as data1 FROM packaging WHERE orderno='$orderno' LIMIT 1") or die(mysql_error()); while($row1 = mysql_fetch_array( $result1 )) { $data = $row1['data1']; if ( $data == '' ) {} else { echo" <tr><td>$name</td><td>$data</td><td>£$price</td><tr>"; } }
  14. for example when i hardcode the query, results are ok and that is what i want to achive here $result1=mysql_query("SELECT pack01 FROM packaging WHERE orderno='$orderno' LIMIT 1") or die(mysql_error()); while($row1 = mysql_fetch_array( $result1 )) { $pack01 = $row1['pack01']; echo "$pack01"; }
×
×
  • 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.