phorce 131 Posting Whiz in Training Featured Poster

In order to achieved this, you, would have to use url re-write (like @Nichito pointed out)

You would still have your username.php which accepts the paramater (hh).

<?php

  $user = $_GET['username']; // Obviously with a bit more security 

  var_dump($user);

  ?>

Hope this helps

phorce 131 Posting Whiz in Training Featured Poster

Quick question, what text do you have to decipher?

phorce 131 Posting Whiz in Training Featured Poster

huuhaa

phorce 131 Posting Whiz in Training Featured Poster

Ok. Glad you sorted it out. Next time, be more specific in what it is you're actually trying to do!

phorce 131 Posting Whiz in Training Featured Poster

Right, show me (in your php file) how you're defining $url please. :)

i.e. The actual script!!

phorce 131 Posting Whiz in Training Featured Poster

It's unclear.

What your suggesting is that $url IS defined as a single variable, but has loads of values.. Almost to say:

$url = "www.google.com, www.yahoo.com";

Which, if this is the case then it's the wrong way to go around things.

I don't get what you mean "echo the variable within HTML" my example did that?

phorce 131 Posting Whiz in Training Featured Poster

Does it give an error?

use:

or die(mysql_error());
phorce 131 Posting Whiz in Training Featured Poster

No prblem :)

Please mark this thread as solved, and, give rep if you feel someone has helped you!

Goodluck with your coding/application

phorce 131 Posting Whiz in Training Featured Poster

Try this:

#include <iostream.h>
int main()
{
int d;
int i=0,n,j,b[100];
cout<<"\n Press 1 for Decimal to Binary converstion";
cout<<"\n press 2 for Decimal to Octal converstion ";
cout<<"\n press 3 for Decimal to Hexadecimal converstion";
cout<<"\n\nEnter your choice: ";
cin>>d;
switch(d)
{
case 1:
cout<<"\nEnter decimal number: ";
cin>>n;
while (n>0)
{
b[i]=n%2;
n=n/2;
i++;
}
cout<<"\nBinary is: ";
j=i-1;
for (i=j;j>=0;j--)
{
cout<<b[j];
}
break;
case 2:
cout<<"\nEnter decimal number: ";
cin>>n;
while (n>0)
{
b[i]=n%8;
n=n/8;
i++;
}
cout<<"\nOctal is: ";
j=i-1;
for (i=j;j>=0;j--)
{
cout<<b[j];
}

break;
case 3:
cout<<"\nEnter decimal number: ";
cin>>n;
while (n>0)
{
b[i]=n%16;
n=n/16;
i++;
}
cout<<"\nHexadecimal is:";
j=i-1;
for (i=j;j>=0;j--)
{
cout<<b[j];
if(b[j]<10)
{
cout<<b[j];
}
else
{
switch(b[j])
{
case 10:
cout<<"A";
break;
case 11:
cout<<"B";
break;
case 12:
cout<<"C";
break;
case 13:
cout<<"D";
break;
case 14:
cout<<"E";
break;
case 15:
cout<<"F";
break;
}
}
}

}

}

Indent your code, it's really messy!!

phorce 131 Posting Whiz in Training Featured Poster

You might have to cast the variables, by this, I mean specifically define the variable type. Look at this example:

<?php

    $budget_min = (int) 20; // CAST the variable (int)
    $budget_max = (int) 10; // CAST

    if($budget_min <= 20)
    {
        echo 'The budget is too small!';
    }else{
       echo 'The budget is  fine!'; 
    }

    if($budget_min > $budget_max)
    {
        echo 'The budget is higher than the max budget';

    }
    // Output:
    // The budget is too small!
    // The budget is higher than the max budget
?>

So in terms of your example:

$budget_min = (int) $_POST['budget_min']; 

And then you can even be more specific and go:

if(!is_numeric($_POST['budget_min']))
  die("Not a number");

Hope this helps, try clearing up what you want/need?

phorce 131 Posting Whiz in Training Featured Poster

Hey,

Look at this:

<?php

 $budget_min = 10;
 $budget_max = 10;

 if(!isset($budget_min) && strlen($budget_min) < 20)
 {
    // display the errror   

 }

 // Check if the value entered is numeric
 if(!is_numeric($budget_min))
 {
    // display the error

 }

 if($budget_min >= $budget_max)
 {


 }

?>

Hope this helps :)

phorce 131 Posting Whiz in Training Featured Poster

So you want the program to iterate until the user enter's quits?

