Jump to content

darkhappy

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Posts posted by darkhappy

  1. I am not really understanding your question. Why can't you just add "checked" to the input tag for boxes you want checked?

     

    You may need to change your if statement so that the boxes you want to show as checked are not getting created by the line after the else, which does not include "checked" in the input tag.

     

     

  2. create a counter for the loop, then put an if statement inside the loop to check if the counter is even or odd. if its even apply class 1, if its odd apply class 2. there are several ways to check if an integer is even or odd, i am not sure the best way but there are some examples here: http://www.php.net/is_numeric.

     

     

    <?php
    
    $counter = 0
    
    foreach ($array as $value) {
        $counter = counter + 1;
        if (counter is even) {
            class = 1;
        } else {
            class = 2;
        }
    
        //rest of foreach loop
    }?>

     

       

  3. sorry if this is the wrong category to post this in i was not sure -

     

     

    i currently host my php site with godaddy, it's still in development but as i bring it online and hopefully get customers and more databases i am sure i will need to move it somewhere else. can some of you share your thoughts on pros and cons of different hosting services? godaddy is pretty slow (at times) and i can't install a database admin tool from my desktop (i have to login to the web to use myPHPadmin) - which is also kind of slow.

     

    thanks for any info.

     

    - dhappy

  4. Best solution for you would be using ctype_alnum(). It's more efficient than using a regular expression, and it does the job.

     

     

    The regex way:

     

    <?php
    
    if(preg_match("/^[a-z0-9]*$/i", $str)) 
    {
       //$str is valid
    }
    
    ?>

     

     

    Orio.

     

    I have tried both ways and empty fields are still evaluating to true. What am I doing wrong?

     

     

    Here is my code:

     

    	<?php
    foreach($checkarr1 as $v4) {
    		if(ctype_alnum($v4)) {
    			echo "'".$v4."'-";
    		}
    }
    ?>

     

     

    $checkarr1 is an array created from a row in a CSV file, some values are null and I only want to echo $v4 for valid fields. I put '' around the var so I can see the blanks when it outputs.

     

     

     

    thanks,

    dhappy

  5. How can I check $var for characters 0 - 9 and a -z (and what ohter normal charactes should I look for?)?

     

     

    I am processing a value from a CSV file if I run the check if ($var!='') on some of the fields it returns TRUE even though the CSV field is empty, so I need to check the $var to make sure it contains data. Please let me know if this question does not make sense so I can re-phrase or give more info.

     

     

     

    Thank you,

    dhappy

  6. i will have to try that next time... instead i tweaked this function to pull the key out of the variable once it is posted. lots of work for a 1 little number hehe!

     

     

    <?php
    function get_sheet() {
    $context = '_POST';
    
    global $$context;
    if(isset($$context)) {
            foreach($$context as $k => $v) {
                    $sheetid = $k;
                    }
            }
    }
    get_sheet();
    ?>

  7. I am getting an error when processing this code - could anyone give me the proper syntax/puntuation for this?

     

     

     

    <?php
    while ($a = mysql_fetch_array($approvals)) {
    
                 if(isset($_POST['{$a['approvals']}'])) {
                              $sheetid = $_POST['{$a['approvals']}'];
                              }
                 }
    ?>
    

  8. Do you want to 'approve' one at a time or do you want to choose multiple items to be approved when you submit the form?

     

    I see where you're going with that, I'd like to approve 1 at a time. It's actually easier because its 1 click and just reloads the page.

     

     

     

    I think I figured out how though. I can use the "name" parameter as suggested in the first reply, and set the value to "approve". then when i process the script i can run the same query i used to display the approval options to begin with, and use a while loop to cycle through different POST statements until I find a match. i think that would work - assuming i can insert a $var into existing $_POST['var'].........

  9. I have a while loop that pulls rows of data from a sql table, and at the beginning if each row I have a button that says "Approve Sheet ID # xxxxx". I want the button to just say "Approve" and attach the unique sheet id some other way in the button without it displaying - do you know if there is a way to do this? Or some other way to get the unique identifier to post without putting it in the value of the "Approve" button?

     

     

    <input name="approve" type="submit" class="style4" value="Approve Sheet ID #<?php echo $sheetid?>" />

  10. I am trying to write a foreach loop that will set all the dates in an array back 1 week if flag 'lastweek' is set. The date-modify function seems to make the most sense but i get fatal errors when using it. When I try to convert to a timestamp with date and mktime i get 1970 for the year. for that code i did:

     

    date("Y",$value) 

     

     

    and it comes out to 1970 every time even though $value (from the foreach loop below) is something like 04-24-2008. any ideas? I have been hacking away at this for hours and am clueless.

     

     

    <?php
    $week = array($monday, $tuesday, $wednesday, $thursday, $friday, $saturday, $sunday);
    
    
    if($_SESSION['lastweek'] == "1") {
                foreach($week as $d => $value) {
                             $date = new DateTime($week[$d]);
                             $date->modify("-1 week");
                             }
                 unset($_SESSION['lastweek']);
                 }
    ?>

  11. Sounds like you need a quick lesson in database normalization. Theres a good link in my signiture to a free book, it has an entire chapter dedicated to the subject.

     

    If your tables are normalized properly, data can grow indefinately without the need to restructure.

     

     

    OOOOOOOOOHhhhhhhhhhhh...... so instead of creating a certain # of fields across 1 table ahead of time, you just create new tables as needed and link the associated fields with an ID - is that right?

  12. You need to make the name of the field an array:

    <form method="post" action="foo.php">
      <select name="bar[]" multiple>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
      </select>
      <input type="submit" name="submit" value="Submit" />
    </form>

     

    Then you will get multiple values returned.

     

    Ken

     

     

     

    could someone show me what the code would look like to put the data from this array into var's once it's posted?

     

     

     

    thanks,

    bb

     

  13. You need to make the name of the field an array:

    <form method="post" action="foo.php">
      <select name="bar[]" multiple>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
      </select>
      <input type="submit" name="submit" value="Submit" />
    </form>

     

    Then you will get multiple values returned.

     

    Ken

     

     

     

    could someone show me what the code would look like to put the data from this array into var's once it's posted?

     

     

     

    thanks,

    bb

  14. php session names from from here:

     

    <?php
    session_start(session_name);

     

     

    i think you would have to dig into your cart script to see where that ID is coming from - could be an encrypted session name or cookie? you could store any variable into a SQL database with MD5 encryption and it would look like that.

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