Jump to content

digibucc

Members
  • Posts

    142
  • Joined

  • Last visited

Posts posted by digibucc

  1. here's what i did:

    $entry would be your array, with all of your info. this foreach will split that into key value pairs, and then format them as an SQL query, and finally it will insert.

     

    <?php
    
    foreach ($entry as $key=>$value){
    if ($value != '' && $value != 'Submit'){
    $cols .= mysql_real_escape_string($key). ', ';
    $vals .= '\''. mysql_real_escape_string($value). '\', ';
    }
    }
    
    $columns = substr($cols,0,-2); // trim trailing "'," , 
    $values = substr($vals,0,-2);
    
    $sql="INSERT INTO table ( $columns )VALUES ( $values )";
    

     

    i'm sure there are other ways to handle the trailing "',", but this works for me :)

  2. hello :)

     

    i would test a simple send with mail() before debugging that:

     

    http://php.net/manual/en/function.mail.php

    bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

    <?php
    mail('caffeinated@example.com', 'My Subject', $message);
    ?>

     

    that will confirm that php smtp is working, and then you can debug phpmailer

  3. i said if else in heredoc because that is what you need info on, a google search returned this:

    http://stackoverflow.com/questions/7187226/if-else-with-heredoc-not-behaving-as-expected

    along with a few others. it's not possible to do your if statement inside your heredoc (EOL)

     

    the code i gave you WILL work if you put it BEFORE the heredoc starts (<<<EOL). honestly heredoc is not the best way to do this project, but if you're set on that you need to do it differently. the link i posted has an example that shows how it must be done.

     

    sorry bud ;(

     

     

  4. so you are using heredoc? that's why the code looked wrong to me, as i couldn't see that.

    i have never used an if inside a heredoc statement, so i'm at a bit of a loss. i would think you need to end the heredoc for the if statement, but i don't know.

     

    i'd venture that's where your problem lies though. "if else in heredoc"

  5. not according to what you posted. that is a weird mixture of php and html and should not work at all.

     

    <?php
    
    if(file_exists($md_sig))
       { ?>
    
    <tr>
       <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>
          <table border="0" width="100%">
             <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>
             <tr>
                <td valign="bottom">$md_sig<hr />Psychiatrist: $md_name_string</td>
                <td valign="bottom">$md_date_string<hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom">$case_manager_sig<hr />Case Manager: $case_manager_name_string</td>
                <td valign="bottom">$case_date_string <hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom">$therapist_sig<hr />Therapist: $therapist_name_string</td>
                <td valign="bottom">$therapist_date_string <hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom">$activity_therapist_sig<hr />Activity Therapist: $activity_therapist_name_string</td>
                <td valign="bottom">$activity_date_string <hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom">$other_sig<hr />Other: $other_name_string</td>
                <td valign="bottom">$other_date_string <hr />Date:</td>
             </tr>
             <tr>
                <td colspan="2"><br />NEXT TREATMENT PLAN REVIEW: <font class="dbd">$next_review</font></td>
             </tr>
          </table>   
       </td>
    </tr> <?php }
    
    else { ?>
    
    <tr>
       <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>
          <table border="0" width="100%">
             <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>
             <tr>
                <td valign="bottom"><hr />Psychiatrist: $md_name_string</td>
                <td valign="bottom">$md_date_string<hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom"><hr />Case Manager: $case_manager_name_string</td>
                <td valign="bottom">$case_date_string <hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom"><hr />Therapist: $therapist_name_string</td>
                <td valign="bottom">$therapist_date_string <hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom"><hr />Activity Therapist: $activity_therapist_name_string</td>
                <td valign="bottom">$activity_date_string <hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom"><hr />Other: $other_name_string</td>
                <td valign="bottom">$other_date_string <hr />Date:</td>
             </tr>
             <tr>
                <td colspan="2"><br />NEXT TREATMENT PLAN REVIEW: <font class="dbd">$next_review</font></td>
             </tr>
          </table>   
       </td>
    </tr> <?php }
    ?>

     

    would work assuming it's actually html it just has that php in it. otherwise you would need an echo or print in there somewhere.

     

    you have html and php mixed with nothing to tell it what's what.

    <?php <td valign="bottom">$md_date_string<hr />Date:</td> ?>

     

    same thing here. you need an echo or print there.

    </tr> }
    
    else {
    
    <tr>

     

    something like this instead:

    <?php
    
    if(file_exists($md_sig))
       {
    echo '
    <tr>
       <td><br /><center><b>TREATMENT TEAM SIGNATURES</b></center>
          <table border="0" width="100%">
             <tr><td colspan="2"><b>Services ordered are Appropriate—See SMI/SED for additional explanation</b></td></tr>
             <tr>
                <td valign="bottom">'. $md_sig. '<hr />Psychiatrist: '. $md_name_string. '</td>
                <td valign="bottom">'. $md_date_string. '<hr />Date:</td>
             </tr>
             <tr>
                <td valign="bottom">'. $case_manager_sig. '<hr />Case Manager: '. $case_manager_name_string. '</td>
                <td valign="bottom">'. $case_date_string. '<hr />Date:</td>
             </tr>
          </table>   
       </td>
    </tr>'; }
    ?>

     

    i'd say you are seeing it twice because it is not parsing it as php at all. so it sees two tables and ignored the if statement.

  6. both of those should have worked, i think you need to show us your code

     

    var_dump($mp_sig); //before the if statement, so you know it is in fact empty.

     

    also copy and post the if else you made in regards to the post before mine, as that should have worked and there's probably something in the code wrong.

  7. this will grab each entry in the array, and then you pull the named key (url) for that entry and do what you want, along with any other keys. it is best if your keys are always the same.

    <?php
    foreach ($array as $entry){
    echo $entry['url']; // named array key in nested array
    }
    ?>
    

     

    or this will cycle through each entry, and then each value in the entry. it's cumbersome and not recommended unless you need to process each value THE SAME, separately.

     

    <?php
    foreach ($array as $entry){
    foreach ($entry as info) {
    // do something with each piece of info, in each entry
    }
    }
    ?>
    

     

  8. if i understand you properly, and all you want is to blank the info if the md_sig is not there, then you could

     

    <?php
    if (empty($md_sig)) {
    $case_manager_sig = '';
    $therapist_sig = '';
    $activity_therapist_sig = '';
    $other_sig = '';
    }
    ?>
    

     

    you could also throw the dates in there if those need to be unset. this way you do it before the html and you don't have to if anything there , the strings will just be blank if  md_sig was blank.

  9. here's what i did:

     

    <?php
    
    foreach ($entry as $key=>$value){
    if ($value != '' && $value != 'Submit'){
    $cols .= mysql_real_escape_string($key). ', ';
    $vals .= '\''. mysql_real_escape_string($value). '\', ';
    }
    }
    
    $columns = substr($cols,0,-2); // trim trailing "'," , 
    $values = substr($vals,0,-2);
    
    $sql="INSERT INTO table ( $columns )VALUES ( $values )";
    

     

    i'm sure there are other ways to handle the trailing "',", but this works for me :)

  10. there is no limit to case. here's a snip from one of my scripts:

     

    <?php 
    switch($stl_type){
    	default:$type = 'other-trucks';break;
    	case 'car carrier truck':$type = 'auto-carrier';break;
    	case 'van trucks / box trucks':$type = 'box-vans';break;
    	case 'bucket truck / boom truck':$type = 'bucket-truck';break;
    	case 'dump truck':
    	case 'dump bodies only':
    	case 'dump chassis truck':
    	case 'dump/transfer':
    	case 'flatbed-dump truck':$type = 'dump-trucks';break;
    	case 'tow trucks':
    	case 'roll-back tow truck':
    	case 'wrecker tow truck':
    	case 'tow truck':$type = 'tow-trucks ';break;
    }
    ?>

     

    notice:

     

    <?php 
    case 'dump truck':
    	case 'dump bodies only':
    	case 'dump chassis truck':
    	case 'dump/transfer':
    	case 'flatbed-dump truck':
    $type = 'dump-trucks';
    break;?>

    so you can set multiple matches for an action. my statement is 3x that long, and i don't believe there is a functional limit. maybe there error is elsewhere, or syntax?

     

    you could also put them in arrays:

     

    <?php
    $region1 = array('county1', 'county2', 'county3', 'etc';
    $region2 = array('county4', 'county5', 'county6', 'etc';
    
    if (in_array($needle, $region1) {
    do_something(); // found your county in region 1
    } else if (in_array($needle, $region2) {
    do_something(); // found your county in region 2
    }?>

     

    if you do more, you may consider making them array keys and using array_key_exists, as that's faster than searching array values. but for 10 counties each region this works fine.

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