darkagn 315 Veteran Poster Featured Poster

It's probably better to have a try at solving your problems yourself and post here with specific problems or error messages that you are experiencing. If you need help understanding what some of your code does, feel free to post snippets here and describe where you are having difficulties, and we will try to help you out.

darkagn 315 Veteran Poster Featured Poster

This will involve some trig, so take a look at the java.lang.Math class.

darkagn 315 Veteran Poster Featured Poster

When you display your results, display them as a hyperlink and store the product id in the url. Then when you go to the details page, use $_GET to retrieve it.

darkagn 315 Veteran Poster Featured Poster

Sorry try

print_r(var_dump($_SERVER));
darkagn 315 Veteran Poster Featured Poster

Is the $_Server array i mentioned earlier is complete ?

var_dump($_SERVER);

will let you know for sure.

darkagn 315 Veteran Poster Featured Poster

The $_SERVER superglobal array contains such information. For example,

$ipAddress = $_SERVER["REMOTE_ADDR"];

Try a var_dump on your $_SERVER array and you will see all of the information that it contains.

EDIT: Not sure about the device, but the OS should be available in the $_SERVER array, let me know if I'm wrong but from memory it is. The OS will often give a strong indication as to the device type so should be suitable for most practical purposes.

darkagn 315 Veteran Poster Featured Poster

Check out this great article by Alexander Chigrik. His explanations of indexes and their function in MSSQL is great, and he gives some really good insight into the optimisation of your database.

darkagn 315 Veteran Poster Featured Poster

You need to close your main method with a } before you declare your numsum method.

darkagn 315 Veteran Poster Featured Poster

So what have you done so far? Or where are you having problems? We only help those that show effort...

darkagn 315 Veteran Poster Featured Poster

In your query change ccc = '%egasg%'" to ccc LIKE '%egasg%'" . Other than that I can't tell what could be wrong with your query.

darkagn 315 Veteran Poster Featured Poster

You can do this:

g.scale = 1;
<?php
$resultCount = mysql_query("SELECT COUNT(*) FROM aa where bbb='1' AND ccc = '%egasg%'") or die(mysql_error());
$count= mysql_result($resultCount,0,0);
?>
g.addRow(<?php echo $count; ?>,3,4,1);
g.title = "haha";
darkagn 315 Veteran Poster Featured Poster

How can I make the first query into one table?

What do you mean? What are you trying to accomplish?

darkagn 315 Veteran Poster Featured Poster

Hi blanj and welcome to DaniWeb :)

We only give homework help to those who show a bit of effort. What have you done so far?

darkagn 315 Veteran Poster Featured Poster

The problem with your method is that the size of your array doesn't change. I would do this in your remove method:
1. create an array of size (original array size -1)
2. go through the original array one at a time.
3. If the index doesn't equal the index of the item being removed, add it to the new array.
4. return the new array.

There are probably more efficient solutions, but that will get the job done.

darkagn 315 Veteran Poster Featured Poster

The question is what is the best way to trach the ads. Should there be a seperate months table?

One approach might be to have an ads_months table that links each advertisement to the month(s) it was run. This would require three columns, ads_months_id (numeric PK), ad_id (numeric FK), month_run (date). Then when you want to know what ads were run during january 2010, use something like the following query:

select ad_id, month(month_run), year(month_run) from ads_months
group by ad_id
having month(month_run) = 1 and year(month_run) = 2010
darkagn 315 Veteran Poster Featured Poster

There are zip and rar extension libraries for PHP. The PHP documentation discusses some, there are also third party ones too. Once you have one installed it should be pretty straight forward, just zip or rar the directory.

darkagn 315 Veteran Poster Featured Poster

Phoogle is a Google Maps PHP package that is very easy to use.

darkagn 315 Veteran Poster Featured Poster

Try ordering your sub-query by review_date desc. This will then return the last row first and should be picked up by your outer query.

darkagn 315 Veteran Poster Featured Poster

Ah, that makes sense. Glad you solved it!

