The Diamonds 15 Newbie Poster

I'd suggest to loop through duration minutes and calculate the cost minute by minute, I've got excited an tried it myself.. it works just fine.

The Diamonds 15 Newbie Poster

Hi,

I can't give you a full answer since you didn't post your full code, but I can give you a few advices that would help you figure out the issue in your code.

In your php code, I suppose that you are using 'getWinesByDescription' to get an array of class 'wine' and will give you full list by default if you don't pass params to it.

I also assume that "wineID" & "description" are both properties in the class "wine".
In that case your 'foreach' loop should be something like :

foreach ($wineListing as $item) :
  echo "<option value='" . $item->wineID ."'>" . $item->description ."</option>";
endforeach;

Now, let's move to the javascript part, you can't select more than 1 item at the same time, so if you want to show the description of the selected item in 'results' span you can use code similar to:

$("#wineNameSelect").change(function(){
  var selected = $(this).find('option:selected');
  console.log(selected.text());
  var content = selected.val() + ": " + selected.text();

  $("#results").html(content);
});

You didn't post your Ajax part or the form submit part, if you need more help please don't hesitate.

The Diamonds 15 Newbie Poster

Hi,

You need to get the parameters for post params before you can use them in your email template.
Suppose that you have {name, email, order, subtotal, promo, tax, shipping, total} fields in your form, you need to write code like below before making MAIL call :

my $query = new CGI;

my $name = $query->param('name');
my $email = $query->param('email');
my $order = $query->param('order');
my $subtotal = $query->param('subtotal');
my $promo = $query->param('promo');
my $tax = $query->param('tax');
my $shipping = $query->param('shipping');
my $total = $query->param('total');
The Diamonds 15 Newbie Poster

Hi,

After first '.pager' click, you're deleting all table contents including '.pager' elements which have event 'click' registered to it, then you're creating new '.pager' elements.

Remeber that "$(".pager").click(function (evt) {" registers the 'click' event first time the page loads and won't work on elements that will be created later on.

To fix that, I'd suggest that you create a seperate function and register 'click' event every time you create new '.pager' element.

Something like:

