Jump to content

mlitch

Members
  • Posts

    9
  • Joined

  • Last visited

mlitch's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. My goal seems simple: a dark green background to my table with lines alternating with a lighter green background. The problem is that I can't get rid of the areas to the left and right of each <td> where the dark green is bleeding through. I've tried setting the left/right border property to 0, the left/right margin property to 0, the left/right border property to 0; the border color to the lighter green—all with no results. The only thing that works is to use "cellpadding='0' cellspacing='0'" with the <table> tag, but this also affects the vertical spacing, which I don't want to make any more compact. I can't figure out what I'm missing here. Thanks.
  2. mlitch

    variable variables

    Because I'm not good with arrays . . . but now that I see how to use it, I will! Thank you for showing me how to deal with the POST variable!!!!!
  3. mlitch

    variable variables

    The problem is with how to use curly braces with the $_POST variable, because this code: $i=1; while ($i<=$how_many) { ${"variable_$i"}=1000+$i; echo 'variable '.$i.' is '; echo ${"variable_$i"}; echo '<br/>'; $i=$i+1; } yields (as I expect): variable 1 is 1001variable 2 is 1002variable 3 is 1003variable 4 is 1004
  4. mlitch

    variable variables

    To be more concrete, this code echo $_POST['recipient1']; echo '<br/>'; echo $_POST['recipient2']; echo '<br/>'; echo $_POST['recipient3']; echo '<br/>'; echo $_POST['recipient4']; echo '<br/>'; $i=1; while ($i<=$how_many) { ${"variable_$i"}=$_POST{"['recipient$i']"}; echo 'variable '.$i.' is '; echo ${"variable_$i"}; echo '<br/>'; $i=$i+1; } yields this: 612113variable 1 is variable 2 is variable 3 is variable 4 is Why can't I get the "while" loop to give me the same results as the statements before the "while" loop? (The variable $how_many equals 4 in this example.)
  5. mlitch

    variable variables

    I need to write PHP code to handle a form. The form may have zero or more fields that are named "recipient1", "recipient2", "recipient3", etc. If there are two fields, I need to capture those fields. If there are six, I need to capture all six. Maybe there are none. I could write if (isset($_POST['recipient1'])) { $thisvariable1=$_POST['recipient1']; } if (isset($_POST['recipient2'])) { $thisvariable2=$_POST['recipient2']; } if . . . and so on. Maybe I could do 10 of these, but what if the form has 11 fields (recipient1 through recipient11)? I can't just write a hundred "if" statements. Surely there's some way to write a code that allows me to replace the "1", "2", and so on with some variable. The form itself will pass along how many fields there are. How can I use that number to automatically generate this kind of code that assigns the $_POST data to variables? Does that make more sense? How can I do this? That's my question.
  6. mlitch

    variable variables

    My PHP-generated form file will generate any number of text fields called "recipient"+an integer, so "recipient1", "recipient2", etc The PHP file handling the form submission will not know how many fields there are, so I need to get something like the following logic: $i=1; $max=how many fields there are (it will know this from a mysqli_num_rows variable being passed) while ($i <= $max) { $recipient+$i = $_POST[recipient+$i] } In other words, as long as $i is less than or equal to the maximum number, generate a variable named "recipient" concatenated with $i and assign it the value of $_POST['recipient concatenated with $i']. I can't wrap my little brain around this. Help?
  7. mlitch

    if condition

    I had to think about this for an hour or two, but now I get it. It makes perfect sense. Thank you!
  8. mlitch

    if condition

    Great. One more thing to learn. If all PHP code executes before javascript, though, why does the confirm box come up? That's executed before the rest of the PHP code. I don't understand why the javascript condition wouldn't also be executed before resuming with the PHP code. Sorry for being such an amateur.
  9. mlitch

    if condition

    Can anyone tell me why this Javascript isn't working? (The following is the PHP code:) if ($quantity>$inventory) { echo '<script language="javascript"> var i = confirm("There are '; echo number_format($inventory); echo ' copies in inventory in '; echo $warehouse_name; echo '.nnThis order is for '; echo number_format($quantity); echo ' copies.nnThat is '; echo number_format($difference); echo ' more than are available.nnClick OK to create a backorder for this itemnor Cancel to abort."); if (!i) window.close();'; echo '</script>'; } The idea is simple: A confirm box opens with a message. If the user clicks OK, the PHP code continues. If the user clicks Cancel, the window should close without executing any more PHP code. Right now, it doesn't matter which button you click: the PHP code just continues regardless. How can I fix this?
×
×
  • Create New...