
jarv
Members-
Posts
325 -
Joined
-
Last visited
Everything posted by jarv
-
Lat/Long was wrong way round! THANKS!
-
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
-
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.....
-
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 )
-
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
-
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 )
-
Thanks, that worked but now I get: Uncaught RangeError: Maximum call stack size exceeded
-
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; } ?>
-
I would if I could find it but then the date will be wrong I think
-
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');
-
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
-
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?
-
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; }
-
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
-
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>"; }
-
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
-
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
-
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.
-
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