If this is the case, just add a loop:

Before:
int choice = 0;

   while(choice != 4)
    {

And then close the bracket off at the end of the program:

}
phorce 131 Posting Whiz in Training Featured Poster

It would be this, surely?:

<?php
$url = "something"; // In my php files $url contain multiple values
?>
<html>
<td><input type="text" size="50" value="<?php echo $url; ?>"/></td>
</html>

Ohhhhhhhh!! You're talking about arrays! Apologies!

So you'd have a list of values:

<?php
   $urls = array('www.google.com', 'www.yahoo.com', 'wwww.website.com');
   foreach($urls as $url) {
     echo $url;

   }

   // output
   //www.google.com www.yahoo.com wwww.website.com 
?>

So in theory, it would be something like this:

<?php
   $urls = array('www.google.com', 'www.yahoo.com', 'wwww.website.com');
   foreach($urls as $url) {
     echo '<td><input type="text" size="50" value="' .$url. '"/></td>';

   }
?>
phorce 131 Posting Whiz in Training Featured Poster

Try this:

(save it as .htaccess) and make sure it's in the correct folder (like localhost, www etc.)

RewriteEngine  on
RewriteRule ^(.*)$ $1.php
phorce 131 Posting Whiz in Training Featured Poster

Apologies.

I purposly left out main, so, you need to include main..

int main()
{


}

As you had it before, just implement my code. :)

Kinda like this (NOT COMPLETE):

#include <iostream>
using namespace std;

int main()
{
    int choice = 0;
    int A[10][10],m,n,x,y,sum=0;
    //Create a Matrix 
    cout << "Enter number of rows and columns in Matrix A : \n";
    cin>>n>>m;
    cout << "Enter elements of Matrix A : \n";
    for(x=1;x<n+1;++x)
    for(y=1;y<m+1;++y)
    cin>>A[x][y];

        cout << "Please enter an option: \n";
        cout << "\t\t 1) Sum Row\n";
        cout << "\t\t 2) Sum Column\n";
        cout << "\t\t 3) Diagonal Sum\n";
        cout << "\t\t 4) Quit\n";
        cin >> choice;

        switch(choice)
        {
            case 1:
             for(x=1;x<n+1;++x)
             {
                A[x][m+1]=0;
                for(y=1;y<m+1;++y)
                A[x][m+1]=A[x][m+1]+A[x][y];
             }
            break;

            case 2:
             for(y=1;y<m+1;++y)
             {
                A[n+1][y]=0;
                for(x=1;x<n+1;++x)
                A[n+1][y]+=A[x][y];
            }
            cout << "\nMatrix A, Row Sum (Last Column)" << " and Column Sum (Last Row) : \n";
            for(x=1;x<n+1;++x)
            {
               for(y=1;y<m+2;++y)
                cout << A[x][y] << "     ";
                cout << "\n";
            }
            break;

            case 3:
              // diagonal sum
            break;

            case 4:
                // quite
                return 0;
            break;

            default:
              cout << "Option unknown";
            break;

        }

}

Hope this helps.

P.S. Indent your code, it's messy to read.

phorce 131 Posting Whiz in Training Featured Poster

Hey,

As far as I'm aware, extract data from a .pdf form is impossible in PHP.. Please see: http://stackoverflow.com/questions/7419236/how-to-extract-field-value-from-pdf-form-in-php

Which may offer some more help, there might be a platform that can do this.. I've never come across this though!

phorce 131 Posting Whiz in Training Featured Poster

Hey,

I'll give you an example.. Then you can just relevant insert the code where you need it.

int choice = 0;

    cout << "Please enter an option: \n";
    cout << "\t\t 1) Sum Row\n";
    cout << "\t\t 2) Sum Column\n";
    cout << "\t\t 3) Diagonal Sum\n";
    cout << "\t\t 4) Quit\n";
    cin >> choice;

    switch(choice)
    {
        case 1:
         // Sum row code
        break;

        case 2:
         // Sum col row
        break;

        case 3:
          // diagonal sum
        break;

        case 4:
            // quite
            return 0;
        break;

        default:
          cout << "Option unknown";
        break;

    }

Dunno if that will help you at all

phorce 131 Posting Whiz in Training Featured Poster

mhmh, just a suggestion.. But I don't code like you:

