I'm frequently using the following to get the second to last value in an array:
$z=array_pop(array_slice($array,-2,1));
Am I missing a php function to do that in one go or is that the best I have?
Surprised that i havent been able to find this myself, but anyway. Let's say i use my web user control like this:
<myprefix:mytag userid="4" runat="server">Some fancy text</myprefix:mytag>
How would i be able to access the text inside the tags from its codebehind? Was expecting it to be exposed through this.Text, this.Value or something similar.
I Need to select a category from a list box with no of items on it. eg. Videos(29). I need to select this and in the next loop it will be "Videos(30)","Videos(31)" etc..
Tried the followings
Addselection with "//option[@value='4641']",
Storeselectedoption,
selenium.click,
selenium.doubleclick etc..
I'm using oracle express and in my application i would insert a time-stamp value in my table:
$marca = date('y-m-d H:i:s');
$query = " INSERT INTO SA_VERSIONE
( ID_ACCETTAZIONE, MARCA_TEMPORALE, TESTO, FIRMA, MEDICO)
VALUES
('$id', '$marca', '$testo', '$firma', '$medico')
";
$stid = oci_parse($conn, $query);
oci_execute($stid);
but when execute it return:
Warning: oci_execute() [function.oci-execute]: ORA-01843: mese non valido in ...
and say that the month is not valid
I have some code like this
function doSomething(){
Jquery.ajax(type: "POST",
url: "HelloWorld",
success: function (msg) {
if(msg.d =="Hello World")
{
return true;
}else
{
return false;
}
}
);
}
i want to know something based on which the return value of the succes function.
Can somebody help?
I have the following code:
NSMutableDictionary *jsonObj = [parser objectWithString:json_string error:nil];
NSString *test = [[[jsonObj objectForKey:@"questions"] valueForKey:@"owner"] valueForKey:key];
but what I get back is:
(
1a19f089a2bc4ee42bff1c102c6e89b8
)
The actual value is fine, but I get those parenthesis, which show up in my string. How can I get rid of them?
how to get the value 4500 to a variable
stdClass Object ( [total] => 4500 )
i tried like these
$abc['total']
$abc->total
but get error when i tried to echo the variable
A PHP Error was encountered
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename: controllers/home.php
Line Number: 144
please help me
Hi,
in a Model I have a CharField with choices:
class MyModel(models.Model):
THE_CHOICES=(
('val',_(u'Value Description')),
)
...
myfield=models.CharField(max_length=3,choices=THE_CHOICES
Now in the template I access an instance of MyModel:
{{ my_instance.myfield }}
Of course the gives me val instead of Value Description. How do I get the description?
Thanks in advance!
I have an array of double pointers, but every time I try do print one of the values the address gets printed. How do I print the actual value?
cout << arr[i] ? cout << &arr[i] ? they both print the address
Does anyone know?
I have 3 HTML combo/drop down boxes. All of them have a distinct name and id.
On a particular event I want to get the value of all three of them.
Can any one give me a code snippet for that?
I have a DataGridView which is filling from Table in SQL Server Database. One of it's columns is "price".
Type of column in DGV is automatically sets as Decimal.
In some cases I need to write in cells of this column text like "none", instead of price.
How can I do it?
DGV.Item("price", 0).Value = "none"
doesn't work, because of decimal type of a cell.
I would like to quickly retrieve the median value from a boost multi_index container with an ordered_unique index, however the index iterators aren't random access (I don't understand why they can't be, though this is consistent with std::set...).
Is there a faster/neater way to do this other than incrementing an iterator container.size() / 2 times?
Hello:
I have a simple webpage that displays the credit balance for calling cards. So far without any problems, with HTML, PHP and mysql, I was able to retrieve the balance from a data base. But I have to display the result in ANOTHER PAGE, wich looks akward because the page must reload.
Can I just load this value into a pre-drawed field under the input fields that collect the data from the customer? Such as :
Account Number: 134556
PIN: *
|send|
Balance is: $12.36
Thanks in advanced
Is there an method for programatically (in T-SQL) retrieving the maximum (and minimum) value of a datatype? That it would act like float.MaxValue in C#.
I would like to use it in some selection when the parameter does not equal any actual values in the database, so I would use something like
declare @min float
declare @max float
/*fill @min and @max, can be null if undefined*/
select * from foo
where bar between isnull(@min,0 ), isnull(@max,max(float)/*magic*/)
Thanks
Hi,
i have a NSString instance ,i want to retrieve value from it and store it into an integer.
This is wat i am doing but its not working.
NSString *totalcnt;
char *str = totalcnt;
int a = atoi(str);
Help me out.
Thanks
Taimur
I want to do something like this
$.get('/Controller/Action/', { model : null }, function(data) {});
Unfortunatelly it doesn't work. In server side the value of the model is {object}.
How do I get null?
I'm trying to query a database, and return a set of values. Part of the data i'm trying to return is an insurance premium breakdown.
Is it possible to run a query, that selects multiple fields, then adds then and returns them as a single value?
I've seen SUM() but the examples i've seen show it as adding up the results of an entire field - where as i need it to add specific fields for each row returned.
Any help is much appreciated.
In Javascript I can do this:
function A(x) { return x || 3; }
This returns 3 if x is a "non-truthful" value like 0, null, false, and it returns x otherwise. This is useful for empty arguments, e.g. I can do A() and it will evaluate as 3.
Does Python have an equivalent? I guess I could make one out of the ternary operator a if b else c but was wondering what people use for this.
Here a code I'm using now.
<%= f.select :project_id, @project_select %>
How to modify it to make it it's default value params[:pid] when page is loaded?
I've got a Jlist inside a JScrollPane and I've set a prototype value so that it doesn't have to calculate the width for big lists, but just uses this default width.
Now, the problem is that the Jlist is for some reason replacing the end of an element with dots (...) so that a horizontal scrollbar will never be shown.
How do I disable with "wrapping"? So that long elements are not being replaced with dots if they are wider than the Jlist's width?
I've reproduced the issue in a small example application. Please run it if you don't understand what I mean:
import javax.swing.*;
import java.awt.*;
public class Test
{
//window
private static final int windowWidth = 450;
private static final int windowHeight = 500;
//components
private JFrame frame;
private JList classesList;
private DefaultListModel classesListModel;
public Test()
{
load();
}
private void load()
{
//create window
frame = new JFrame("Test");
frame.setSize(windowWidth, windowHeight);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
//classes list
classesListModel = new DefaultListModel();
classesList = new JList(classesListModel);
classesList.setPrototypeCellValue("prototype value");
classesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
classesList.setVisibleRowCount(20);
JScrollPane scrollClasses = new JScrollPane(classesList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
for (int i = 0; i < 200; i++)
{
classesListModel.addElement("this is a long string, does not fit in width");
}
//panel
JPanel drawingArea = new JPanel();
drawingArea.setBackground(Color.white);
drawingArea.add(scrollClasses);
frame.add(drawingArea);
//set visible
frame.setVisible(true);
}
}
Even if you force horizontal scrollbar, you still won't be able to scroll because the element is actually not wider than the width because of the dot (...) wrapping.
Thanks in advance.
I have the following SQL query, note I want the literal value '0' in the second
field in the second SELECT statement from the ItemSale table.
How do I express this in LINQ?
I get the error message 'Invalid anonymous type member declarator'.
SELECT BranchNumber,QuantitySold
FROM Department
UNION
SELECT BranchNumber,0
FROM ItemSale
How to express the '0' in LINQ?
var unionQuery = (from dept in Department
select new
{
dept.BranchNumber,
dept.QuantitySold,
})
.Concat(from item in ItemSale
select new
{
item.BranchNumber,
0
});
I need help because I want to create a gameover screen that display score. However, there's an error that prevent me from transferring the score from theplayclass.as to thegameoverclass.as. Are there ways to pass a value to another movieclip without causing any errors.
I refer the source code from this website : http://www.emanueleferonato.com/2008/12/17/designing-the-structure-of-a-flash-game-as3-version/
Here's the error
C:\Users\xxx\Downloads\Migrate\test\theplayclass.as, Line 54, Column 41 1067: Implicit coercion of a value of type theplayclass to an unrelated type main.
main.as
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class main extends MovieClip
{
public var playClass:theplayclass;
public var gameOverClass:thegameoverclass;
public function main()
{
showWin();
}
public function showWin()
{
playClass = new theplayclass(this);
addChild(playClass);
}
public function showGameOver()
{
gameOverClass = new thegameoverclass(this);
addChild(gameOverClass);
removeChild(playClass);
playClass = null;
}
}
}
theplayclass.as
package
{
import flash.display.MovieClip;
import flash.events.*;
public class theplayclass extends MovieClip
{
private var mainClass:main;
var gameScore:Number;
var gameOverScore:thegameoverclass;
public function theplayclass(passedClass:main)
{
mainClass = passedClass;
scoreText.text ="0";
gameScore = 0;
win.addEventListener(MouseEvent.CLICK, showwinFunction);
next.addEventListener(MouseEvent.CLICK, showgameoverFunction);
addEventListener(Event.ADDED_TO_STAGE, addToStage);
addEventListener(Event.ENTER_FRAME, changeScore);
}
public function addToStage(e:Event):void
{
this.x = 0;
this.y = 0;
}
private function showwinFunction(e:MouseEvent):void
{
gameScore+=50;
}
private function changeScore(e:Event):void
{
scoreText.text =""+gameScore;
}
public function showgameoverFunction(e:MouseEvent)
{
mainClass.showGameOver();
gameOverScore = new thegameoverclass(this);
gameOverScore.setTextScore(gameScore);
}
}
}
thegameoverclass.as
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.*;
public class thegameoverclass extends MovieClip
{
var mainClass:main;
var scorePoints:Number;
public function thegameoverclass(passedClass:main)
{
mainClass = passedClass;
finalScore.text = "test";
}
public function setTextScore(textToSet:Number)
{
finalScore.text = ""+scorePoints;
}
}
}
I am trying to get the value of a cell in a table view but it won't let me. If someone could help that would be great.
int numberOfChecks = -1;
numberOfChecks = numberOfChecks +1;
if ([objectsForTable count]-1 >= numberOfChecks) {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:numberOfChecks];
NSString *cellTitle = cell.textLabel.text;
}