pty 882 Posting Pro

And the moral of the story is, don't try to join tables using manually-entered string/varchar fields. It just won't work. Some people will enter their name as 'Timothy' in some forms, 'Tim' in others and ocassionally 'Timmy'.

Your user table should have a automatically incrementing numeric primary key. Your tracker should have a field called user_id, and you should set up a foreign key between those two tables.

Then your query would be sensible:

select
    t.id,
    t.date_implemented,
    u.name,
    t.comments

from
    tracker t
inner join
    users u
        on t.user_id = u.id
where
    t.scheduled_date_start between :d1 and :d2
and
    u.username = :uname
    -- or if you prefer, u.id = :uid
pty 882 Posting Pro

I don't really understand the question, but if you mean you want to display code with syntax highlighting (rather than edit it, in which case rproffitt's answer is correct), then there are a few libraries for this, namely rainbow and highlight.js.

pty 882 Posting Pro

This looked interesting so I had a go. Did it in Ruby so it wouldn't be of use to anyone with Java, C or C++ homework :)

puts "enter a number:"
number = gets.to_i

# calculate the dimensions of the square
length = ((number-1) * 2) + 1

# create an empty set of nested arrays of the correct length
square = Array.new(length, Array.new(length, nil))

# loop through the rows...
(0...length).each do |row|
  # ...and the cols
  (0...length).each do |col|

        # calc the min distance from each vertical and
        # horizontal edge, and set the value of the cell
        # to the smallest (which we'll increment by 1 to
        # adjust for zero indexing)
        square[row][col] = [
                [row, ((length-1)-row)].min,
                [col, ((length-1)-col)].min
        ].min + 1

  end

  # we're done with this line, pad and print it!
  puts square[row]
        .map {|n| n.to_s.ljust(2) }
        .join(",")

end

Screen_Shot_2017-08-24_at_16_36_46.png

pty 882 Posting Pro

It's annoying when people ask a straight up SQL question and wrap everything in $LANGUAGE.

To cut a long story short, what you need is a join.

pty 882 Posting Pro

Easy to forget how much power you have with the Unix toolbelt at your fingertips.

Screen_Shot_2017-08-21_at_15_49_23.png

rproffitt commented: Toolbelt, power? Batman using the force? +12
pty 882 Posting Pro

Nobody's going to try and decipher/run all that code. What exactly is the problem? Try creating a JSFiddle or something.

pty 882 Posting Pro

Why are you mixing PHP and Javascript up like that? And why are you using document.getElementByID? Also, putting spaces in id attributes is invalid.

Clue, just use PHP for this, perhaps a case statement:

switch (true) {
    case $count <= 6:
        $trend = 'super-hot';
        break;

    case $count <= 4:
        $trend = 'hot';
        break;

    case $count <= 1:
        $trend = 'new';
        break;

    default:
        $trend = 'lame';
        break;
}
pty 882 Posting Pro

Still waiting for links UI. For a bit of entertainment I looked up some amazing contributions UniqueIdeaMan has made to the web. Here's a great one:

Problem is, googling brings out forums and forums are full of amateurs too with amateurish samples

So, let's stop helping him, clearly we're too amateurish.

On a brighter note, here's another person hitting the nail on the head.

Jesus Christ, dude. You have no ****ing clue what you are doing and just stabbing your **** around hoping to hit something. You're submitting your form using GET and then looking for POST. Do you even have an idea what those words mean? What's the difference between them?

The first ****ing thing you do is realize your IF condition is failing if you don't see an echo result, so a normal person would take a look in $_SERVER to see what's going on. Well, a normal person would understand the basics by this point and know what POST and GET mean.

I know you're trying to learn, man, but you keep coming in here with syntax errors. You have no understanding of the basics.

pty 882 Posting Pro

I guess the beauty of markdown is that they can introduce it without it really affecting people who don't know or care about it.

The only markdown directives that might get in the way are, as you said, asterisks. I guess FB chat doesn't allow hyperlinks, headings or lists?

Anything that pushes Markdown more mainstream is good though. I started a business recently that's hopefully going to introduce non-tech people to Markdown, so the more exposure the better.

pty 882 Posting Pro

As a SQL contractor who comes across computer-generated messes like this rather frequently, I'd like to make a suggestion. Break this up into manageable chunks.

Here's your query with syntax highlighting:

Screen_Shot_2017-08-18_at_12_38_15.png

Attempting to do the case statements alongside aggregate functions with a load of joins and criteria is complex, but you can make it easier by creating an intermediate view that just does the select and case statements. Then, from that view, try to add your where clause. If that's all fine, now try adding the aggregates (sum and group by).