function pagerFnc(evt) {
//alert(evt);
$(".loading").css("display", "inline");
var pageindex = $(evt.target).data("pageindex");
$("#CurrentPageIndex").val(pageindex);
var CurrentPageIndex = pageindex;
var PageCount = '@info.PageCount';
var PageSize = '@info.PageSize';
var SortDirection = '@info.SortDirection';
var SortField = '@info.SortField';
//evt.preventDefault();
//$("form").submit();
$.ajax({
url: '@Url.Action("JobsServiceProviderIC", "PostWork")',
type: "Post",
dataType: "json",
data: { CurrentPageIndex: CurrentPageIndex, PageCount: PageCount, PageSize: PageSize, SortDirection: SortDirection, SortField: SortField },
success: function (data) {
$(".loading").css("display", "none");
//alert(data.length);
$("#tblJobs > tbody").html("");
if (data.data.length > 0) {
for (var i = 0; i < data.data.length; i++) {
tr = $('<tr/>');
tr.append("" + data.data[i].JobTitle + "");
var SDate = new Date(eval('new' + data.data[i].StartDate.replace(/\//g, ' ')));
var formattedSDate = SDate.getMonth() + 1 + '/' + SDate.getDate() + '/' + SDate.getFullYear();
var EDate = new Date(eval('new' + data.data[i].EndDate.replace(/\//g, ' ')));
var formattedEDate = EDate.getMonth() + 1 + '/' + EDate.getDate() + '/' + EDate.getFullYear();
tr.append("View");
$('#tblJobs > tbody').append(tr);
}
tr = $('<tr/>');
tr1 = $("<td style='text-align:center;padding: 0px !important;' colspan='9'>");
tr2 = $("<ul class='pagination' style='margin: 10px 0;'>");
for (var i = 0; i < data.PageCount; i++) {
if (i == data.CurPageIndex) {
tr2.append("<li class='page-item active'><span class='page-link'>" + …
The Diamonds 15 Newbie Poster

I can see that you're trying to dump user data into a file then compress it for faster upload, but I don't see you do the upload, that's why I don't understand what progress are you calculating.

I'm not familiar with reaching Mysql database in PHP through SSH, but I suggest that you use CLI stream, see this link here.

The Diamonds 15 Newbie Poster

Hi,

I can't see how your code would work, I think you've missed couple of somethings.

As I saw on many websites, you need to use the function "ssh2_exec" instead of "exec" and you need to run the commands one by one.

Also, in your case you can't use the command:

$progress=mysql_affected_rows(); // line 38

because you're not managing the mysql connection by php.

For more info about ssh connection try this link and search for "Great! PHP supports SSH - time to code" to skip server configurations.

The Diamonds 15 Newbie Poster

Hi matutuedwin and WELCOME to Daniweb!

You can achive this, simply, by linking two pages and when the user clicks on the link the browser just opens the required page.. A better way is to use Ajax to retrieve the data in real time without making the browser to load new page.

The Diamonds 15 Newbie Poster

Hi,

You're doing the quotes wrongly, try this:

echo "<tr><th><a href='#' onclick='sort($order)'></a></th></tr>";
The Diamonds 15 Newbie Poster

Yes, you're right that is another problem.. I didn't notice.

The SQL function count doesn't take two column names. try to use one column name or 1 or * as an argument for the function like this:

$q = 'SELECT COUNT(state) AS c FROM all WHERE state = "' . mysql_real_escape_string($nc) . '" AND title = "' . mysql_real_escape_string($t) . '"';

Are you supressing the error messages? The interpreter should be giving you the message & line number of the error by default.

The Diamonds 15 Newbie Poster

Hi,

You have a problem at line 8; there is the = operator that shouldn't be. Just remove it and it will be fine.

The Diamonds 15 Newbie Poster

Hi,

I'm sorry that I can't help you with that converter thing.. but, why do you need one anyway?

If you have the the VB.Net code just compile it into .dll library then you can use it in your C# projects.

Just suggesting..
Regards.

The Diamonds 15 Newbie Poster

Hi,

Why wont you try to build a web crawler that visits a news website and fetchs some articles?

If you like the idea I suggest that you use HTMLAgility to crawle through the web.

Regards

The Diamonds 15 Newbie Poster

Hi,

Since you want to add properties to your interface, why don't you convert it to 'abstract class' instead?

The Diamonds 15 Newbie Poster

Salam Mohd,

I don't think it is a proper way to query from database every time the user changes the combobox values.

Instead you can use your SqlDataAdapter to fill a dataset, something like this:

DataSet myDataset = new DataSet();
SqlDataAdapter daSearch = new SqlDataAdapter("SELECT companyName FROM CompanyDetail", conn);
daSearch.Fill(myDataset);

After that you need to bind your third combobox to the resulted table inside 'myDataSet':

BindingSource  = new BindingSource();
thirdcomboboxBindingSource.DataSource = myDataset.Tables[0];

thirdcombobox.DataSource = thirdcomboboxBindingSource;
thirdcombobox.DisplayMember = "column_name"; // where 'column_name' is the name of the column you want to display in your combobox.

Final step is to filter the results based on the current values of the two comboboxs' values:

thirdcomboboxBindingSource.Filter = string.Format("ItemName = {0} AND CategoryID = {1}",
                                        firstcombobox.SelectedValue.ToString(),
                                        secondcombobox.SelectedValue.ToString());

Now you need to make you change the filter each time the first or second comboboxs inside SelectedValueChanged event handler.

Hope this would help.

The Diamonds 15 Newbie Poster

As far as I know it is just * and ? that can be used.

You're welcome.

The Diamonds 15 Newbie Poster

Thanks Dani for posting your solution :)

I found the same approach but with the use of hooks to register this function on "pre_system" here

The Diamonds 15 Newbie Poster

Yes, that's what I've assumed and I've wrote previous codes to use the same window not to open a new one.

Have you tried the code?

The Diamonds 15 Newbie Poster

You can match any file with any extension by:

*.*

If you want another pattern just give me the specification then I can help you.. I couldn't find any link that provide examples more than what I've already provided.

To be honest, this is not kind of big topic to cover.. you only need to understand the use of astrisk (*) & question mark(?) and everything would follow by its own. Write any combination and test it yourself, it is pretty much easy.

The Diamonds 15 Newbie Poster

So you're asking about files-names search patterns..

First there is the asterisk (*), it matches zero or more characters as follows:

  • (*.cs) matches all .cs files (e.g. myclass.cs, yourclass.cs)
  • (m*.cs) matches all .cs files that starts with letter m (e.g. moonclass.cs)

and so on...

Second there is the quistion mark (?), it matches zero or one character as follows:
- (???.cs) matches file names that have at most three characters before file extension (e.g. kbs.cs, mr.cs, p.cs)
- (s??p.cs) matches file names that start with letter s and ends with letter p and contains no more than four characters before file extension (e.g soup.cs, soap.cs, sp.cs)

The Diamonds 15 Newbie Poster

Hi Firozeh,

Adding to what ddanbe just said:
If you're searching for files in some directory, you can use the following:

System.IO.Directory.GetFiles("dire_path", "*.cs")

EDIT:
You can use two search patterns in the previous command:
*: Zero or more characters.
?: Exactly zero or one character.

More in the following link.

The Diamonds 15 Newbie Poster

Ok, when you use third number you need to add new fraction variable to hold the results of the second summation:

// third number
Fraction thirdfraction = new Fraction();
thirdfraction.WholeNumber = 2;
thirdfraction.Numerator = 1;
thirdfraction.Denominator = 2;

// second summation value holder
Fraction secondSum = new Fraction();
secondSum = firstfraction + thirdfraction;

// print the result
Console.Write("\n {0}/{1}", firstfraction.Numerator, firstfraction.Denominator);
            Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", thirdfraction.WholeNumber, thirdfraction.Numerator, thirdfraction.Denominator, secondSum.WholeNumber, secondSum.Numerator, secondSum.Denominator);
The Diamonds 15 Newbie Poster

Simply change the second number (lines 11-13):

secondfraction.Numerator = 1;
secondfraction.Denominator = 2;
secondfraction.WholeNumber = 2;

EDIT:
or create a third number with (2 1/2) value, you don't want to affect previous results.

The Diamonds 15 Newbie Poster

Hi,

The issue that you're facing is not a logical error in your "Fraction" class, it is just you didn't print the values properly.

Look at line 20 of your code:

Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator,secondfraction.WholeNumber, add.WholeNumber, add.Numerator, add.Denominator);

you print secondfraction.WholeNumber in field {2} instead of secondfraction.Denominator.. so the real number is (2 1/8) but you're printing it (2 1/2) and nothing wrong in the result (2 3/8)

Just change that line to:

Console.WriteLine(" + {0} {1}/{2} = {3} {4}/{5}", secondfraction.WholeNumber, secondfraction.Numerator, secondfraction.Denominator, add.WholeNumber, add.Numerator, add.Denominator);

Note: I didn't review all of your code.. I just checked that problem.

Good Luck!

ddanbe commented: Great help! +15
The Diamonds 15 Newbie Poster

Hi,

What libraries are you using?
I tried your code on latest Google chrome & Firefox browsers and I got an error "Media is not defined". So were is this 'Media' class?

The Diamonds 15 Newbie Poster

Hi snitcher,

Have you tried to run your code?

Ok, let's talk about javascript portion of your code:

    // javascript
    function sendpayment(){
        var payment = _("SendPayment").value;
        var touser =_("ToUser".value;
        if (payment == "") { 
            _("status").innerHTML = "Type Amount";} else {
                _("status").innerHTML = "Processing.."; }
                {
                var ajax = ajaxObj("POST", "payment.php"); 
                var response = ajax.responseText;
                    if(response == "success"){
                        _("paymentform").innerHTML = '<h3>Your Payment was Sucessful</h3>';}
                        else {
                        _("status").innerHTML = 'Your payment has not been sucessful';}
    }
    }
    ajax.send("payment="+payment+"&touser="+toUser+");

First:
Look at line 4, you forgot to close the parentheses.
Now look at line 17, you forgot to close the qoute.

Second:
Who told you that the use of the syntax _("element_id") is valid?
In javascript you would use document.getElementById("element_id") to get an element.

Third:
Don't name any of your functions a name you've given to an element.

Now your syntax is correct, you should look into the logic behind your code.. because it doesn't do what you intend to do.

The Diamonds 15 Newbie Poster

Sorry buddy, you lost me here. @.@

You want to display a text and a button and yet you don't want to open a window? How is that possible?

You need at least one window to accomplish that, don't you think so?

The Diamonds 15 Newbie Poster

Glad that you found it helpfull.

One last advice.. use standards. Unless standards don't meet your requirements (and I highly doubt that) you SHOULD use it.

I recommend you use ini or xml formats in your .proj file, here are some useful links:
- ini file
- ini file parser
- learn xml
- xml c# example
- Google is your friend

Wish you luck.

The Diamonds 15 Newbie Poster

Good news!
hmmm, let's see.. how do you open the file in your app? Can you share some code here?

An example of reading a file line by line and add each line to the listView would be:

System.IO.StreamReader sr = new System.IO.StreamReader("path_to_your_file"); // create stream reader

string fileName;
while ((fileName = sr.ReadLine()) != null) // read the file line by line
    projectRootNode.Nodes.Add(fileName); // add each line to the listview

sr.Close(); // close the stream
The Diamonds 15 Newbie Poster

Hi,

It has been long time since I used OpenGL, but I'll try to help.

First, if you know how to intilialize OpenGL properly try the following approach.. otherwise wait for someone else to help:p
Second, I didn't test the code and I'm not sure whether it works or not.

Add the following global variables (you can change the values as you like) :

int lineHight = 25; // the hight of each line
int lineMargin = 10; // the left margin for your text
int currentHight = 25; // the y position of the cursor.

Now in the main function and after OpenGL initialization enter the following lines:

glutKeyboardFunc(myKey); // register the key handler.
glRasterPos2f(lineMargin, currentHight); // set the cursor to the initial position.

And here is some definition of the key handler:

void myKey(unsigned char key, int x, int y)
{
    if (key == 13) // enter key
    {
        currentHight += lineHight; // change cursor y position
        glRasterPos2f(lineMargin, currentHight); // jumb to next line

        return;
    }

    glColor3f(0.0, 0.0, 1.0); // text color
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, key); // print the color
}
The Diamonds 15 Newbie Poster

Hi,

Can you be more specific were exactly you're struggling?

I've just looked into TreeViewer and I found it straightforward, here is what I've tried:

string[] files = new []{"file 1", "file 2"}; // files array that needs to be read from a file

TreeNode projectRootNode = treeView1.Nodes.Add("project_name"); // create root node of the project

// filling the project root node branch with the files
for (int i = 0; i < files.Length; i++)
    projectRootNode.Nodes.Add(files[i]);

You didn't say much about the (.proj) file although your thread title is all about it. How you manage that file? What type is it (e.g. xml)?

The Diamonds 15 Newbie Poster

Hi,

You need to use EditedFormattedValue instead of FormattedValue.

Private void LastColumnComboSelectionChanged(object sender, EventArgs e)
{
     string itemValue = GridSellProducts.Rows[GridSellProducts.CurrentCell.RowIndex].Cells["Item"].EditedFormattedValue.ToString();
// more code   <--- null value shown here always
}

Appearently, the cell value would be null while in editing mode.. see more about FormattedValue & EditedFormattedValue here

One more thing, why didn't you use sender object inside the handler method?
e.g:

Private void LastColumnComboSelectionChanged(object sender, EventArgs e)
{
    if (sender is ComboBox)
    {
        ComboBox cbox = sender as ComboBox;
        string itemValue = cbox.SelectedItem.ToString();
    }
}

Good luck.

The Diamonds 15 Newbie Poster

Hi,

Most likely, the form is not closing when you hit "X" button because you get an exception inside Form1_FormClosing.

I suggest you call Form1_FormClosing method explicitly while the app is still running to see what type of exception you get. You can just drop a new test button and call the method "onClick" of that button. You may use the following line to call the method:

Form1_FormClosing(this, new FormClosingEventArgs(CloseReason.None, true));

Hope this helps.

The Diamonds 15 Newbie Poster

Ok, what you have is the redirect-code that you need to put in the page you submit the data to.
For instance, you've used the following code in the registeration page:

<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">

The form data will be submitted to the page provided in the "action" parameter (which is the value of $editFormAction).

Suppose that ( $editFormAction = 'http://www.example.com/register.php?do=register'; )
Now you need to put your code in 'register.php' page something like the following:

<?php
/***
 * Page name: register.php
***/

    if (@$_GET['do'] === 'register')
    {
        // put data validation code here...

        // put the registeration code here...

        // put redirect-code here, you can use your code or the following code:
        $redirectPage = 'http://www.example.com/homepage.php';
        header ("Location: $redirectPage");
    }

?>

Regards,

The Diamonds 15 Newbie Poster

Hi,

Why don't you put a simple redirect like the one below in the page specified by "$editFormAction" variable?

header("Location: http://your-homepage.example.com/");

Note: header changes, and the line above of course, should be ordered before submitting any output to the client.

The Diamonds 15 Newbie Poster

Do you understand what variables are?

Let's put it in different way, do you know what first line of the code means?

float price=56.95;
The Diamonds 15 Newbie Poster

I know that this thread is a little bit old, hope I could help.

You could use a GET parameter to specify what are you displaying like this:
TeamA.php?do=viewteam&id=$some_team_id

Now, inside "TeamA.php" check for the new parameter and act accordingly, you do something like:

if(@$_GET['do'] == 'viewteam')
{
    $team_id = @$_GET['id'] or die('No team id was specified');
    // fetch players, display some data.
} else
{
    // your code for displaying the team list goes here.
}

Salam