darkagn 315 Veteran Poster Featured Poster

This link has a good explanation of primitives and literals. Let us know if you still have questions after reading this page.

darkagn 315 Veteran Poster Featured Poster

You have a - where there should be an =.

CREATE TRIGGER before_insert_ddsw BEFORE INSERT ON `ddsw`
      FOR EACH ROW SET products.count = products.count +1;
darkagn 315 Veteran Poster Featured Poster

You could try the DISTINCT key word, but I'm not sure if it will help because you are selecting the columns pros and cons which will undoubtedly not be unique.

SELECT DISTINCT
      p.product,
      r.pros,
      r.cons,
      a.AVG,
      a.Latest
      FROM product_tbl AS p
      JOIN (
      SELECT
      product, AVG((price+quality+features)/3) AS AVG,
      MAX(review_date) AS Latest
      FROM review_tbl
      GROUP BY product
      ) AS a ON p.id=a.product
      JOIN review_tbl AS r ON p.id=r.product
      ORDER BY a.AVG DESC;
darkagn 315 Veteran Poster Featured Poster

How should i read a nested for loop? Like would this run essentially 30 times? Does it basically say run the inside loop 10 times? So then does it basically run once, go into the nested loop, run 3 times, then go back into the outer loop, then back into the nested loop 3 times?

Yes, the inner code will be run 30 times. Basically, the outer loop is run 10 times, and each time the outer loop is run the inner loop is run 3 times, (plus the output line is run once each time the outer loop is run).

And I'v read a few definitions and my lecturer has failed what a 'literal' is effectivley. So can i ask, what are they?

A literal is not a terminology I am immediately familiar with, what is the context?

darkagn 315 Veteran Poster Featured Poster

Ok the trick is to decide when the variable is incremented. The pre-increment (++i) occurs before the variable is used in the current statement, so in the final output the increment happens before the output. The opposite is true for the post-increment (i++), here the increment occurs after the variable is used in the current statement.

So, the first output only outputs the value of i. That one's easy. The second one outputs the value of i and then increments it (i++) and the final output statement occurs after i is incremented again (++i). The value of i after the code is complete is a trick question, it wouldn't matter the order of the increments, the value would be -7 either way.

I hope this illustrates to you a bit better how increment works. Try this one for more practice:

int a = 0;
System.out.println(a);
a++;
System.out.println(a++);
a++;
System.out.println(++a);
System.out.println(a++);
System.out.println(a);

Or this slightly harder one involving methods:

public static int squared(int a)
{
  return a * a;
}

int b = 7;
int c = squared(b++);
int d = squared(++b);
int e = squared(b);
System.out.println(b);
System.out.println(d);
System.out.println(e);
System.out.println(f);
darkagn 315 Veteran Poster Featured Poster

The problem here is that your pros and cons, there can be one of each for each and every record, and because they are text they will rarely be the same as another review.

I would do this in two queries, the first returning the average rating and latest review date, the second returning the list of pros and cons, and then deal with the entire set of data as you need.

darkagn 315 Veteran Poster Featured Poster

Well for starters, the code will output three values of i. What are those values at the time that the code outputs?

Sorry about the "$i", that is PHP syntax. It should be:

int i = 17;
      ++i;
      System.out.println(i);
      i = -7;
      i--;
      i--;
      System.out.println(i++);
      System.out.println(++i);

EDIT: Also, what is the value of i after the code is run?

darkagn 315 Veteran Poster Featured Poster

Also the " ++i " thing confuses me, it means that it is iterated beforehand , is that right ? So what kind of questions might involve that?

Can you answer the following common exam question:

What is the output of the following code snippet?

$i = 17;
++$i;
System.out.println($i);
$i = -7;
$i--;
$i--;
System.out.println($i++);
System.out.println(++$i);

EDIT: Here is a link to Google's first site when I typed in "Java exam questions" into the search engine. There were many, many more.

darkagn 315 Veteran Poster Featured Poster

Ok, so what is it doing that it shouldn't? What should it do that it is not? Are you getting any error messages when you run it?