pty 882 Posting Pro

Since the odds are against me then how-about I pay you nothing if I lose but you pay me everything of your wealth if you lose ? Can you afford to bet like this ? I doubt it! Programmers in other forums have told me my ideas are good enough that they told me to shoot the top 10 sites in the world without talking too much. One even pleaded me to not reveal my ideas to the "clowns in the forum". Therefore, I have stopped).

You've not had any ideas though, because if you did you wouldn't be wasting your time arguing on here and you'd be building something. How about you point me at the homepage of one of your world beating projects, or to a patent detailing your top ten websites in the world ideas and then I'll apologise and admit that you're not a complete sham?

That sounds like a fair bet to me; and at this point I'd rather send you £100 than admit you have a clue.

So, the challenge has been set, UI has the simple task of pasting a URL to one of his creations, ideas or projects. If he can, all is forgiven and I'll let him continue conquering the world. If he can't, he's a phony.

pty 882 Posting Pro

I think you misunderstood UI

It's not the first time.

The general consensus is that UniqueIdeaMan's ideas are indeed unique. Unfortunately they aren't the good kind of unique.

This hasn't only been established here. Benanaman on codingforums knows the score. And Mittineague on sitepoint's forums goes as far as claiming that he is

missing a basic understanding of how things are.

As the old saying goes, there's no smoke without fire.

The nicest possible thing I can say about UI is that he is clueless timesink.

Dani commented: Please can we not resort to name calling. If you have nothing nice to say ... +0
pty 882 Posting Pro

I don't really suffer from insomnia but on occasions when I can't get to sleep listening to an audiobook for a few minutes usually makes me drop off. I think it's because it takes my mind off whatever it was on and, depending on the book, can be quite relaxing.

pty 882 Posting Pro

The classic examples go something like this

A self-driving car carrying a family of four on a rural two-lane highway spots a bouncing ball ahead. As the vehicle approaches a child runs out to retrieve the ball. Should the car risk its passengers’ lives by swerving to the side—where the edge of the road meets a steep cliff? Or should the car continue on its path, ensuring its passengers’ safety at the child’s expense?

They are the decisions that a tiny tiny tiny number of real people ever have to take, and usually happen so fast that people don't have time to weigh up the pros and cons.

pty 882 Posting Pro

In a few years it won't be uncommon to see driverless cars, every car company is pouring money into the problem; a mix of new players like Tesla and Google and older ones like Volvo and Nissan leading the way.

They already have hundreds of thousands of deathless hours under their belt and there is a roadmap (pun intended) for their progress.

As Dani says, some markets will be better-suited, taxis and logistics probably first.

I just want a car I can drive when I want to, but if I've had a drink or want a snooze I can tell it where I want to go and enjoy the journey as a passenger.

pty 882 Posting Pro

If you want to record customers without coding anything I'd just embed a Google form which would be linked to a spreadsheet on Google Drive. Yes, it's not an .xslx file and it doesn't react differently depending on whether the record already exists, but without building a proper website and writing some code, it's probably your best free option.

pty 882 Posting Pro

UI, I'm still waiting for you to share the details of your browser that is on the verge of setting the world on fire. Please can you post some information or I won't be able to remove you from the "bullshitting timewaster" category that you are currently a member of.

rproffitt commented: The last two set the world on fire showed me a hacked up firefox and chromium based browser. Both were infested with spyware. "It's my feature!" +12
pty 882 Posting Pro

I'm no PHP expert but shouldn't you be using SERVER_NAME, which is set in your webserver config?

pty 882 Posting Pro

So how come the link is marked as broken in my post? It works just fine.

https://help.qwant.com/help/overview/how-does-qwant-index-the-web/

The button to continue to the page should be more strongly coloured than the 'go back' button, too. Without having full trust in the 'is the link dead' checker, it's probably what most people want to do. If it is dead, they can just click back.

Gribouillis commented: The link worked once for me then mysteriously broke. +0
pty 882 Posting Pro

Qwant appear to have avoided some of the problems of building their own index and spider by using Bing. Still, it looks like a decent attempt at starting a search business and I wish them luck.

rproffitt commented: Why is using Bing struck out? +0
pty 882 Posting Pro

The main question is the amount of work it would take to build your own search engine

Building a search engine that works well would be incredibly complicated. Having it index a decent enough chunk of the web to be useful would be incredibly expensive. Getting people to actually favour your search engine over what's already out there would be almost impossible.

Keep in mind, when Microsoft needed a search engine they didn't build one from scratch. They already had the dated and not-very-successful MSN search, plus they went out and bought Powerset, Farecast and VideoSurf (probably others, too).

