Traevel 216 Light Poster

I have a code which is lc.runlight();

It has no parameters. public void runLight(int numCycles,int sizePerCycle) requires two integers.

I have looked through this and can't really see which section would help me

Start at the top, read until you're at the bottom. It's a good tutorial telling you exactly how to create different Dialogs, including the one you need for your assignment.

Traevel 216 Light Poster

Regardless of Entity Framework or your data model, the select query could be something like:

SELECT expenseCode.ExpenseId,expenseCode.Cost,expenses.ExpenseType FROM expenseCode INNER JOIN expenses ON expenseCode.ExpenseId=expenses.Id;

Which you can put in a view if you don't want to have this query in your code.

Though I believe Entity Framework automatically links tables (with foreign key relations) for you. You can access one through the other and vice versa through the database context.

"is expensesID value 4? If so it's food so get the cost and display it in the food field"

What if you added an extra expense type? You'd add a new input manually? Your table structure suggests you intend a dynamic expense type, but the code would prevent such behaviour again if you used manually defined inputs.

Traevel 216 Light Poster

I don't know what you have and I don't know what you want, so I can't help you with anything other than general usage.

$("#myTextbox").focus(); will set focus to an element with the id myTextbox. Be sure to call it after the elements have been created, for instance by using:

$(function(){
    $("#myTextbox").focus();
});

On a side note, this has nothing to do with PHP.

Traevel 216 Light Poster

"Focus on a textbox while moving to the next textbox if it's empty"

You mean as in focus on the first non-empty textbox?

while moving to next field

Moving as in moving focus?

You'll have to be more clear.

You can use .focus() to set focus, or .focusin() and .focusout() for even more freedom.

Traevel 216 Light Poster

Several things I'm noticing:

You seem to be mixing JavaScript and HTML, some of it might never run.

 <input id="rNo" type="radio" name="YesNo" value="No" onclick="this.form.submit();">

<input id="rYes" type="radio" name="YesNo" value="Yes" onClick="location.href='http://localhost/home/calcprint.php';"

Both those inputs suggest the form should be sent as soon as someone clicks on them. The second one is missing a closing >.

<input name="btnEquals" type="Button" value=" = " onclick="Operation('=')"></TD> 

Apart from there not being an opening <TD> or <table> anywhere, you're calling a function called Operation('=') the code of which you did not post.

function OnCalc(value1,op,value2,total)
{
/* var expression = purpose + value1 + op +value2 +'='+ total;
alert(expression); */
}

This function is empty and never being called. Your PHP is also expecting purpose for its INSERT query, you're not passing it to this function, nor creating it here.

The function is parseFloat and not parsefloat.

 {value1.value = parseInt(value1.value)}
else
{value1.value = parsefloat(value1.value)}

Not sure what that is supposed to do, it just starts. There is no if. Also, parseInt won't fail, it will just put NaN in value1.value. Which I don't think is what you think it is (value1.value is probably not the form field).

if (value1 == parseInt(num))

What is value1 and what is num?

You do not have a submit button as far as I can tell and you are not posting the form in any other way than by those radioboxes.

In your PHP, you are not fetching …

Traevel 216 Light Poster

If the container has a different ratio than the image then either the div will have whitespace or the image will be stretched yes. I changed the .one class to a #one id in your example by the way. I pasted the code I had into your fiddle.

You could consider cropping if it really needs to fit the container perfectly. But you won't know if important parts get cut off.

Traevel 216 Light Poster

Are you still in a position to change the table structure? What you are describing sounds like a one-to-many (or many-to-many) relationship between speakers and clients. You could avoid saving ID's in a string by using a different structure.

client       speaker             speaker_client
--------     --------       ------------------------
id name      id name        client_id    speaker_id
1  jack      1  jason       1            1
2  john      2  jay         1            2

You could then request the values of speaker with something like:

SELECT * FROM speaker WHERE speaker_client.speaker_id = speaker.id AND speaker_client.client_id=1;

Even easier if you create a TABLE VIEW from a query like this, then you could retrieve them using something as simple as:

SELECT * FROM speaker_view WHERE client_id=1;

The advantage of this table structure is that you could include more information, for instance "topic of discussion" that is attached to the speaker/client relation.

Is there an alternative to calling a table from an array of items or something

You could use the IN clause.

SELECT * FROM speaker WHERE id IN (1, 5, 8);

