Jump to content

mr. big

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.dhreport.com

Profile Information

  • Gender
    Not Telling

mr. big's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks so much for your help, Daniel0.  I feel silly discovering that the main problem was such a basic syntax mistake -- it's the power of misdirection, as I was concentrating on learning function-building. I doubly appreciate the code, as I'm not comfortable with the format and it will give me something tangible to learn.
  2. Thanks for the response, but it doesn't work. I think this is on the right track, though -- the POST variable is not available to the function for a reason I don't understand.  I'm still working away on this  :'( This is really confusing, because $POST is a superglobal.  I'm going to try $REQUEST.
  3. This really isn't all that hard, but using php you are going to get a page refresh each time you click a column.  This really would be better done with more server-side power than php can give you.  I'd use AJAX with a php backup for people with javascript disabled. My first thought would be to do it as a dropdown POST form then pull the second and third columns from database queries.
  4. I have a sticky form (I actually invented the sticky code for non-text buttons myself, not that it hasn't been done a thousand times before LOL).  Here's the applicable form snippet: [code] Do you do regular weight training?<br> <input type="radio" name="muscle" value="1" <?php if ((!isset($_POST['muscle'])) or ($_POST['muscle'] == "1")) echo  'checked="checked" '; ?> >&nbsp; Occasionally or never.<br> <input type="radio" name="muscle" value="1.05" <?php  if ((isset($_POST['muscle'])) and ($_POST['muscle'] == "1.05")) echo  'checked="checked" '; ?>                         >&nbsp; Yes, as part of my exercise routine.<br /> <input type="radio" name="muscle" value="1.2" <?php if ((isset($_POST['muscle'])) and ($_POST['muscle'] == "1.2")) echo  'checked="checked" '; ?>                       >&nbsp; Yes and I have gained significant muscle bulk.<br /> [/code] The php tests the first entry and writes[i] checked="checked"[/i] into the form 1) by default, i.e. if no value is set, or 2) if it has previously been chosen.  It tests subsequent buttons and inserts [i] checked="checked"[/i] only if the button has previously been chosen.  So far so good. I have tried fifty ways from Sunday to make a formula that will work in the stickies so I can get rid of the awful clutter.  Here's my last try: [code] <?php function defRadio ($namex, $valuex)  { if ((!isset($_POST['$namex'])) or ($_POST['$valuex'] == "$valuex"))  { return 'checked="checked"'; } else { return 'foobar'; } } function altRadio ($namey, $valuey)  { if ((isset($_POST['$namey'])) and ($_POST['$valuey'] == "$valuey"))  { return 'checked="checked"'; } else { return 'foobar'; } } ?> <div class="bmi_l"> <span class="b"> Do you do regular weight training?</span><br> <input type="radio" name="muscle" value="1" <?php $ch=defRadio('muscle', 1); echo $ch; ?> >&nbsp; Occasionally or never.<br> <input type="radio" name="muscle" value="1.05" <?php  $ch = altRadio('muscle', 1.05); echo $ch; ?> >&nbsp; Yes, as part of my exercise routine.<br /> [/code] The problem I'm having is that the form always fills in the first button, even if the second (third, fourth) button was previously checked.  The word "foobar" does echo in the altRadio choices.  I'm thinking the $_POST values aren't making it to the formula, but I've tried every way I know to get them in. Herlp! (The "foobar" value is just for debugging.)
  5. [code]//INSERT NEW RECORD   $artist_name_file=$_FILES['artist_name_file']['name'];   $object_SQL_insert="INSERT INTO artists (artist_name_file) VALUES ('$artist_name_file')";   $bool=mysql_query($object_SQL_insert);[/code] You could easily know a lot more than I do, but here's how I'd do it: [code] $a = $_POST['artist_name_file']; if ($a)  { $query = "INSERT INTO artists (artist_name_file) VALUES ('$a')"; $result = mysql_query ($query); $aid = mysql_insert_id();          // Get the article ID.                 if ($aid > 0) {            // New article has been added. echo ("The artist's name posted successfully into artists as $a at id $aid") <br />");                 } else {                               echo "Something went wrong!";                 } } else { echo 'The variable $a didn't get a value'; } [/code]
  6. Yeah, thanks, it looks really good but I need something more comprehensive. 
  7. It's not really a simple question at all. Basically, what I do is to create a html form with one input section for each column, the input type being appropriate, i.e. radio buttons for boolean or a small set, checkboxes for enum, text or textbox for text, etc.  I use method $_POST and action = the same file name, although you could put the php in a separate file and that would be the action.  The name of each input will become a value in the POST array, so name="color" in the form input will become $_POST['color']. Above it in the same file I put a php section that takes the POST data, gives it easier variable names, then does a MySQL INSERT query.  E.g., $c = $_POST['color'], then "INSERT INTO elephants (color, favorite_song) VALUES ('$c','$fs")"; Ullman's book "PHP and MySQL" has a good section on this.
  8. I don't know if this is the right forum to ask, so I apologize in advance if it isn't. I'm doing pretty well with php and mysql, but I'm lost when it comes to file-handling.  Can anyone recommend a good, comprehensive book on the subject? TYIA
  9. Notepad. I guess the world is split into handcoders and Dreamweavers. Yeah I get syntax errors -- never more than three so far -- but it takes me all of 30 seconds @ to clean them up. Actually I use a basic HTML editor for just one reason: the good undo feature.
  10. You'd be more likely to get a good response if you posted the code.
  11. Since you already have a relationship between the value type and customer type in a table, I don't see why you'd want to have the exact same information in yet another table.  Any work you need to do could be done by a query to the Purchase Order table.
  12. This part looks good to me. I'm pretty much a noob but I use a nearly identical code, only the last line of mine makes the insertion query using $hp instead of giving $_POST['home_phone'] a second variable name. Might be in another part of the code.
  13. I made a php form to edit articles in my MySQL database, with a $_GET passthrough of variable $id, which represents the primary key for the table. At the end of the form, after the hidden "submitted" input, I have a line[code]echo '<input type="hidden" name="id" value="' . $id . '" />[/code] The query won't perform the update without this line, and I just wondered what it does, theoretically.  I was having a terrible time until I started looking for scripts and saw this somewhere.
×
×
  • 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.