pty 882 Posting Pro

DuckDuckGo was launched in 2008 and is totally unaffiliated with Google. It's a shame Google is so entrenched but DDG is the best option around from a privacy point of view, results are of a decent quality and the UI is sensible and familiar.

pty 882 Posting Pro

Because, when I mentioned my browser somewhere (that revolves around my big ideas), one of the major international advertising company (from where the money would be coming from to the browser users) read the concept and told me not to go ahead publicising it anymore unless they get back to me.

So are you going to show us this world-beating browser?

rproffitt commented: Show me the money! (or broswer.) +12
pty 882 Posting Pro

Yes, you can definitely normalise further, like with the nutrients approach @diafol suggests, but you need to know the data before making a judgement on whether it's worth it.

There are advantages and disadvantages in cases like that.

ddanbe commented: Thanks for the advise! +15
pty 882 Posting Pro

Should I turn those into an extra column or should they become seperate tables?

They should definitely be stored in a separate table (say, food_category) and you should add an appropriately-named foreign key to the table you posted (let's called that food).

In SQL, you'd use a statement like this to create the tables with the foreign-key relationship in place, note the references line:

create table food_category (
        id     serial primary key,
        name   varchar(32) not null unique
);

create table food (
        id          serial primary key,
        category_id int references food_category(id) not null,
        name        varchar(32) not null unique,
        calories    numeric,
        cholesterol numeric,
        sugar       numeric
);
pty 882 Posting Pro

On another note, this is where the StackOverflow 'style' of questions and answers, with plenty of non-nonsense moderators, works well.

Homework questions like this are good for nothing. If the student can't be bothered to formulate a sensible question they are weakening whatever community is left and making it more difficult for any potential non-chump users to find something worth reading.

If someone has made an effort and posted some code that's stripped down to the essentials and well-formatted, I'm more than happy to go out of my way to help. When it's a case of

NEED STUDENT ATTENDANCE SYSTEM PLS HALP

Yeah.. no.

As someone of Indian descent, it's pretty embarrassingly focussed, too.

pty 882 Posting Pro
Grade F: rahul_63
pty 882 Posting Pro

For every image you want to store a separate watermarked version of that image. So, you need a 'task' that runs per upload. For your already-uploaded images you need to also be able to run that task.

In Rails, let's say you have a class called Image with method generate_watermark

class < ActiveRecord::Base

  after_save :generate_watermark, if: :image_changed?

  def generate_watermark
    ...
  end

end

So, this method is called every time the image is changed. Easy. Now, for your backlog you need to call this method for every Image that has no watermark. Fire up a Rails console:

Image
  .where(watermark: :nil)
  .each(&:generate_watermark)

Easy, huh? You'd use the same approach in Laravel.

pty 882 Posting Pro

Quite an easy process. Just create a semitransparent watermark, find an image, add the watermark to your image and voila, you're done!

pty 882 Posting Pro

Back in 2012, I once built a .exe bot that finds you WP blogs that still have their commenting section open and then posts your comment.

Well done, your posting bot has obviously evolved to posting to forums and ever since you added the Rambling::Bullshit module and pointed it at daniweb.com it's gone from strength to strength. Keep up the good work, with all your amazing ideas you're clearly destined for the top.

pty 882 Posting Pro

I'd start by learning Java. Then SQL. When you've learned Java and SQL, then learn HTML. Now you've mastered those relatively simple subjects, just learn all of the glue that connects them together. Once you've done that, it's quite simple:

Your attendence is probably represented by a join table; a student attends a lesson. so your attendance table will contain student_id and lesson_id.

Now, on your HTML form you should generate a list of checkboxes for every student who might attend the class (probably based on their subject and grade, or whatever). The checkbox's value should equal the student's ID:

<input type="checkbox" name="attendance" value="2345"/>

When the form is submitted, only the checked checkboxes that are checked (i.e. those who have attended the lesson) will be included in the form data. Save each of the IDs you recieve as a row in the attendance table. Easy.

pty 882 Posting Pro

You can't create a table if a something with the same name already exists. If you have created it in error and it doesn't contain any important data, drop it.

drop table PO;

Now your create table PO ... command should work.

pty 882 Posting Pro

Nope, FINDSTR only returns whole matching lines. You're best creating something in Powershell to return only what you want.

pty 882 Posting Pro
pty 882 Posting Pro

If you're teaching someone C# as their first language, Visual Studio makes sense - it's an excellent environment all round and providing everyone's using Windows it makes sense to use it.

For people new to programming, though, I'd start with something more expressive. Incidentally, omni-completion (aka intellisense) has been present in just about every half-decent programming environment since the 80s. Here it is in Vim with Python.

pty 882 Posting Pro

Unfortunately, MySQL doesn't support Window Functions, which make this type of query much simpler:

select rank(), pos, performance, wind, athlete
over (
    partition by athlete, wind
    order by pos, performance
)
pty 882 Posting Pro

Another advantage of Python (and other interpreted languages) is that you can learn the syntax much more quickly and easily while using a REPL. For those who don't know, you can just type in code and it evaluates it and prints the result:

>>> colours = ["red", "yellow", "pink", "green"]
>>> for colour in colours:
...     print(colour)
...
red
yellow
pink
green

If you make a mistake, you'll see it as soon as you hit enter.

>>> for colour in colours:
...     print(uh_oh)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'uh_oh' is not defined

For people learning to code, this is way more intuitative and less frustrating than the way I learned many years ago; the feedback loop is much tighter and there isn't much that can go wrong inside a REPL, you don't have to take the extra steps of learning to use a compiler and a shell, troubleshoot non-executable files and permissions and other things that we don't think twice about but trip up newbs.

pty 882 Posting Pro

Python is a solid first choice, it's really easy to get up and running, it's very sensibly designed and has plenty of libraries to choose from when you start doing more advanced things.

pty 882 Posting Pro

To cut a long story short, you don't want to connect to the database directly, you want to build an API that sits in-between. Let the API service talk to the database and communicate with the API via HTTP calls or some other protocol.

pty 882 Posting Pro

The problem looks like it's the quote symbol on your require line, require ‘watir’.

In Ruby, this needs to be either a standard ' or " pairing. If you really want to you can use percent string syntax, in therequire %q{watir} style, but in more than 14 years of Ruby I have never seen that syntax used in a require statement.

In short, you'll have more luck with require 'watir'.

pty 882 Posting Pro

I'd start by getting someone who speaks native English to proof-read your text. I'd also drop the name Microsoft from your company name, it's likely to make potential customers think you're a scam outfit. Get rid of the obviously fake customer reviews and dodgy stock photos.

Think about what you are actually trying to provide and make that clear on your site. Summarise it in 3 sentences and throw away everything else.

Getting backlinks by posting useless questions in other support forums and having the URL in your sig isn't going to do you any good in the long run, I'd nip that in the bud.

pty 882 Posting Pro

Using tables for borders like that is no longer required, it's very brittle (as you've found out) and unnecessarily fiddly.