<?php

   $callsign = mysql_real_escape_string($_POST['CallSign']);
   $query = "SELECT * FROM users WHERE Callsign='$callsign'";
   $result = mysql_query($query);
   if(mysql_affected_rows() == 1)
   {
        $row = mysql_fetch_row($result);
        echo $row[0] . "<br>";

   }else{
     echo "That CallSign has been claimed Already!<br>";
     echo "<p><a href='register.php'>Return to Try Again</a><br>";

   }


?>

I don't see what the problem is? Maybe it's something to do with your database table, how the field name is or something!

phorce 131 Posting Whiz in Training Featured Poster

Hello!!

I don't know if I can offer much help, or, insight to this. You should think of the logic behind Programming as being:

"Anyone can code. Anyone can Google. Does that make you a Programmer? It's understanding the logic and given a task to solve and finding the best concept and solution that best fits the problem." - Phorce, DaniWeb 2012 ;)

I don't understand why they would go down the BASIC route, as it being so old! I converted some code from BASIC to C++ a few months back and the logic/syntax for it was horrible.

As in terms of topics, I imagine a brief overall logic:

OR, AND, NOT, GREATER THAN, LESS THAN (But might not be as basic). I guess it's just to try and make you think about the logic:

"How do I input and manipulate multiple numbers" and then someones logic could be to have a massive list of integer numbers whereas someone elses logic could be to create an array. (I guess)!

Hope this helps a tiny bit :)

phorce 131 Posting Whiz in Training Featured Poster

