Jump to content

phpretard

Members
  • Posts

    821
  • Joined

  • Last visited

    Never

Posts posted by phpretard

  1. There are 45 text fields (catID) and 45 corresponding checkboxes (score)

     

    <form>

     

    // in a while loop that stops at 45

     

    <input type="text" name="catID[]" value="<? echo $test['id']; ?>" readonly />

    <input type="checkbox" name="score[]" value=\"1\" /> incorrect

     

    // end in a while loop

     

    <br />

     

    <input type="submit" name="submit_test" value="Submit" />

     

    </form>

  2. This might help explain...

     

    
    foreach($_POST['catID'] as $catID){
    
    
    
    if ($_POST['score'] == "1"){ // represents a checkbox with a value of 1
    
    
    $insert = mysql_unbuffered_query(" insert into test_results values('".$_POST['id']."', '$catID', '1') ");	
    
    
    }else{
    
    
    $insert = mysql_unbuffered_query(" insert into test_results values('".$_POST['id']."', '$catID', '0') ");		
    
    }
    
    }
    
    

  3. The reason I need the foreach is because there are 45 catID[] that should correspond with 45 score[]

     

    if catID's value is 5 and score is checked the vars I need would be: "$catID = 5 , $score = 1"

     

    
    <?
    
    foreach($_POST['catID'] as $score){
    
    //insert values "$catID = 5 , $score = 1"
    
    }
    
    ?>
    
    <form>
    
    // in a while loop
    
    <input type="text" name="catID[]" value="<? echo $test['id']; ?>" readonly />
    <input type="checkbox" name="score[]" value=\"1\" /> incorrect
    
    // end in a while loop
    
    <br />
    <input type="submit" name="submit_test" value="Submit" />
    </form>
    
    

     

    Thank you for the help!

  4. I use $_GET

     

    
    <?php
    
    $Type = $_GET['source'];
    $id = $_GET['id'];
    $track = $_GET['track'];
    $doc=$_GET['doc'];
    
    $file_path = $_SERVER['DOCUMENT_ROOT']."/orders/".$track."/".$doc;
    if (file_exists($file_path) && !is_dir($file_path)) {
    header('Content-type: application/octet-stream');
    header("Content-Disposition: attachment; filename=\"".$doc."\"");
    header('Content-Length: ' . filesize($file_path));
    ob_clean();
    flush();
    readfile($file_path);
    exit;
    } else {
    
    header ("HTTP/1.0 404 Not Found");
    exit;
    }
    
    ?>
    
    

  5. I'm not sure I do either :)

     

    Can I write $this into linux using exec() not having to use SSH or Plesk?

     

    $this="*/1 * * * * /usr/bin/php /var/www/vhosts/website.net/httpdocs/a_assign_appraiser.php"

  6. So I have files in a Plesk Skeleton for newly added domains. 

     

    Within the files there are a few that requires cron for the site to run properly.

     

    With exec() I can write this into linux?

  7. I know how to setup cron.  I need to know if there is a way to setup cron via php.

     

    For example.  When you install wordpress or Joomla there is a wizard of sort to install the database and configure some files. 

     

    Is there such a script to do the same with cron?

  8. I am trying to dislay a negative number without the minus sign.

     

    If the math come out to $-50.00 I need it to display $50.00.

     

    If it comes out to $50.00 then I need it to display $-50.00.

     

    Here is what I thought was working...

     

    $grandTotal="-50.00";
    
    if ($grandTotal <= 0) {
    	$grandTotal = explode('-', $grandTotal);
    	echo "$".number_format($grandTotal[1], 2);
    
     }else{
     	$grandTotal = number_format($total - $subtract, 2);
    	echo "$-".number_format($grandTotal, 2);
    
     }
    

    It did work for a few instances but now it's giving me problems.

     

    Any thoughts?

  9. How I get ".00" to show if there is nothing after the decimal in the Database.

     

    For example if I insert 2.00 [decimal (10,2)] in the database the php will only display the ".00" if there is a value after the decimal.

     

    The code works fine it's the .00 that's got me.

     

    function getBalance(){
    
    connect();
    
    $balanceQ=mysql_query("select cart.eventID, cart.userID, 
    competitions.id, competitions.price, competitions.coachcost
    FROM cart LEFT JOIN competitions ON competitions.id = cart.eventID
    where cart.userID='123'
    ") or die(mysql_error());	
    
    while($balance=mysql_fetch_assoc($balanceQ))
    {
    $total +=$balance['price'] + $balance['coachcost'];
    }
    
    // get previous payments
    $historyQ=mysql_query("select * from account where userID='123' ");	
    while($history=mysql_fetch_assoc($historyQ))
    	{	
    	$subtract +=$history['amount'];
    
    	} 
    
    free($balanceQ);
    free($historyQ);
    
    echo "$".($total - $subtract); //<<<<  PROBLEM
    
    }
    

     

    Any help?

  10. Inside of a while loop I need to echo several rows of info...easy enough.

     

    In the loop (for the sake off css) I need to distinguish between odd and even row numbers.

     

    
    <?
    connect();
    
    $documentQ=mysql_query("select * from docs");   
    while($doc=mysql_fetch_assoc($documentQ))
      {
       echo" 
       <li class=\"oddrow\"><a href="docs/notes/PrincipalsNotes_0911.doc\">November</a></li>
       <li><a href=\"docs/notes/PrincipalsNotes_0910.doc\">October</a></li>
       <li class=\"oddrow\"><a href=\"docs/notes/PrincipalsNotes_0909.doc\">September</a></li>
       ";
      }
    
    free($documentQ);
    
    ?>  
    
    

     

     

    Male sence?

     

    Any thoughts?

     

     

  11. What the heck am I doing wrong???

     

    
    <?
    if (isset($_POST['submit'])){
    
    echo $_POST['theNumber']."<br />";
    
    convertNumber($_POST['theNumber'])."<br />";
    
    echo $output; // <-- ???
    
    }
    ?>
    
    
    <form action="" method="post">
    <input type="text" name="theNumber" /><input type="submit" name="submit" value="go" />
    </form>
    
    

     

    Still notta.

  12. I added this to the bottom of the page...

     

    
    <?
    if (isset($_POST['submit'])){
    
    echo $_POST['theNumber']."<br />";
    
    convertNumber($_POST['theNumber']);
    
    }
    ?>
    
    
    <form action="" method="post">
    <input type="text" name="theNumber" /><input type="submit" name="submit" value="go" />
    </form>
    
    

     

    It output the number but still not the text...?

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