Jump to content

Hepp

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Posts posted by Hepp

  1. Ken,

     

    I LOVE YOU. THANK YOU.

     

    So simple, yet I need sleep.

     

    Thanks buddy.

     

    Revised correct code for anyone who is looking:

     

    <?php
    
    function aboutUs() {
    
    echo "This is the <b>about</b> section.<p>";
    
    }
    
    function otherPage() {
    
    echo "This is the <b>other</b> section.<p>";
    
    }
    
    if (isset($_GET['page'])) {
    
    $page = ($_GET['page']);
    
    if ($page == "aboutUs") { 
    
    aboutUs(); 
    
    } elseif ($page == "otherPage") {
    
    otherPage();
    
    } else {
    
    echo "";
    
    }
    
    }
    
    ?>
    
    <a href=static.php?page=aboutUs>About</a>
    <a href=static.php?page=otherPage>Other</a>
    

     

    Thanks again Ken =)

     

    -Hepp

  2. I still don't really get what your problem is.

     

    Don't know if thats where your problem is, but y8ou can try to fix those things and see what happens.

     

    The problem is that when you click the link, it does not display the code from the function like I've been trying to get it to, you know?

     

    2) The function aboutUs($page) calls for the variable $page, but you aren't passing it to the function when you call it.

     

    But the function calling the variable, I removed it. I tried something earlier, forgot to get rid of it.

     

    Here's the revised code:

     

    <?php
    
    function aboutUs() {
    
    echo "This is the <b>about</b> section.";
    
    }
    
    if (isset($_GET['page'])) {
    
    $page = ($_GET['page']);
    
    if ($page[0] == "aboutUs") { 
    
    aboutUs(); 
    
    } else {
    
    echo "";
    
    }
    
    }
    
    ?>
    
    <a href=static.php?page=aboutUs>About</a>
    

     

    1) you are referring to $page both as a single variable, and then as an array later on.

     

    Can you not refer to $page as a single and then to an array? I couldn't think of another way to do this.

     

    Thanks man.

    -Hepp

  3. You set your index page to tos.php in your server settings, or place the tos code in the index page, and make a home.html page and link after they agree to them at the bottom.

     

    Simple.  ;)

  4. To answer your question, yes I read the FAQs, and there was a Select Case example there.

     

    I've been coding for 3+ years now, but this is angering me.

     

    Snippet of code:

     

    <?php
    
    function aboutUs($page) {
    
    echo "This is the <b>about</b> section.";
    
    }
    
    if (isset($_GET['page'])) {
    
    $page = ($_GET['page']);
    
    if ($page[0] == "aboutUs") { 
    
    aboutUs(); 
    
    } else {
    
    echo "";
    
    }
    
    }
    
    ?>
    
    <a href=static.php?page=aboutUs>About</a>
    

     

    I've been trying to get that to work all day. Is there something I am overlooking, doing wrong, or forgetting?

     

    Bleh I need sleep  :P

     

    Thanks so much.

    -Hepp

  5. Thank you for your help again.  ;D

     

    I don't quite understand what your saying, but I need to use the email the user supplies in the input field in order for them to receive the mail and not the one in php.ini.

     

    Like:

     

    They enter their email, click "Retrieve Password", the PHP code matches their email with the one in the database and grabs their password, puts the correct password in the message, then sends the email to that users email, along with their password.

     

    I need this.

     

    Anymore suggestions?

  6. I have two different servers, a web and a mail server. The mail server uses localhost and the port of 25 for SMTP in php.ini, and the "sendmail_from" is set in php.ini - I'm 100% sure.

     

    I tried making a simple mail script work...

     

    <?php
    
    // The message
    $message = "Line 1\nLine 2\nLine 3";
    
    // In case any of our lines are larger than 70 characters, we should use wordwrap()
    $message = wordwrap($message, 70);
    
    // Send
    mail('BlahBlah@gmail.com', 'My Subject', $message);
    
    ?>
    

     

    I have the php.ini "sendmail_from" setting to a different email than in that code. I need the code to have different emails for such things as a forgot password script when parsing info over $_POST, like the email. I need it to send the info to their email, not the one in php.ini.

     

    Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in *FilePath* on line *SomeNumber*

     

    And it's given me a headache to the max. And now I'm angry at this thing. GAH!  >:( ???

     

    Any suggestions?

     

    Thanks for the help if so  ;D

  7. OMG! IT WORKED! THANK YOU SASA AND MAINEWOODS!

    But... that led to yet another problem.

    I can't find a way, no matter what, to get the items displayed to order by "itemname". Instead, they're ordering in the order they were purchased and inputed into the database.

    I also was wondering if there is a way that you can add all the values together of all the items in the array to get it to display a variable called "$totalamount"...?

    I can't figure out how to do both, but seriously, thank you MaineWoods and Sasa for all the help so far  ;D

    Here is my current coding below if it helps:

    [code]
    <?php

    include('config.php');

    $itemidlistquery = mysql_query("SELECT itemidlist FROM customers WHERE username='".$_COOKIE['username']."' LIMIT 1");

    $itemidlistrow = mysql_fetch_array($itemidlistquery);
    $itemidlist = ($itemidlistrow['itemidlist']);

    $itemslist = explode(",",$itemidlist);
    $inventorystring = "";
    foreach($itemslist as $a => $b)
    {
    $inventorystring .= "itemid='$b' OR ";
    }
    $inventorystring .= rtrim($inventorystring, " OR ");
    $itemsquery = mysql_query("SELECT * FROM items WHERE $inventorystring ORDER BY itemname LIMIT 1");
    while ($itemsrow = mysql_fetch_array($itemsquery))
    {
    $itemnames = mysql_query("SELECT * FROM items ORDER BY itemname");
    while ($onename = mysql_fetch_array($itemnames))
    {
    $transname[$onename['itemid']] = $onename['itemname'];
    }
    $itemidlist2 = ($itemidlistrow['itemidlist']);
    $itemslist2 = explode(",",$itemidlist2);
    $valuesarray = array_count_values($itemslist2);
    foreach ($valuesarray as $name => $amount)
    {
    $page .= "
    <tr>
    <td width=100% align=center>
    <b>".$transname[$name]."</b> (". $amount .")
    </td>
    </tr>\n";
    }
    $page .= "
    <br>\n";
    }
    ?>
    <link href=styles.css rel=stylesheet type=text/css>

    <html>

    <head>

    </head>

    <body>

    <center>

    <form action=inventory.php method=post>
    <table width=60% align=center>
    <tr>
    <td align=center width=100% colspan=2 cellpadding=3>
    <b>Inventory</b>
    </td>
    </tr>
    <tr>
    <td width=100% align=center>
    <br>
    You have <font color=lime><b><?php echo($totalamount); ?></b></font> items.
    </td>
    </tr>
    </table>

    <?php echo($page); ?>
    </table>
    </form>
    <p>

    </center>

    </body>

    </html>
    [/code]

    Thank you again. I am very grateful.
  8. Okay, so I tried that, and it didn't exactly work. I had to edit it a bit too to get it to at least say what it does now.

    It displays the following at the top of the page now:

    [code]
    = 6 = 8 = 10
    = 6 = 8 = 10
    = 6 = 8 = 10
    [/code]

    The numbers are correct, and I know it's almost there... but I just can't think of this.

    Here is the coding for the entire page itself:

    [code]
    <?php

    include('config.php');

    $itemidlistquery = mysql_query("SELECT itemidlist FROM customers WHERE username='".$_COOKIE['username']."' LIMIT 1");

    $itemidlistrow = mysql_fetch_array($itemidlistquery);

    $itemidlist = ($itemidlistrow['itemidlist']);

    $itemidlist2 = ($itemidlistrow['itemidlist']);


    $itemslist = explode(",",$itemidlist);

    $inventorystring = "";


    $itemidquery = mysql_query("SELECT itemid FROM items");

    $itemidrow = mysql_fetch_array($itemidquery);


    foreach($itemslist as $a=>$b) {

    $inventorystring .= "itemid='$b' OR ";

    }

    $inventorystring .= rtrim($inventorystring, " OR ");

    $itemsquery = mysql_query("SELECT * FROM items WHERE $inventorystring ORDER BY itemname");

    //NEW CODING

    $getnames = "SELECT * FROM items"; //gets all the rows
    $itemnames = mysql_query($getnames);
    while (!$onename = mysql_fetch_array($itemnames)) {
        $transname[$onename['itemid']] = $onename['itemname']; //building the $transname array
    }
    //the $transname array should contain all the values in the items table
    //it uses the primary key of each record as the array key as well


    while ($itemsrow = mysql_fetch_array($itemsquery)) {

    $itemslist2 = explode(",",$itemidlist2);

    $valuesarray = array_count_values($itemslist2);


    foreach ($valuesarray as $key => $value) {

    echo $transname[$key] . ' = ' . $value . ' ';

    }


    echo '<br>';

    }

    ?>
    <!--

    //OLD CODING

    while ($itemsrow = mysql_fetch_array($itemsquery)) {

    $itemslist3 = explode(",",$itemidlist2);

    $valuesarray = array_count_values($itemslist3);


    foreach ($valuesarray as $key => $value) {

            //write some code to get the translation of
            //the $key code from your database

    //get $key to euqal $itemid and them for that $itemid to equal that $values

    $itemid = ($itemsrow['itemid']);

    $whatevs = ($count_values[$value]);

    }

    $page .= "
    <tr>
    <td width=100% align=center>
    <b>".$itemsrow['itemname']."</b> (". $whatevs .")
    </td>
    </tr>\n";

    }
    -->
    <link href=styles.css rel=stylesheet type=text/css>

    <html>

    <head>

    </head>

    <body>

    <center>

    <form action=inventory.php method=post>
    <table width=60% align=center>
    <tr>
    <td align=center width=100% colspan=2 cellpadding=3>
    <b>Inventory</b>
    </td>
    </tr>
    </table>

    <?php echo($page); ?>
    </table>
    </form>
    <p>

    </center>

    </body>

    </html>
    [/code]

    MaineWoods, again, thank you so much for sticking with me and helping me. You are a PHP God. Thank you so much.  =)
  9. I do have a seperate table called "items", that has the field "itemid" and "itemname" to communicate with "itemidlist" to display the name of the item in the variable "$page". I can't get my head to think of how I could tell the code to display how many times that itemid number is in "itemidlist" for the itemname. I don't know how to get it to do that in that while() loop...  ???
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.