ete..
don't know this example make you clear or not.. sorry bcause dont know how to explain..
(-__-

Hey,

I'm pretty sure DaniWeb store their data inside a database!

I think what you're hinting, or suggesting is that you have data read in from Excel; which if is the case then you would parse the data in using XML and then you can then manipulate the data and then save it after the processing/manipulation. - Is this the case?

phorce 131 Posting Whiz in Training Featured Poster

ete..
don't know this example make you clear or not.. sorry bcause dont know how to explain..
(-__-

Hey,

I'm pretty sure DaniWeb store their data inside a database!

I think what you're hinting, or suggesting is that you have data read in from Excel; which if is the case then you would parse the data in from XML and then you can then manipulate the data and then save it after the processing/manipulation. - Is this the case?

phorce 131 Posting Whiz in Training Featured Poster

From what you've said - It should be possible.. I believe, not to sure what it is your trying to do though!

Anything is possible, if you put your mind to it ;)

phorce 131 Posting Whiz in Training Featured Poster

Providing the specification is clear and consise, and, depending on the purposes I would be more than happy to help you! P/m me to talk more?

phorce 131 Posting Whiz in Training Featured Poster

op with me on trips out and connect using my mobile phone for wireless.

It's possible, I mean, don't give up! It's good to experiment with such things, and, once you start it'll all click into place. I mean, when do you need it by? Do you have a specification of how you want it to look like / function?

phorce 131 Posting Whiz in Training Featured Poster

Hey, apologies.

You would need to use something like, jQuery/Ajax/Javascript in order to create this kind of functuanlity. You can use PHP to do the processing i.e. ("retriving / displaying data"). But the real-time, none-refreshing element would need to be done in a client-side language.

I guess it would be fairly easy to create it where you can show ("Next {#} Records") for example, as well as shifting through them.

phorce 131 Posting Whiz in Training Featured Poster

e same

Do you want someone to do the code for you? You could atleast attempt it. I don't get what question you're actually asking.

phorce 131 Posting Whiz in Training Featured Poster

Like everyone else has said, you should atleast attempt it before posting on here!

Maybe this might help..

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

double subTotal(vector<double> &values)
{
    return accumulate(values.begin(),values.end(),0);
}

int main(int argc, char *argv[]) {

    vector<double> numbers;

    numbers.push_back(10);
    numbers.push_back(20);
    numbers.push_back(9);
    numbers.push_back(8);

    cout << subTotal(numbers) << endl;
}

It might give you an idea how to do stuff like Grandtotal etc..

phorce 131 Posting Whiz in Training Featured Poster

I'm an idiot :)

almostbob commented: not going to argue, but the silliness of the questin is at least offset in part by finding the answer yourself +12
phorce 131 Posting Whiz in Training Featured Poster

Hello,

I'm building an application in PHP and when outputting HTML tags, it shows the tags.. So for example:

<?php
  echo "<b>Hello world</b>";
?>

I would expect Hello world to be in bold.. But no, I get:

<b>Hello world</b> as the output

Any ideas please?

phorce 131 Posting Whiz in Training Featured Poster

Hello,

I'm having a weird problem with some PHP when outputting some HTML. For example:

echo "<h1>There are errors!</h1>";
foreach($errors AS $error)
{
    echo $error . '\n';
}
exit();

I want the output to actually show the text in H1 style, however the output is like this:

<h1>There are errors!</h1>

In other words, it isn't processing the HTML.

Any suggestions?

phorce 131 Posting Whiz in Training Featured Poster

Confused..

By using var_dump, it just dumps whatever is stored in a particular varialbe and then outputs it to the screen (or whatever)! In order to display the output, you should just use echo/printf?

<form action="abc.php" method="post">
    <select name="study_class[]" multiple>
    <option value="Class 1">CLASS 1</option>
    <option value="Class 2">CLASS 2</option>
    <option value="Class 3">CLASS 1</option>
    <option value="Class 4">CLASS 2</option>
    </select>
    </form>
    abc.php
    <?php
    #get data
    $study_class=implode(', ', $_POST['study_class']);
    //var_dump($study_class);
    echo $study_class; // this would output it.
    ?>
    <html>
    .
    .
    <P> Study Classes Chosen are: <?php echo $study_class; ?></P>
    .
    </html>

I don't know if that's what you mean! Or whether you want to actually store the result of var_dump inside a variable.

Biiim commented: understood question better +5
phorce 131 Posting Whiz in Training Featured Poster

s among the easiest ways to have multi page CMS up and running in a relatively short space of time. Themes and skins are free in many cases and for beginners it overcomes many of the obstacles that stand in their way. Of course it does replace the need for HTML designers to some extent so maybe that's where you are coming from. Personally I had one site initially which gave me time to earn while I learn. If I had started with HTML or DHTML I may never have had a customised site for a year. But that's just my opinion. Maybe I should'nt be on DaniWeb. It's sounding like a site for programmers and not for those of us who are learning.

@mim2gether DaniWeb is for everyone, which, is what makes it so unique and that's why people come back (And of course stayed loyal!) it's not just for programmers, although, obviously, the majority will be programming since that topic is a major talking point for the visitors. This in mind, you should be here! If not to ask questions for yourself, or to answer questions that are posted by the users but to learn and adapt other coding techniques and standards from other programmers and developers (That's one of the points of programming, right?)!

As for WordPress, and, like you said - Each to their own! I personally developed a website / blog using Wordpress/BuddyPress and found it horrible to develop for. Yeah, I used …

phorce 131 Posting Whiz in Training Featured Poster
phorce 131 Posting Whiz in Training Featured Poster

Hello,

Have you tried to use jQuery? It has an amazing library for key events. I haven't come across such a thing in PHP before.

phorce 131 Posting Whiz in Training Featured Poster

@min2gether - I would stay away from WordPress IMHO

What kind of example would you like?

phorce 131 Posting Whiz in Training Featured Poster

Apologies!

So what is it your exactly trying to do? Do you want to increment by a particular number and then create a dynamic table that populates depending on the results?

phorce 131 Posting Whiz in Training Featured Poster

Hello,

It would be a good idea if you atleast tried this yourself, even the smallest attempt would be beneficial since we're not here to do homework.

I don't clearly understand what you want, but, have a look at this:

<?php

    // Accept the users age
    $age = $_POST['age'];

    $half_age = $age / 2; // half the age
    $dble_age = $age*2; // double the age
?>

I'm sure it's not as simple as that.. If you want to increment by 10 each time, then you can do that.. If you want to increment by the half age, or double age.. You can do that as well!

Phil

phorce 131 Posting Whiz in Training Featured Poster

No problem :)

Please mark this thread as solved and give rep if you think someone helped!

Goodluck with your application

phorce 131 Posting Whiz in Training Featured Poster

Hello,

First of all, I wouldn't put the function there. Make sure that the function is above all of the main code, so like this:

<?php
   function echoArray($theArray)
   {
       $size=count($theArray);
       for ($i=0; $i<=$size; $i++)
       echo "month number " . $i . " is :" .$theArray[$i] . "<br />";
    }

    // rest of PHP code
    // rest of PHP code
?>

(There was a problem with your code inside this function, you were trying to output $months but it does not exist, instead, you need to output $theArray).

The next step is to actually display the months (or in this case, execute the function).

 <?php
       function echoArray($theArray)
       {
           $size=count($theArray);
           for ($i=0; $i<=$size; $i++)
           echo "month number " . $i . " is :" .$theArray[$i] . "<br />";
        }
        $months=array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
        echo echoArray($months);
    ?>

This will now display the months. I don't know how your application works, but, you should be able to adapt these changes inside your code.

I hope this helps you, feel free to ask for further help :) - Phil

