I can think of a number of ways to do this in PHP or even JavaScript, but I'm wondering if there's a SQL-based technique I'm overlooking.
I have a database table, let's say 20 fields X 10 rows. I want to display the entire table on an web page, so I'd do something like SELCT * FROM data_table;, and then format the result set using HTML table tags.
However, I'd also like to highlight values in the table based on whether they are the maximum or minimum value in their column. For example, I'd add bold tags around the max in each column. A resulting table might look something like this, with bold tags shown:
id | field1 | field2 | field3 | ...
0 | 5 | 2 | <b>7</b> | ...
1 | 3 | <b>8</b> | 6 | ...
2 | <b>9</b> | 5 | 1 | ...
...
I could do a separate SELECT with an ORDER BY for each field and then interpret the results, but that seems like a lot of extra DB access.
My alternative right now is to just fetch the whole table, and then sort/search for the highlight values using PHP.
Is there a better way?
I'm creating a database access layer in native C++, and I'm looking at ways to support NULL values. Here is what I have so far:
class CNullValue
{
public:
static CNullValue Null()
{
static CNullValue nv;
return nv;
}
};
template<class T>
class CNullableT
{
public:
CNullableT(CNullValue &v) : m_Value(T()), m_IsNull(true)
{
}
CNullableT(T value) : m_Value(value), m_IsNull(false)
{
}
bool IsNull()
{
return m_IsNull;
}
T GetValue()
{
return m_Value;
}
private:
T m_Value;
bool m_IsNull;
};
This is how I'll have to define functions:
void StoredProc(int i, CNullableT<int> j)
{
...connect to database
...if j.IsNull pass null to database etc
}
And I call it like this:
sp.StoredProc(1, 2);
or
sp.StoredProc(3, CNullValue::Null());
I was just wondering if there was a better way than this. In particular I don't like the singleton-like object of CNullValue with the statics.
I'd prefer to just do
sp.StoredProc(3, CNullValue);
or something similar. How do others solve this problem?
There is an image capturing device which gives its output in wmf. This output is stored in the database directly. We have cases where at times some of these images do not appear on a web page in IE. But if we right click on the page we are able to save the image on to the hard disk; meaning the image does exist on the page, but does not appear visible. I think this is because of some file corruption issue, but I don't know how to resolve it. We are however able to view such files using MS Picture Viewer (desktop app). Is there anyway we can detect such problematic files?
By best I mean most efficient.
So don't go on about subjectiveness.
I have a list of websites and I want to store the list on the iphone locally, there must be an URL, title and a small image (like 32x32 max image size). I don't think I should be using CoreData for this. Should I be using a plist?
From the docs:
You usually access to-many
relationships using
mutableSetValueForKey:, which returns
a proxy object that both mutates the
relationship and sends appropriate
key-value observing notifications for
you.
So this returns an "intelligent" NSMutableSet which automatically lets the context delete objects when they get deleted from the set, and reverse? Is that a proxy object?
I have a datamodel with to-many to-many relations. Using the example of employee database let say the entity division is related to department which in turn is related to employee. The employee has an attribute salary. How best to have a attribute at the level of division which is derived from the salary attribute. For example average salary or maximum salary.
I would need those attributes to sort the list of departments.
I'm having some problems using sed in combination with html. The following sample illustrates the problem:
HTML="<html><body>ENTRY</body><html>"
TABLE="<table></table>"
echo $HTML | sed -e s/ENTRY/$TABLE/
This outputs:
sed: -e expression #1, char 18: unknown option to `s'
If I leave out the / from $TABLE so that it becomes <table><table> it works ok.
Any ideas on how to fix it?
`public void SeparateData()
{
//read file
StreamReader sr = new StreamReader("myTextFile.txt");
//string to hold line
string myline;
myline = sr.ReadLine();
while ((myline = sr.ReadLine()) != null)
{
string[] lines = Regex.Split(myline, " ");
foreach (string s in lines)
{
using (StreamWriter sw = new StreamWriter("myTextFile.txt"))
sw.WriteLine(lines);
}
}
} `
I've been trying to estimate the size of an Access table with a certain number of records.
It has 4 Longs (4 bytes each), and a Currency (8 bytes).
In theory: 1 Record = 24 bytes, 500,000 = ~11.5MB
However, the accdb file (even after compacting) increases by almost 30MB (~61 bytes per record). A few extra bytes for padding wouldn't be so bad, but 2.5X seems a bit excessive - even for Microsoft bloat.
What's with the discrepancy? The four longs are compound keys, would that matter?
This is what I'm doing right now:
Execute a query and check if the date
to be inserted already exists in a
table.
If date doesn't exist:
Another query will insert the date into the table.
How can these two query be combined?
I'm trying to cut a row that has the specified cell blank and then paste it into another sheet in the same workbook. My coding works fine to delete the row but everything I've tried to cut and paste keeps giving me errors. Here's the working code that deletes the rows:
Sub Remove()
'Remove No Denovo &/or No Peak Seq
Dim n As Long
Dim nLastRow As Long
Dim nFirstRow As Long
Dim lastRow As Integer
ActiveSheet.UsedRange
Set r = ActiveSheet.UsedRange
nLastRow = r.rows.Count + r.Row - 1
nFirstRow = r.Row
For n = nLastRow To nFirstRow Step -1
If Cells(n, "G") = "" Then Cells(n, "G").EntireRow.Delete
Next n
End Sub
Thanks for any help!
What's the difference between the two? They seem to have the same functionality at first glance.
Which one has faster performance which one is easier to use?
I'm not sure what the best way of populating a notification page is. I've been using sessions to populate it with information, but this falls short if the user is blocking cookies. I've considered passing it in HTTP GET variables, but I'm unsure whether it's a good alternative since its length is limited by some browsers.
Which method do you prefer?
Hi,
I have a textbox in a gridview and a table "purchaseoreders". Now when the itemcode(field of the table) is given in the textbox, the others details have to bind.
Ideas..??
Please help.
Thank You
Pravi.
i have 1 master page with 5 dropdownlists on it. The thing is, the master page has href's to aspx pages that use this master page as pagebehind. now lets save i am in page1.aspx with master1.master as pagebehind. If i select couple of dropdownlists, and then click on an href, the whole master page reloads. how do i catch this in session before postback?
Building on this question, is there a simple solution for having a multi-key dictionary where either key individually can be used to identify the value?
ie.
MultikeyDictionary<TKey1, TKey2, TValue> foo;
foo.Add(key1, key2, value);
myValue = foo[key1];
// value == myValue
foo.Remove(key2);
myValue = foo[key1]; // invalid, Exception or null returned
Can any one tell me what is the problem in my program?
String a[],b[];
int c[] = new int[b.length];
for (int j = 0; j < a.length; j++) {
for (int k = 0; k < b.length; k++) {
if (b[k].equals(a[j])) {
c[k]++;
} else {
c[k] = 0;
}
}
}
I have thousands of words stored in a HashMap. Now I want to check in every file that how many time one word occurred from allWords.
Can you point out mistake in my program or give me your idea that how I can do it?
Im trying to add variables to a C char array. Also I have tried sprintf, but it is causing a few other issues within my program.
I am looking to do something like this:
char* age = "My age is = " + age;
I am planning on sending the char array to a socket using send()
Thanks