darkagn 315 Veteran Poster Featured Poster

The AVG function will be valuable to you. Basically, you are after an average of the average of your three rating values, so your query will look something like this:

select product_id, avg((price + quality + features)/3) as average_rating from review_tbl group by product_id

You can join with the other table as necessary, or limit your result set to a list of products etc. Have a fiddle with that query and see what you can come up with.

darkagn 315 Veteran Poster Featured Poster

The DATEPART function might come in handy here. Not sure exactly how you could do it without writing a procedure, but take a look at the MSSQL documentation for the DATEPART function and see if you get any inspiration from it.

darkagn 315 Veteran Poster Featured Poster

Have you tried a HAVING clause instead of a WHERE clause? I don't really understand the difference, but sometimes HAVING works when a WHERE doesn't.
Your query would become:

SELECT TS.col1, TS.col2, count(*) AS Number
      FROM view_scary VS
      LEFT OUTER JOIN table_scary TS ON VS.IdContact = TS.IdContact
      GROUP BY TS.col1, TS.col2
      HAVING TS.col1 = 5 AND TS.col2 = 'a'
darkagn 315 Veteran Poster Featured Poster

Hi igirl and welcome to DaniWeb :)

If I keep both tables how can I add the Title to the CourseDetails table without manually adding them all?

There is no need, it is in the Courses table so you don't need it in the CourseDetails table as well. To select all details from both tables you do a join like so:

select Courses.CourseID, Title, Description, Objectives, Price, Length, Prerequisites, CategoryID, TypeID, SubTypeID, Type
from Courses
inner join CourseDetails
ON Courses.CourseId = CourseDetails.CourseId

Now for your second problem, all you need to do is update the Courses table according to the CourseId like so:

update Courses set Title = 'Course Title' where CourseId = 12

Just change 'Course Title' and 12 to match the record that you are updating.

Hope this helps.

darkagn 315 Veteran Poster Featured Poster

SQLYog is pretty easy to use.

darkagn 315 Veteran Poster Featured Poster

The best text book I used in my Mathematics and CS degree was "Linear Algebra and its Applications" by David C Lay, Published by Addison-Wesley. We used it in three of the five mathematics courses I did (including Discrete Math), and can thoroughly recommend it. I hadn't studied anything for 10 years before I decided to go back to university, so that is probably a pretty good advertisement for this text!

darkagn 315 Veteran Poster Featured Poster

There are no errors displayed because you are catching the exceptions and not doing anything with them. Try this to see what is happening:

} catch (MalformedURLException me) {
  System.err.println(me.getMessage());
} catch (IOException ioe) {
  System.err.println(ioe.getMessage());
}
darkagn 315 Veteran Poster Featured Poster

You can't use the == operator on a string comparison in java. You need to call the equals method like so:

if(input.equals("sixty"))
darkagn 315 Veteran Poster Featured Poster

Your if-statement has too many else's. An if-statement in PHP looks like this:

if(boolean condition 1)
{
  // do something
}
else if(boolean condition 2)
{
  // do something else
}
...
else if(boolean condition X)
{
  // do something else
}
else
{
  // if we get here then ALL previous conditions have evaluated to false
  // so there can only ever be one "else" but as many "else if" statements as you need
}

$airdate is ok because when you have grabbed it from the database you have passed it through a call to strtotime to change it to a timestamp.

EDIT: whitestream6, you are very close. Your problem lies not in your calls to date() but in how you are assessing when to use which date format.

darkagn 315 Veteran Poster Featured Poster

You can create as many instances of as many classes as you like (up to your memory limit). I will need to see your Catalog class as well in order to see what is going on, as the init() function in both your classes makes use of this.

darkagn 315 Veteran Poster Featured Poster

Happy New Year from Adelaide, South Australia where it is currently 3am on New Year's Day :)

darkagn 315 Veteran Poster Featured Poster

Actually I can see the benefits of the initial proposal which mostly targets child pornography and terrorism sites.