With the above table structure you could also choose for an IN clause instead of the AND to retrieve speaker values, something like:

SELECT * FROM speaker WHERE id IN (SELECT speaker_id FROM speaker_client WHERE client_id=1);

This way you would not need to retrieve and split the 1, 5, 8 first.

Traevel 216 Light Poster

LOL

I just figured it out. So I just solved my own question.

Guess which question about you I just solved? I now know you were telling the truth there. You did only spend half an hour learning Java.

It shows.

Traevel 216 Light Poster

Are you hosting it yourself? Check ports and whether the host allows remote access to a MySQL database. Also check you have the proper user privileges in place (GRANT).

Traevel 216 Light Poster

How accurate do the address coordinates need to be? You could download an open source dataset.

Traevel 216 Light Poster

I want to debug this, so I can learn how the debugger works.

"The debugger"

You might want to specify what IDE you are using next time, there's not just one "debugger". For NetBeans it should be ctrl+F5 yes, perhaps try one of the other ways.

Traevel 216 Light Poster

No worries, mods cough Americans cough are sensitive.

But more likely they're just worried Google will make a fuss.

he expected more in the screen shot
Perhaps for question purposes you could move some images around. Different ones with the same name so you won't ruin code or anything.

Traevel 216 Light Poster

This is my code.

Well there's your problem.

Also, no idea which image you mean. You want to show a product image when you select a specific category? There will be multiple.

Traevel 216 Light Poster

Some things I'm noticing:

There are no test cases (Unit Tests), but I'll assume you meant "it doesn't work".

