$strXMLxx .= "<categories>\n";
$strXMLxx .= "<category label='". $arr2[1] ."'/>\n";
$strXMLxx .= "</categories>\n";
$strXMLxx .= "<dataset seriesname='abc'>\n";
$strXMLxx .= "<set value='" .$BOY. "' />\n";
$strXMLxx .= "</dataset>\n";
$strXMLxx .= "<trendlines>\n";
$strXMLxx .= "<line startvalue='12250' color='#0075c2' displayvalue='Previous{br}Average' valueonright='1' thickness='1' showbelow='1' tooltext='Previous year quarterly target : $13.5K' />\n";
$strXMLxx .= "</trendlines>";
I try to store a value in $strXMLxx to use it for drawing a chart:
<?
$strXML = "<chart caption='".$r3."' subCaption='' canvaspadding='5' placeValuesInside='1' rotateValues='1' slantLabels='1' labelDisplay='ROTATE' pieSliceDepth='30' showBorder='1' xaxisname='".$tbl_header."' formatNumberScale='0' numberSuffix='' basefont='tahoma' basefontsize='10' basefontcolor='#000000' >"
.$strXMLxx;
$strXML .= "</chart>";
?>
After execution this message appears :No data to display
Related
Is it possible to have a php array sorted by clicking on a button?(Alphabetically or by year)
I am using fullpage.js and Columnizer jQuery plugin. Unfortunately, the problem is that I have to make a new table for each new slide. (Maybe someone knows a better solution?)
Or is it more useful javascript / jquery to use?
here is the Code:
// get table data from Plugin TablePress
$table = TablePress::$model_table->load( $atts['table-id'], true, true );
//only get the important data
$data = $table['data'];
$output = '<div id="tablecontest-slider">';
$output .= '<div class="section" id="section0">';
array_shift($data);
$counter = 1;
foreach ($data as $value) {
if ($counter == 1) {
$output .= '<div class="slide">';
$output .= '<div class="columnize">';
$output .= '<table>';
}
$output .= '<tr>';
$output .= '<td>' . $value[0] . '</td>';
$output .= '<td>' . $value[1] . '</td>';
$output .= '<td>' . $value[2] . '</td>';
$output .= '</tr>';
$counter++;
if ($counter == 21) {
$counter = 1;
$output .= '</table>';
$output .= '</div>';
$output .= '</div>';
}
}
$output .= '</div>';
$output .= '</div>';
return $output;
I dont know how to sort the array by click on a button..
Thank you for ideas and suggestions
No, you can't. PHP is running on your server and delivers the page. So there is no PHP-Array anymore once you render the site in your browser.
If you would get your data via an AJAX-call you COULD implement sorting and filtering on the server.
You can't directly sort anything on PHP from JS. BUT you can send an Ajax query on the button click, and respond with the PHP array sorted.
I adapted the following code for a project. The "updateTempDataClient.php simply INSERTS the selection into an SQL database. It works fine with one exception. If the table's first column has anything other than numbers in the field this function will not run.
> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<?php
echo "<table border='2'>";
echo "<tr><th>ClientNum</th><th>Company</th><th>Address</th><th>City</th><th>State</th></tr>";
while($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_BOTH))
{
$resultArray[] = $row;
echo "<tr>";
echo "<td onClick='selection(" . $row[0] . ")'><a href><font color=blue><u>" . $row[0] . "</a></font></u></td>";
echo "<td>" . $row[1] . "</td>";
echo "<td>" . $row[2] . "</td>";
echo "<td>" . $row[3] . "</td>";
echo "<td>" . $row[4] . "</td>";
//echo "<td>" . $row[5] . "</td>";
//echo "<td>" . $row[6] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
<script>
function selection(myselection){
$.post("updateTempDataClient.php?tabledata="+myselection,
function(data){
});
}
</script>
Here is the INSERT query. The database has 3 columns. One is for id (int) the other 2 are client and vendor. Both are varchar(50). I tried adding an alert to the script. It will popup when a numbers only selection is made. However, if I click on anything with a letter in it the alert won't fire.
<?php
$serverName = "palmbeach\sqlexpress";
$connectionInfo = array( "Database"=>"mylocaldb", "UID"=>"username", "PWD"=>"******");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
//echo "Connected OK.";
}else{
echo "Connection fail.<br />";
die( print_r( sqlsrv_errors(), true));
}
$test = urldecode($_GET[‘tabledata]);
$sql = "UPDATE TempData SET client='$test' WHERE id=1";
$stmt = sqlsrv_query( $conn, $sql);
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
// Close the connection.
sqlsrv_close( $conn );
?>
The day names on my site are in English.
How can I get the day names in Russian?
In JavaScript I tried to replace Tuesday->Вторник in code but it is not working.
Code:
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$url = 'http://api.sypexgeo.net/xml/'. $ip .'';
$xml = simplexml_load_string(file_get_contents($url));
$loc_array = array($xml->ip->city->lat,$xml->ip->city->lon);
$loc_safe = array();
foreach($loc_array as $loc){
$loc_safe[] = urlencode($loc);
}
$loc_string=implode(',', $loc_safe);
$json = file_get_contents('http://api.wunderground.com/api/232323***/satellite/webcams/forecast/q/' . $loc_string . '.json');
$obj = json_decode($json, true);
?>
<?
$html .= "</h2><table cellpadding=4 cellspacing=3><tr>";
foreach ($obj['forecast']['simpleforecast']['forecastday'] as $arr) {
$html .= "<td align='center'>" . $arr['date']['weekday'] . "<br />";
$html .= "<img src='http://icons-pe.wxug.com/i/c/k/" . $arr['icon'] . ".gif' border=0 /><br />";
$html .= "<font color='red'>" . $arr['high']['celsius'] . '°C' . " </font>";
$html .= "<font color='blue'>" . $arr['low']['celsius'] . '°C' . "</font>";
$html .= "</td>";
}
$html .= "</tr></table>";
echo $html;
?>
<script type="text/javascript">
window.onload=function(){
//I try, but not replace
$("td:contains('Tuesday')").html("Вторник");
};
</script>
As an option, you can change the call to wunderground API. Include language settings /lang:xy. Something like this:
https://api-ak-aws.wunderground.com/api/8dee7a0******/satellite/webcams/forecast/lang:RU/units:metric/v:2.0/q/CWEW.json
You can try defining a JSON object like:
days = { "name of the day": "name of the day in Russian" }
Then instead of using $arr['date']['weekday'] use days[$arr['date']['weekday']].
Note: I don't know the php syntax actually, but something like that should work.
I have an issue with my grid, after loading data and enabling vertical scroll, i find my grid loaded with additional space after the my rows. I want that removed, any idea why i am getting this ?
This is my grid with the scroll bar
This is the problem
I just want the scroll bar to stop at number 20, i don't want all that additional space.
And this is my grid setting :
$html .= '$("#'. $this->_name .'").jqGrid({';
$html .= 'url:"tools/grid_server_calls.php",';
$html .= 'datatype: "json",';
$html .= 'autoencode: true,';
$html .= 'mtype: "POST",';
$html .= 'postData:{inputs:'. $this->_server_inputs .'},';
$html .= 'gridview: true,';
$html .= 'ignoreCase: true,';
//$html .= 'loadui: "block",';
$html .= 'hidegrid: false,';
$html .= 'width: "' . $this->_width_grid . 'px",';
$html .= 'forceFit: true,';
$html .= 'pager: "#pager_'.$this->_name.'",';
$html .= 'rowNum: ' . $this->_rowNum . ',';
$html .= 'rowList: [' . $this->_rowList . '],';
if( $this->_scroll_enabled ){
$html .= 'scroll: true,';
$html .= 'height: "230px",';
}
else{
$html .= 'height: "auto",';
}
$html .= 'viewrecords: true,';
$html .= 'emptyrecords:"'.$this->_message_no_records.'",';
$html .= 'recordtext:"{0} - {1} / {2}",';
$html .= 'altRows: true,';
$html .= 'multiselect: "' . $this->_multiselect .'",';
$html .= 'altclass: "color_line_grid",';
$html .= 'caption: "' . $this->_caption . '",';
$html .= 'colNames: [' . $this->_colNames . '],';
$html .= 'colModel: [' . $this->_colModel . '],';
$html .= 'sortname: "' . $this->_initialSort . '",';
$html .= 'sortorder: "asc",';
if(!$this->_search_enabled){
$html .= 'pgbuttons: false,';
$html .= 'pgtext: null,';
$html .= 'rowList: [],';
$html .= 'cmTemplate: {sortable:false},';
}
I got to the root of the problem, it was as simple as learning to read before asking dumb questions, in fact you need not set scroll to true, you just need to set a height, when the data exceeds the height that was set, the scroll bar will appear automatically 'In my case' .
I'm generating a custom field on the Wordpress admin panel. I want to add 2 buttons:
1. Add another
2. Remove field
The add button should generate the same field. I need help coding the javascript that generates the fields.
Here is my code:
$html = '';
$html .= '<div class="pyre_metabox_field">';
$html .= '<label for="pyre_' . $id . '">';
$html .= $label;
$html .= '</label>';
$html .= '<div class="field">';
$html .= '<input type="text" id="pyre_' . $id . '" name="pyre_' . $id . '" value="' . get_post_meta($post->ID, 'pyre_' . $id, true) . '" />';
if($desc) {
$html .= '<p>' . $desc . '</p>';
}
$html .= '<p style="margin-bottom:15px; padding-top:5px;clear:both;">Add Remove</p>';
$html .= '</div>';
$html .= '</div>';
Have you tried : Advanced Custom Fields ?
This plugin is really simple to use, and I'm pretty sure it can do what you're trying to do. It may save you a lot of work :)