However I am a bit of a cynic. Once in place who's job will it be to say what is offensive and what is acceptable. I mean, we can't even get an R-rating for our video games, but I guess that is just a whole other issue...

BTW Happy New Year!

darkagn 315 Veteran Poster Featured Poster

Hi JRM,

Sorry for the swings and round abouts, I was trying to explain what was happening without just handing the answer over so that whitestream6 could learn from what was being done. strftime is indeed another approach, but I started down the date() path and didn't want to confuse whitestream6 further. But you do make good points, thanks for the contribution :)

darkagn 315 Veteran Poster Featured Poster

When deleteing from multiple tables, you need to specify what is being deleted. There are two available syntaxes:

DELETE table1, table2 
FROM table1 INNER JOIN table2 ON table1.id = table2.id 
WHERE table1.id = 1

or:

DELETE FROM table1, table2 
USING table1 INNER JOIN table2
WHERE table1.id=table2.id AND table1.id = 1

Hope this helps.

darkagn 315 Veteran Poster Featured Poster

Ok, I think you've got yourself confused with all the variables.
When I gave you this code:

$airdate = strtotime($r['airdate']);
$now = strtotime("NOW");
$currentYear = date("Y", $now);
$yearOfDateFromDatabase = date("Y", $airdate);
if($yearOfDateFromDatabase == $currentYear)

this is what I was doing:
-- get the timestamp of the database record ($airdate)
-- get the current timestamp ($now)
-- calculate the current year ($currentYear)
-- determine the year of the database record ($yearOfDateFromDatabase)
-- compare the current year to the year of the database record

You need to repeat this algorithm for the current day. Here is how I would find the current day:

$currentDay = date("d m", $now); // $now is already defined as the current timestamp

This will make $currentDay the following string for today's date (in Australia anyway): "31 12".
So then you will need to use $airdate to find the day of the database record and compare it to $currentDay.

As an aside, the date 1st January, 1970 at midnight is known as the Unix Epoch. PHP Timestamps are the number of seconds since then, so if you see that date in your output it generally means that your date function has been called with a very low timestamp (the second parameter in the call).

darkagn 315 Veteran Poster Featured Poster

It's a bit hard to tell from the code you have posted. Do you have code for the classes in question that you can post?

darkagn 315 Veteran Poster Featured Poster

Hi snarb,
I can't think of any languages that can't do what you are asking. The functions that you require are fairly basic. Just about any of the modern languages will do. It really depends on what else you require from your programs. For example, if you require a language that uses low runtime memory, perhaps C would be a good start. If you require a language that can be run on any platform, try Java. If all you require is what you have already specified then literally any language will do.

darkagn 315 Veteran Poster Featured Poster

Hi snarb and welcome to DaniWeb :)

Your criteria are a little vague.

-Send cursor to set coordinates and click -> not sure what you mean here.
-Copy and store information -> if you mean permanently, then you need a language which can either write to a file or to a database. That is, nearly every language available. If you mean just while your application is running, then every language available.
-Perform calculations (multiply, divide, etc.) based on information that it gathers -> every language I can think of can do this, these are fundamental functions of a computer.

darkagn 315 Veteran Poster Featured Poster

Ah ok, that makes sense niek_e. Thanks for the info.

darkagn 315 Veteran Poster Featured Poster

I'm no expert on bat files, but I would suggest changing the line that reads: java -Xmx500M -cp .;./classes/; server to: java -Xmx500M -cp .;./classes/src/; server and see if that fixes your problem.

darkagn 315 Veteran Poster Featured Poster

Simple example:

static int MAX_TESTS = 5;
int test = 0;
boolean result = true;
int something = 6;
while(test < MAX_TESTS && result)
{
  result = (something > 7);
  test++;
}

EDIT: Basically, the while loop takes a boolean condition. This can be the result of a single boolean method or evaluation, or multiple boolean results and'ed or or'ed together (or any other boolean arithmetic).

darkagn 315 Veteran Poster Featured Poster

Why not just do:

if(strlen($str) > 25)