{import

Is that just a pasting error? Can't have a { there.

public class Assignment2

It needs to go at the end of the above line instead.

int minint = 100 ; so if I enter 101 and 102 as numbers? Which one will be lowest? Consider Integer.MAX_VALUE.

You have a do-while inside of a while that are both checking for that condition. Either use a while or a do-while, you'll have to think about which one to use in this case. Keep in mind the difference between the two, what's special about do-while over while. Hint: where does the check take place.

Traevel 216 Light Poster
.content1{
    opacity: 0.4;
    filter: alpha(opacity=40);
}

The lower the number, the more see through. The second line is for IE compatibility. You can add it to the existing .content1. If that's not the right div, inspect again and find the right one, then put the lines in its css.

One personal tip, as you progress with your project you might want to keep an eye on how far the screenshots go in terms of what could be seen by minors. From what I've gathered over the years here there are a lot of students looking around for homework help and all. Not really sure what age they all are, but just in case.

Traevel 216 Light Poster

I thought: given an arbitrary width (whether it comes from a div, canvas or in my example 200) adjust the height proportionally, write it to a canvas of the same size so it can be exported as PNG in the new size.

Just out of curiosity... why aren't you just using CSS to size the image to fit the container?

The image has to be written to canvas if you want to export it to PNG using canvas.toDataURL("image/png"). Can CSS influence an image inside a canvas? Perhaps set the height/width of the image with CSS, then retrieving the width/height to write it on the canvas. But will that work with auto and %? No idea, just pondering as well.

The image is not fitting the width nor the height of the container

Well no, that seemed something you could do, alter the 200 to whatever size the div is. But, I realized height would never be adjusted in my example so I dove in one more time.

        var canvas = document.getElementById('myCanvas');
        var container = document.getElementById('one');
        var context = canvas.getContext('2d');
        var imageObj = new Image();
            imageObj.src = 'darth-vader.jpg';
            imageObj.onload = function() {
                var size = fetchSize(imageObj.width,
                                     imageObj.height,
                                     container.offsetWidth,
                                     container.offsetHeight);
                canvas.width=size[0];
                canvas.height=size[1];
                context.drawImage(imageObj, 0, 0, size[0], size[1]);
            };

        function fetchSize(w,h,max_w,max_h){
            var size = [w,h];
            var r;
            if(w > max_w){
                r = max_w / w;
                size[0] = max_w;
                size[1] = h * r;
                h = h * r;
                w = w * r;
            }
            if(h > max_h){ …
Traevel 216 Light Poster

I'm a thirteen year old programmer.

From your linkedin you posted on your profile:

2015-01-15--1421325895_590x143_scrot.png

You "enrolled" when you were 9? You'd think there would have been something in the news about that.

Regardless of the age (and truth), why hang around here asking if you're a genius, go build a space station or something. No one will question you if you're on the news floating around in space. But they will if you run around saying "I'm a genius right?" on a forum.

Traevel 216 Light Poster
if($image_width > $data3['maxwidth_bn'] || $image_height > $data3['maxheight_bn'])

That means:
IF the image width is larger than max_width OR the image height is larger than max_height, the image is too big.

Is it too wide? 597 is not larger than 1000, so no.
Is it too high? 424 is larger than 240, so yes.

If either one is true (OR) it will be too big.

Traevel 216 Light Poster

You could use MySQL's REGEXP to search for that pattern.

Traevel 216 Light Poster

And if you change $scope.contents to $scope.content?

Traevel 216 Light Poster

If I use

var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var imageObj = new Image();
    imageObj.src = 'img url snipped';
    imageObj.onload = function() {
        var width = 200;
        var height = imageObj.height * (width/imageObj.width);
        canvas.width=width;
        canvas.height=height;
        context.drawImage(imageObj, 0, 0, width, height);
    };

And remove the bottom:50px; from that css, I get:

2015-01-15--1421308160_636x334_scrot.png

If I then right click and "view image" it shows the image in a smaller version without the white space. Saving works too and produces a smaller image. You'll just need that export to png part (and add the image url I snipped). And perhaps fetch the image width from canvas.width instead of the other way around.

Not sure if the fiddle updated, but just in case.

Traevel 216 Light Poster

No, read it again. The other one of the two. You're on your own now though as far as I'm concerned. I'm not here to write your code for you, and I doubt others will. This is our free time. All you did was repost your original code.

Instead of wasting 7 hours on this, like you said, spend those 7 hours following tutorials and learn proper PHP CRUD. Find another one if you don't want to do the one I posted. But don't just order others to change your code for you.

If you're tired, go sleep. And again, better to waste 5 hours doing proper PHP/MySQL and start fresh than 5 hours trying to fix the wrong way of doing PHP/MySQL.

Traevel 216 Light Poster

You mean a partial view?

Include them with @Html.partial() in your cshtml (if you're using the Razor view engine anyway, not sure about the use with other engines). You can pass along the model as well.

You'll have to Google a bit or wait for someone more knowledgeable if you want more information on the matter though. It's been a while.

Traevel 216 Light Poster
$user_mBalance = getUserData('payCheck');

That is the balance of the current user, i.e. $total. Just do the exact same for the receiving user. Same query but with a different ID. That would be $total2. Then update it with howMuch and re-insert.

If I changed your code I'd have to rewrite every part because of the mysql. That's a bit much. You can follow this tutorial if you want to change it to a correct format.

Traevel 216 Light Poster

If you're new you should be willing to learn and follow tutorials. What's the point in one of us converting your format for you? You're not saying you're having a problem with a small part of the conversion, but with everything. How can we ever help with that, teach you PHP from scratch?

Using mysqli you could try something like:

$id = 5; 

$sql = "SELECT id, cat FROM articles WHERE cat = (SELECT cat FROM articles WHERE id = ? LIMIT 1)";

$stmt = $conn->prepare($sql);

if($stmt === false) {
  trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}

$stmt->bind_param('i',$id);

$stmt->execute();

$stmt->bind_result($id, $cat);

while ($stmt->fetch()) {
  echo $id . ' = ' . $cat . '<br>';
}

$stmt->close();

Which is all taken from that exact same tutorial. It should print all id's and cat's of the articles that have the same category as the article with id number 5 (this includes 5 itself). If you don't have articles, or categories or unique id's it will go wrong.

Also, it needs error handling, if you keep it like this things will hit the fan at some point.

Traevel 216 Light Poster

Where do you fetch $total2? It needs to be the amount already known in the database, so you need to fetch it with a query similar to $getUser_payCheck. But that's pseudocode I hope.

$getUser_payCheck = "SELECT `payCheck` FROM `users` WHERE `First Name`='$where'";

won't execute anything.

Traevel 216 Light Poster

Get the total for the receiver with a query (similar to line 14), then add the howMuch to total and do the update query (similar to line 25) again but for receiver.

Using mysql is bad though, you should switch to mysqli or PDO.

Traevel 216 Light Poster

Anything you can tell about the inner workings of that object?

Because if I try something like:

        var Object = function(){
            this.Status = {
                Name : "foo"
            };
        };
        var object = new Object();

        // prints foo
        console.log(object.Status.Name);

        object.Status.Name = "bar";

        // prints bar
        console.log(object.Status.Name);

Or

        var Object = function(){
            this.Status = new Status();
        };

        var Status = function(){
            this.Name = "foo";
        };

        var object = new Object();

        // prints foo
        console.log(object.Status.Name);

        object.Status.Name = "bar";

        // prints bar
        console.log(object.Status.Name);

Nothing seems the matter.

Traevel 216 Light Poster

Read Taywin's last part again:

I do not want to modify your script because it is using bad format already

If he gave you the answer before you modified the code to a proper mysqli or PDO format it would stay bad code. You might have your category issue fixed, but tomorrow something else will cause a problem, and the next day another, and so on.

His advice to fix the format of your code now while you're still working on the basics is one I fully agree with.

I suggest you rewrite your code from mysql syntax to mysqli syntax as the two are rather similar.

So replace mysql_query with mysqli_query and so on. Also, it would be safer to use prepared statements and not just put variables directly in the query. For a more in depth explanation on using mysqli you could read a tutorial.

From the tutorial:

$sql='INSERT INTO customers (firstname, lastname) VALUES (?,?)';

$firstname = 'John';
$lastname = 'Doe';

$stmt = $conn->prepare($sql);
if($stmt === false) {
  trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
}

/* Bind parameters. TYpes: s = string, i = integer, d = double,  b = blob */
$stmt->bind_param('ss',$firstname,$lastname);

/* Execute statement */
$stmt->execute();

See how that is different from what you have now. That is why an answer on how you have it now won't help you, or anyone else reading this post later looking for answers.

Traevel 216 Light Poster

A little more than that. The image has to be resized and drawn onto the canvas, then you can export the canvas to a data url with that function.

Perhaps these links will help:

resizing proportionally

drawing to canvas

I reckon a combination of those should do it.

Traevel 216 Light Poster

Well you should definitely use an UPDATE instead of a SELECT query then. Thing is, PHP runs on the server so you won't be able to fetch user input and deal with it on the same page. You're going to need a user part, with the form inputs and a PHP part that handles the variables and update the database accordingly. You could circumvent this by posting to the same page, but it will result in a "two page crammed into one" kind of file, which is harder to read and maintain.

I'd suggest to read a CRUD tutorial first and then post a more specific question should it arise. The reason for not changing the code you have now would be the mysql you're using, as it makes up the bulk of the logic. And the fact that you have no POST logic whatsoever yet.

Sometimes, how hard it may be, it's best to start over. Especially if it wouldn't take long to get back to where you are now, but using the right methods upon which you can expand.

Traevel 216 Light Poster

You should really consider abandoning the oudated mysql in favour of mysqli or PDO. If you make use of prepared statements you won't have to insert the parameters directly into the query, which is dangerous.

Regardless of that, where are you setting those $Business2 variables? The code you posted does not contain them.

And just to be clear, do you want to update the SQL table with data from the page or the HTML/PHP table with data from the database?

Traevel 216 Light Poster

That's because you used a 0 (zero) and not an O.

Traevel 216 Light Poster

Are you sure you are creating a new map each time?

Keep in mind you're adding a reference to the map, not a snapshot of the map itself. If you change the map the reference in the list will simply point to the changed version.

Traevel 216 Light Poster

You could create/resize it on an HTML canvas and export the canvas to PNG using canvas.toDataURL("image/png").

Traevel 216 Light Poster

You didn't get an answer in VB.NET and I doubt you'll get one in here. That's like asking how to build a car. Be more specific.

Traevel 216 Light Poster

By "fails", what do you mean?

What comes to mind is the blocking nature of an alert(). It blocks execution while awaiting your click. Removing the alert would remove the block.

It's going fine here in a test. It hides the divs, loads a text file and shows the div regardless of the alert being present.

Traevel 216 Light Poster

You could use RTP/RTCP over UDP for streaming. If memory serves me right VLC even has (some sort of) support for it.

Traevel 216 Light Poster

If you want to use it as a database, have you considered using sqlite?

From what I gather its usage is fairly straightforward in Python.

Traevel 216 Light Poster

using div css and php hahahaha , so much easy than using ajax

Yea, silly us for telling you to use this monster:

$.ajax({
    url: "whatever.php",
    type: "POST",
    data: { 
         id : 0,
         and : "whatever",
         data : "we",
         would : "want"
    },
    context: document.body
}).done(function(response) {
    $(this).html(response);
});
Traevel 216 Light Poster

I've merely dabbled in ASP.NET, wrestling with its quirks and most notably Entity Framework and the use of existing databases. It would have been nice if during my first steps I had known the darn thing added a pluralizing "s" to my non-english tables resulting in one of the most nonsensical data models I've ever had the horror.. I mean honor of designing.

Old personal frustrations aside, perhaps this recent post describing the setup of Identity 2.0 without Entity Framework (I'm assuming it's DB First since it builds on his previous post where he used EF and DB first with Identity 1.0) will be of some help for further research. It seems like a lot of hoops requiring lots of jumps to even get a barebones system going.

Good luck with your efforts.

PS bring an axe just in case

pritaeas commented: Thanks. +14
Traevel 216 Light Poster

You can't have multiple primary keys in a table, you can have a composite primary key in a table.

The use of multiple auto increment columns eludes me, they would all hold the same value as the others.

The intention of a Primary Key is to provide a unique identifier. You have that in the form of id. Why add more columns? You won't make it more unique that way. Furthermore, it is common practice that a Primary Key holds no meaning or information. Title and category hold information I assume. What if the title changes at some point? Your primary key would change. That is unwanted behaviour as the unique reference you once had is now invalid.

Traevel 216 Light Poster

Let me guess, self answer following shortly?

Traevel 216 Light Poster

This part session_start(); is done more than once, I see it on line 11 and 54 (might be even more, I didn't look further). It might also be done by parts above or below the part you posted. You can't do it more than once so remove all but the first occurrence (again, that also includes occurrences on other pages you may have included above or below the part you posted).

Traevel 216 Light Poster

But you would only need the id of the image you want to change then? Not get all the id's and override all of them with the new picture.

That looks like bootstraps popover, it contains the input I take it and then attaches it to the image rows?

You can find the popover that is currently visible using jQuery and then read the image id on the row the popover belongs to.

By default the popover should be in a div like <div class="popover more classes here" so you could find the active ones by doing $('div.popover:visible').

What might work even better, considering you're already passing the input element to the readURL function, is only to get the img that precedes the input, rather than all the images.

So something like:

    function readURL(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function(e) {

                $(input).prev("img.img-thumbnail")
                        .attr('src', e.target.result);

            }
            reader.readAsDataURL(input.files[0]);
        }
    }

Where $(input).prev("img.img-thumbnail") should find the thumbnail image that directly precedes the input field.

Traevel 216 Light Poster

What's the intended purpose? Are you trying to set multiple images to the same src given an input?

If so, the function I provided is a bit inefficient since it would read the same data over and over again for each img. The following would be better

function readURL(input) {

    if (input.files && input.files[0]) {
        var reader = new FileReader();
        reader.onload = function(e) {
            $("img").each(function(){
                $(this).attr('src', e.target.result);
            });
        }
        reader.readAsDataURL(input.files[0]);
    }
}

I don't know what you mean by the image being overriden as I thought that was the intention.

Traevel 216 Light Poster

No I think your images will not exist yet when you try to collect them using var imgs = document.getElementsByTagName("img");. It depends on where you placed that script block in the code.

Try

function readURL(input) {
    $("img").each(function(){
        var img = this;
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function(e) {
                img.attr('src', e.target.result);
            }
            reader.readAsDataURL(input.files[0]);
        }
    });
}

$("#file-input").change(function() {
    readURL(this);
});

You might have to use $(img).attr('src', e.target.result); instead though. I'm not 100% sure whether it will recognize the attr() without it. I can't test it for you at the moment.

Traevel 216 Light Poster

as this is to demonstrate and capture your understanding on the
subject matter.

Your understanding, not our understanding.

Read the rules. Do work first, then get help.

Free tip: Vogella tutorials.

Traevel 216 Light Poster

You're already using jQuery, have a look at the selectors it provides.

You could use $(img) to get all img elements. If you only want specific images you could give them a class and select on that using $(.class) or $(img.class). You could even use something like $(img[src*='album']) that checks the src attribute of all images for the occurrence of the word album.

You could even go old school and do

var imgs = document.getElementsByTagName("img");

for (var i=0;i<imgs.length;i++){

    var id = imgs[i].id;

    // etc
}

But using the selectors is no doubt easier.

Traevel 216 Light Poster

It specifies which sides (both) of the element may not be adjacent to previous floats.

Those coffee/phone boxes are floats.