Jump to content

jarv

Members
  • Posts

    325
  • Joined

  • Last visited

Everything posted by jarv

  1. Lat/Long was wrong way round! THANKS!
  2. Thanks, I'm getting there now, I used the second one: while( $rs_location = $rs_locations->fetch_row() ) { $markers[] = $rs_location; } My markers are now showing, GREAT! .... but in the middle of the Indian Ocean
  3. ok, I don't get it, sorry. I am just trying to follow the example using the php array they commented out here is where I currently am: $mysqli = mysqli_connect("localhost", "root", "", "plods"); $sql_locations = "SELECT CONCAT(address1, ', ', address2) as address, Longitude, Latitude FROM southdowns"; $rs_locations = mysqli_query($mysqli, $sql_locations); while( $rs_location = $rs_locations->fetch_assoc() ) { foreach( $rs_locations->fetch_assoc() as $rs_location => $value){ $markers[] = $value; } } //while( $rs_location = $rs_locations->fetch_assoc() ) { // $markers[] = $rs_location; //} echo "<pre>".print_r($markers)."</pre>"; and it comes out like this: Array ( [0] => Nyetimber, Broughton House, 6-8 Sackville Street [1] => -0.137792 [2] => 51.509285 [3] => Baker Tilly, The Portland Building, 25 High Street.....
  4. no no, if you look at the working example on that link when you call json_encode() in the javascript it should then look like this: array( 'Westminster Abbey, London', 51.4992453, -0.1272561 ), array( 'QEII Centre, London', 51.4997296, -0.128683 )
  5. convert it to JSON and plot markers on a map, like here: http://stackoverflow.com/questions/33652498/google-map-to-display-many-markers-dynamically-using-php-and-jquery
  6. it needs to be out put like this: array( 'Palace of Westminster, London', 51.499633, -0.124755 ), array( 'Westminster Abbey, London', 51.4992453, -0.1272561 ) but I am getting: Array ( [0] => Array ( [address] => Quintessence Fragrances Ltd, Unit 2A, Hawthorne Industrial Estate [Longitude] => 0.058305 [Latitude] => 50.798006 ) [1] => Array ( [address] => Nyetimber, Broughton House, 6-8 Sackville Street [Longitude] => -0.137792 [Latitude] => 51.509285 )
  7. Thanks, that worked but now I get: Uncaught RangeError: Maximum call stack size exceeded
  8. Please help, I am trying to get data out of my database as an array but it doesn't seem to be working?! I just get: ArrayArrayArrayArrayArray here is my code <?php $mysqli = mysqli_connect("localhost", "root", "", "plods"); $sql_locations = "SELECT * FROM southdowns"; $rs_locations = mysqli_query($mysqli, $sql_locations); foreach( $rs_locations as $rs_location ) { $markers[] = array( "{$rs_location['address1']}, {$rs_location['address2']}", $rs_location['Longitude'], $rs_location['Latitude'] ); echo $markers; } ?>
  9. I would if I could find it but then the date will be wrong I think
  10. Yes it's all a bit mashed together $time variable is a date set in the database $time = $context->data->field_event_date[0]['value']; var deadline = '". date('Y-m-d', $time) ."'; initializeClock('clockdiv', deadline);", 'inline');
  11. Whichever... PHP? I just tried this but it came back as -16449 days 3 months -8 hours var deadline = '". date('Y-m-d', strtotime($time. ' + 1 days')) ."'; at the moment the countdown says: 0 days 13 hours 46 minutes 30 seconds I would like it to say: 1 days 13 hours 46 minutes 30 seconds
  12. So I am declaring deadline as a JS variable and then going into PHP var deadline = '". date('Y-m-d', $time) ."'; I just want to add an extra day onto my deadline any help here please?
  13. I am getting an error to check my values but I am using the right username, password, table name and host name. Can anyone help me here? $mysqlDatabaseName ='drupal'; $mysqlUserName ='drupal'; $mysqlPassword ='xxx'; $mysqlHostName ='localhost'; $mysqlExportPath ='content_type_vacancy.sql'; $command='mysqldump --opt -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p' .$mysqlPassword .' ' .$mysqlDatabaseName .' content_type_vacancy > ~/' .$mysqlExportPath; exec($command,$output=array(),$worked); switch($worked){ case 0: echo 'Database <b>' .$mysqlDatabaseName .'</b> successfully exported to <b>~/' .$mysqlExportPath .'</b>'; break; case 1: echo 'There was a warning during the export of <b>' .$mysqlDatabaseName .'</b> to <b>~/' .$mysqlExportPath .'</b>'; break; case 2: echo 'There was an error during export. Please check your values:<br/><br/><table><tr><td>MySQL Database Name:</td><td><b>' .$mysqlDatabaseName .'</b></td></tr><tr><td>MySQL User Name:</td><td><b>' .$mysqlUserName .'</b></td></tr><tr><td>MySQL Password:</td><td><b>NOTSHOWN</b></td></tr><tr><td>MySQL Host Name:</td><td><b>' .$mysqlHostName .'</b></td></tr></table>'; break; }
  14. Hi, I am trying to add values together in my while loop, so far I have: $q->query($DB, $SQL); while($avrating=$q->getrow()): $averageratings = $avrating['sum(rating)'] / $noofreviews; $overallaverage = round($averageratings, 2) + round($averageratings, 2); echo '<p>'.$avrating['rating_name'].': '.round($averageratings, 2).'</p>'; endwhile; echo 'x'.$overallaverage; $overallaverage += $overallaverage / 10; echo 'The Average: '.$overallaverage; from this, I get: x7.34The Average: 8.074 the total shold be: 42.34 then dived by 10 should be 4.23
  15. here is the code in my page: $SQL = " SELECT sr.review_id, sr.review_date, sr.review, sr.reviewer_name, sr.reviewer_surname, r.rating_name, r.rating FROM school_reviews sr LEFT JOIN ratings r USING(review_id) WHERE sr.active = 1 AND sr.is_deleted = 0 AND sr.school_id = '" . $school_id . "' ORDER BY sr.review_date DESC"; $q->query($DB,$SQL); // store results of query in array $reviews = array(); while($row = $q->getrow()) { // get the review id $id = $row['review_id']; // group reviews by review id if(!isset($reviews[$id])) { $reviews[$id] = array( 'message' => $row['review'], 'date' => $row['review_date'], 'name' => $row['reviewer_name'], 'surname' => $row['reviewer_surname'], 'ratings' => array() ); } // group ratings by review id $reviews[$id]['ratings'][] = array( 'name' => $row['rating_name'], 'value' => '<img src="/en/images_v2/ratings/star'.$row['rating'].'.png" />' ); } // loop over the reviews foreach($reviews as $review_id => $review) { // output review echo "<div class=\"schoolreview\">"; echo "<p><span class=\"right\">Posted On: " . $review['date'] . "</span>"; echo "Review by: ".$review['name']."<br />\n" . "</p>\n"; // output ratings list for each review echo "<ul class=\"ratings\">\n"; foreach($review['ratings'] as $rating) { echo "\t<li>" . $rating['name'] . ': ' . $rating['value'] . "</li>\n"; } echo "</ul>\n"; echo "<p>Review: " . nl2br($review['message']) . "</p>"; echo "</div>"; }
  16. Thanks but no, I need to get the average by adding each rating for each review Review1 = Rating: Location = 4 Review2 = Rating: Location = 4 Review3 = Rating: Location = 5 4+4+5 / 3reviews = Overall Location = 4.3 Review1 = Rating: Accommodation = 2 Review2 = Rating: Accommodation = 5 Review3 = Rating: Accommodation = 1 2+5+1 / 3reviews = Overall Accommodation = 2.6
  17. Hi, I have a table RATINGS here is an example: <table border="1" cellpadding="2" cellspacing="2"> <tr> <td>rating_id</td> <td>review_id</td> <td>rating_name</td> <td>rating</td> </tr> <tr> <td>1</td> <td>46</td> <td>location</td> <td>4</td> </tr> <tr> <td>2</td> <td>46</td> <td>accommodation</td> <td>3</td> </tr> <tr> <td>3</td> <td>46</td> <td>travel time</td> <td>5</td> </tr> </table> I would like to get the average from the RATING datafield for each of the rows in my database Could anyone please help point me to a tutorial or be so kind to post some example code? thanks
  18. excellent! thank you very much, I've been using JOINS for a couple of years now but not ARRAYS I've learn a lot from this, thanks.
  19. Hi, I have 2 tables of data REVIEWS and RATINGS I would like to show a list of my reviews and a list of rating for each of my reviews I have tried putting my second WHILE loop inside teh first one but that doesn't work, can anyone please help? here is my code: $SQL = "SELECT * FROM school_reviews WHERE active = 1 AND is_deleted = 0 AND school_id = '" . $school_id . "' ORDER BY review_date DESC"; $q->query($DB,$SQL); while($review = $q->getrow()): $reviewid = $review['review_id']; echo $reviewid; echo '<h3>'.$review['review'].'</h3>'; endwhile; echo '<ul>'; $SQL = "SELECT * FROM ratings WHERE review_id = '".$reviewid."'"; $q->query($DB,$SQL); while($rating = $q->getrow()): echo '<li>'.$rating['rating_name'].': '.$rating['rating'].'</li>'; endwhile; echo '</ul>'; here is an example of the review I get: ReviewID: 46 Review: testing the reviews ReviewID: 43 Review: Because I know John is sooo handsome and he works at Cactus ReviewID: 40 Review: iuhi Ratings: Course / Course content: 5 Teacher: 5 Social Programme: 5 School Facilities: 5 Atmosphere: 5 Location: 5 Accommodation: 4 Service from Cactus: 2 Value for money: 3 Overall Experience: 5
  20. I just got this message so hopefully I can geocode more postcodes tomorrow?! var_dump() results jason response string(137) "{ "error_message" : "You have exceeded your daily request quota for this API.", "results" : [], "status" : "OVER_QUERY_LIMIT" } " jason decoded object(stdClass)#1 (3) { ["error_message"]=> string(56) "You have exceeded your daily request quota for this API." ["results"]=> array(0) { } ["status"]=> string(16) "OVER_QUERY_LIMIT" } lat NULL long NULL // $qr = "SELECT * FROM pubs WHERE rsTown = 'Worthing'"; // // $res= mysql_query($qr); // $i=0; // while($row = mysql_fetch_array($res)) // { // $postcode = $row["rsPostCode"]; // $response = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($postcode) . '&sensor=true'); // $response = json_decode($response); // // $lat = $response->results[0]->geometry->location->lat; // $long = $response->results[0]->geometry->location->lng; // // $qr = "UPDATE pubs SET rsLat='$lat',rsLong='$long' WHERE rsPostCode = '$postcode'"; // // //echo $qr; // $res= mysql_query($qr); // echo $qr; // // $i++; // }
  21. no nothing, and your line of code didn't output anything?!
  22. Hi, My codes does not show any Latitude or Longitude but it did last night when I started writing this code?! $postcode = 'BN113ED'; $response = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($postcode) . '&sensor=true'); $response = json_decode($response); $lat = $response->results[0]->geometry->location->lat; $long = $response->results[0]->geometry->location->lng; here is the URL that shows the JSON http://maps.googleapis.com/maps/api/geocode/json?address=bn113ed&sensor=true
  23. yes, here is my site: http://www.jbiddulph.com/worthing/
  24. thanks but I added name="submit" to my form and still 'hello' is not being output ?!
  25. I am trying to submit a form and then run an update but its not working, please help here is my page: <?php session_start(); mysql_connect("xxx", "xxx", "xxx"); mysql_select_db("xxx"); $id = $_REQUEST['id']; $query1 = "SELECT * FROM app1_blog"; $result1 = mysql_query($query1); $qry="SELECT id,title,date,article,image1,image2,image3 FROM app1_blog WHERE id = '$id'"; $cur=mysql_query($qry); while($i=mysql_fetch_row($cur)) {$id=$i[0]; $title=$i[1]; $date=$i[2]; $article=$i[3]; $image1=$i[4]; $image2=$i[5]; $image3=$i[6]; } if(isset($_POST['submit'])){ echo 'hello'; $new_title=mysql_real_escape_string(stripslashes($_POST["title"])); $new_article=mysql_real_escape_string(stripslashes($_POST["article"])); echo $new_title; } //$sql = "UPDATE app1_blog SET title='$new_title',article='$new_article' WHERE id = '$id'"; //$msg = 'Blog edited'; //$result = mysql_query($sql,$link) or die('Error: ' . mysql_error() . '<br>SQL: ' . $sql); //header("Location: edit.php?msg=$msg&id=$id"); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <title></title> <link rel="stylesheet" href="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.css"> <!-- Extra Codiqa features --> <link rel="stylesheet" href="codiqa.ext.css"> <!-- jQuery and jQuery Mobile --> <script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script> <script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> <!-- Extra Codiqa features --> <script src="https://d10ajoocuyu32n.cloudfront.net/codiqa.ext.js"></script> </head> <body> <!-- Home --> <div data-role="page" id="page<?php echo $id;?>"> <div data-theme="a" data-role="header"> <h3> Edit blog post </h3> </div> <div data-role="content"> <h2> Blog </h2> <form method="post" action="<?php print $_SERVER["PHP_SELF"]; ?>" name="form"> <div data-role="fieldcontain"> <label for="textinput1"> Title </label> <input name="title" id="textinput1" placeholder="" value="<?php echo $title;?>" type="text"> <input name="id" placeholder="" value="<?php echo $id;?>" type="hidden"> </div> <div data-role="fieldcontain"> <label for="textinput2"> Date </label> <input name="date" id="textinput2" placeholder="" value="<?php echo $date;?>" type="text"> </div> <div data-role="fieldcontain"> <label for="textinput3"> Article </label> <textarea name="article" id="textarea1" placeholder=""><?php echo $article;?></textarea> </div> <img src="<?php echo $image1;?>" alt="image" width="288" > <img src="<?php echo $image2;?>" alt="image" width="288" > <img src="<?php echo $image3;?>" alt="image" width="288" > <input data-theme="b" value="Submit" type="submit"> </form> </div> </div> </body> </html>
×
×
  • 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.