Drop shadows can be implemented with a single line of CSS:

.card.login-form {
  margin-top: 8rem;
  box-shadow: 6px 6px 66px 6px rgba(0,0,0,0.39);
}

Here's how your login form would look using a modern CSS framework (Bootstrap, here). Code is here. Screenshot below:

Screen_Shot_2017-06-21_at_11_46_10.png

pty 882 Posting Pro

I don't envy the task ahead of you Dani. There just isn't the enthusiasm there once was.

Tech support has largely been supplanted by stackoverflow, the social/discussion aspect by Reddit, Facebook, etc.

Maybe putting DW on ice and concentrating on Dazah making inroads into its intended market is best. The idea sounds like it could work and things that grease the wheels of commerce tend to, but without a solid example of a market where it's actually connecting people I think it's going to be an uphill struggle.

I get the impression (and would bet you agree) that the current users of Daniweb, the fifteen or twenty regular posters and the people needing homework help aren't the cohort you need to be targetting.

diafol commented: Clear thinking +0
pty 882 Posting Pro

You could always switch to a language where indexing starts at 1. FORTRAN, Lua, Pascal and Smalltalk to name a few.

rproffitt commented: Oh Pascal, where I spent too much time. +12
pty 882 Posting Pro

There are browser addons that do this automatically. Not the perfect answer, I know, but might come in handy.

pty 882 Posting Pro

What's APACHE_RUN_DIR set to? It will be defined elsewhere in your config

pty 882 Posting Pro

So you're building an OS and an IDE but the contents of a project file are confusing?

Just do yourself a favour and use something built by experts until you see a shortfall that you'd like to address.

Note, I'm not saying don't build an OS, an IDE or a language, but don't try to do all three at once unless you are Fabrice Bellard.

ddanbe commented: Nice! +15
rproffitt commented: That's Fab! +12
pty 882 Posting Pro

Or, add a fulltext index to your table (across all the columns you care about) and use match (cols...) against syntax.

seularts commented: This did the trick. The stupid script that generated the table with its content is not all that retarded because it had added fulltext indexes! +3
diafol commented: Good +15
pty 882 Posting Pro

You can use three columns, just simplify your HTML a bit. See this

pty 882 Posting Pro

Just find the ban hammer.