phorce 131 Posting Whiz in Training Featured Poster

Do you need any further help? I.e. a code snippet.

rjony321 commented: yes i need code help..can you give me code but +0
phorce 131 Posting Whiz in Training Featured Poster

No. You cannot.

You can however, "design" the drop down menu in HTML and then process it using PHP.

phorce 131 Posting Whiz in Training Featured Poster

Try this:

<?php
// Set up the database connection
$dsn = 'mysql:host=localhost;dbname=lafamosa_plaincart';
$username = 'lafamosa_kermis';
$password = 'lafamosa1980';
$options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);

try {
    $db = new PDO($dsn, $username, $password, $options);
} catch (PDOException $e) {
    $error_message = $e->getMessage();
    include('errors/db_error_connect.php');
    exit();
}
?>
phorce 131 Posting Whiz in Training Featured Poster

Maybe show some code where it's going wrong - People might be able to help you :)

phorce 131 Posting Whiz in Training Featured Poster

No, it should recognise "Class 1", "Class 2"..

<?php

  $study = $_POST['study_class'];

  var_dump($study);
?>

Then depending on whichever value is entered, should assign this.

I haven't tested it though, might be wrong!

phorce 131 Posting Whiz in Training Featured Poster

Please can you close the thread, mark is as solved and give reputation respectively. If the problem has been solved! :)

phorce 131 Posting Whiz in Training Featured Poster

No problem :)

Sorry if my answer was a little blunt last night; it was 3am!

Good luck with your project :)

P.S. Thres not a huge difference between echo/printf although I'm sure I read somewhere that echo is faster.

phorce 131 Posting Whiz in Training Featured Poster

pencils

Here you go..

<?php
$product_name = "pencils";
$product_price= 7.99;
printf( "Product %s will cost %1.1f dollars.",
$product_name, $product_price );
?>

Remember, %s = string. %f = floating point number..

Hope this solves it :)

LastMitch commented: Thanks for the example and explanation! +0
phorce 131 Posting Whiz in Training Featured Poster

here, I don't know how to get PHP to build a list using the data. I could do it manually every time a new month comes up, but that defeats the purpose in my book.

Hello,

Basically (From what I understand) you should have a table/column that populates a list of months, from this month, the form should handle it by a $_GET method. So for example:

yoursite.com/Archive.php?month=january

and the php would be like this:

<?php

  $month = $_GET['month'];

  // rest of php code

 ?>

You can populate the form (list of months) by a query.

Sorry it's not much help, message back if you require any further code snippets!

phorce 131 Posting Whiz in Training Featured Poster

Hello,

First of all..

int main();

Shouldn't have a semicolon, therefore it should just be:

int main()
{

   return 0;
}

You've also declared a function, but, it doesnn't mean it's wrong, you can set the prototype (Especially if your using the function in main, but it's actual functiuanlity is set outside of main).

Also, you seem to be accepting numbers (in a for loop) that only get entered into a single variable.. This isn't right, you need to create an array for the numbers to be stored in, and then pass this array to a function that calculates all of the numbers together. (I think this is how you want the program to work!)

Have a look at this example:

#include <set>
#include <iostream>

using namespace std;

     double atotal(double *theNumbers, int theTotal)
     {
        int total = 0;

        for(int i=0; (i < theTotal); i++)
        {
            total += theNumbers[i];

        }
        return total;
     }

    double daverage(double *theNumbers, int theTotal)
    {
        int total = atotal(theNumbers, theTotal)/theTotal;

        return total;

    }

int main()
{
    int itotal = 0;

    cout << "please enter how many numbers: " <<endl;
    cin >> itotal;
    double* a = new double[itotal];

    cout << "start entering numbers" <<endl;
    for(int i = 0; (i < itotal); i++)
    {
        cin >> a[i];
    }
    // This will display the numbers added together
    cout << "The total sum of the numbers is: " << atotal(a, itotal) << endl;
    cout << "The average of the numbers is: " << daverage(a, itotal) << …
phorce 131 Posting Whiz in Training Featured Poster

<?php
$product_name = "pencils";
$product_price= 7.99;
printf( "Product %f will cost %1.1f dollars.",
$product_name, $product_price );
?>

Can't you just echo it?

<?php
$product_name = (string) "pencils";
$product_price= 7.99;

echo "Product $product_name will cost $product_price";
?>