Jump to content

oliverj777

Members
  • Posts

    98
  • Joined

  • Last visited

    Never

Posts posted by oliverj777

  1. I really can't get my head around this dynamic drop box. What I want is for a drop box to be populated with values in my database.

     

    I have this that connects to my SQL and picks out the table required:

     

    function displayUsers(){
       global $database;
       $q = "SELECT username,"
           ."FROM ".TBL_USERS." ORDER BY userlevel DESC,username";
       $result = $database->query($q);    ...

     

    I then have this to pick out any errors, and also using the num_rows to get the number of rows (values) there are:

     

    $num_rows = mysql_numrows($result);
       if(!$result || ($num_rows < 0)){
          echo "Error displaying info";
          return;
       }
       if($num_rows == 0){
          echo "Database table empty";
          return;
       }

     

    From here, I guess I want the num_rows to keep 'adding on' the number of <option value=""> in my selection box according the number of values I have in my database.

     

    At this point, I can pull out the values into a dynamic table ... but I want it into a drop box -- but I'll but up the code for the dynamic table so you can get an idea:

     

     

    /* Display table contents */
       echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n";
       echo "<tr><td><b>Username</b></td></tr>\n";
       for($i=0; $i<$num_rows; $i++){
          $uname  = mysql_result($result,$i,"username");
          echo "<tr><td>$uname</td></tr>\n";
       }
       echo "</table><br>\n";
    }

     

    I hope you can use the code above to help me develop this darn drop box!

     

    Thanks, Ollie!

  2. Basically,

     

    I have a database table called 'users' and I would like to populate a drop down box with these values of 'users'.

     

    How?? - to call upon the values is this: 'upduser2'

     

    Right now, all I am using is a text box, in where you have to type in the users name manually (this is so an admin can change variables and settings according to that current user). This is what I am using so far:

     

     

    <h3>Update User Level</h3>
                                                        <? echo $form->error("upduser"); ?>
                                                        <table>
                                                          <form action="adminprocess.php" method="post">
                                                            <tr>
                                                              <td> Username:<br />
                        <input type="text" name="upduser" maxlength="30" value="<? echo $form->value("upduser"); ?>" /></td>
                                                              <td> Level:<br />
                                                              <select name="updlevel">
                                                                  <option value="1">1 </option> //example settings
                                                                  <option value="9">9 </option>
                                                                </select></td>
                                                              <td><br />
                                                                <input type="hidden" name="subupdlevel" value="1" />
                                                                <input type="submit" value="Update Level" /></td>
                                                            </tr>
                                                          </form>
                                                        </table></td>
                                                    </tr>

     

     

    Much help would be appreciated.

  3. I would imagine its something to do with your 'explode' and $file.

     

    The explode is splitting your string by string, and being whats in your $file - is causing it to repeat/place your ;; everywhere

     

    I'm no expert though

  4. It could be because you are your <? ?> already within a PHP script.

     

    Try this: (I'm no expert btw)

     

     

    echo "
    
    <html>
    
    <head>
    
    <title>Photography</title>
    
    </head>
    
    <body>
    
    <table width='100%' border='0' align='center' style='width: 100%;'>";
    
    
    $result_final  // I'm not sure what this is doing here??
    include("search.php");
    
    echo"
    
    </table>
    
    </body>
    
    </html>";

  5. Hello,

     

    My user login script saves their passwords into my SQL in a md5 encryption.

     

    I am currently working on a 'forgot password' that sends the password to their email.

     

    The code that pulls out the password is this:

     

    echo $req_user_info['pass'];

     

    Now is there a way to decrypt the 'pass' (currently nothing is displayed - not even the encryption code)

     

    Please help - Ollie

  6. Oh My Jesus Christ --

     

    It's taken me, what 6 hours to figure this out ... And I've just found the problem .. You're not going to believe it.

     

    I missed the '=' off the:

     

    input type"text" name"firstname"...

     

    Correction is:

    input type="text" name="firstname"...

     

    It had nothing to do with my PHP coding!! HOW ANNOYING!!

  7. Okay, I have a useredit page in where a user can manage their account info. All the text field and SQL connections work fine, and they all update perfectly. But when I go ahead and add my own text field (first name) and hit submit, it says success - but in my SQL it hasn't actually updated ... What the Ef?

     

    Here are my snippets of my codes:

    --useredit.php--

     

    <form action="process.php" method="POST">
    
    <input type"text" name"firstname" value="<? if($form->value("firstname") == ""){    echo $session->userinfo['firstname']; }else{    echo $form->value("firstname"); } ?>">
    
    <input type="hidden" name="subedit" value="1">
                            <input type="submit" value="Edit Account">

     

    --process.php--

     

    function procEditAccount(){
          global $session, $form;
          /* Account edit attempt */
          $retval = $session->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email'], $_POST['firstname']);
    
          /* Account edit successful */
          if($retval){
             $_SESSION['useredit'] = true;
             header("Location: ".$session->referrer);
          }

     

    --session.php--

     

    function editAccount($subcurpass, $subnewpass, $subemail, $subfirstname){
          global $database, $form;
    
    if($subfirstname){
             $database->updateUserField($this->username,"firstname",$subfirstname);
          }

     

    --database.php--

     

     function updateUserField($username, $field, $value){
          $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'";
          return mysql_query($q, $this->connection);
       }

     

     

    If you need to see more code, let me know.

     

    Would appreciate the help, thanks!

    Ollie!

  8. Basically, All I want to do is save a .txt (doesn't have to be .txt) to my FTP and PHP simple echos it. The .txt is where a message is stored. But when I write the message my self like this:

    Hello

     

    This is a message.

     

    - And then upload it to my FTP, PHP echos it like this "HelloThis is a message". Is there anyway for PHP to notice the 'white space'?

     

    --OR--

     

    If you know of a better way to make a message system, then also let me know

     

    Thanks, Ollie!

  9. Hello,

     

    As you may know, money is displayed like so: 10.50 (from where I am from its £10.50, but anyway ...)

     

    So what would you recommend as a type for SQL to save that value, I would prefer it to be numeric, but I would also like to save the decimal so when it comes to PHP, I can see what is pounds (dollars) and pence (cents) in which I will soon later add to a mathematical array.

     

    Thanks, Ollie!

×
×
  • 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.