Jump to content

bulrush

Members
  • Posts

    185
  • Joined

  • Last visited

    Never

Everything posted by bulrush

  1. It's tricky because I'm new to PHP. I just started going through this book last week, and I'm not sure how to construct a PHP variable inside the double quotes of my query statement. Do you think this would work? for ($i=1; $i<=10; $i++) { $descvar=$_POST['txtDesc'.$i]; $modelvar=$_POST['txtModel'.$i]; $query = "INSERT INTO mytable (desc, model) VALUES ('$$descvar', '$$modelvar')"; //... do query } //for i
  2. Maybe I should clarify. My php page is called "entry.php". When the user goes to this form the first time, it shows a form with 10 rows. If they click the Save button (named "submit") then the form reloads itself and saves all 10 rows to the table. So, when the form is submitted, and the form fields are named txtDesc1, txtDesc2, txtModel1, txtModel2, the values are saved in $_POST['txtDesc1'], $_POST['txtDesc2'], etc. They are not stored in variables $txtDesc1 from my understanding, unless I manually copy the values from $_POST['txtDesc1'] to $txtDesc1.
  3. But txtDesc1 is not a variable at this point, is it? It's the name of a form field (text box). Isn't that different than a PHP variable? A form is in HTML, a variable is in PHP. I have not saved the value of the form field in a PHP variable yet. Perhaps this will work: for ($i=1; $i<=10; $i++) { $descvar='txtDesc'.$i; $modelvar='txtModel'.$i; $query = "INSERT INTO mytable (desc, model) VALUES ('$$descvar', '$$modelvar')"; //... do query } //for i
  4. Ok. So if I name the form fields txtDesc1, txtDesc2, txtDesc3, txtModel1, txtModel2, txtModel3, etc for rows 1, 2, and 3. How would I construct the field names for my INSERT statement inside a loop? for ($i=1; $i<=10; $i++) { $query = "INSERT INTO mytable (desc, model) VALUES (??, ??)"; //... do query } //for i
  5. I think so. In Visual Basic I think it's called a Data Grid, or simply a Grid control. I'm not sure what the PHP term is. But yes, I want to display n rows on the New Record Entry screen, where each row would become a new record in a table. Later, I will make a screen to edit existing records. This screen is for mass entry of new records.
  6. Maros174, Can you tell us which version of Jquery you are using which gives the problem? Also which OS name and OS version, and which IE version you are using? My friend in the next cubicle uses Jquery, I wonder if he has this problem.
  7. I am somewhat new to PHP. I am going through a PHP tutorial book "Head First: PHP and MySql". So I know the PHP basics. But none of their examples cover what I need to do in a real world application. I would like to make a form with many columns per row, with multiple rows. Ideally each row would be an entry in an array, so the user can enter 10 rows at once, and save them all at once. My form with one row looks like this: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table> <tr><td>Description <td>Number <td>Price <tr><td><input type="text" name="txtDesc" value="<?php if (!empty($desc)) echo $desc; ?>" size="45"> <td><input type="text" name="txtModel" value="<?php if (!empty($model)) echo $model; ?>" size="20"> <td><input type="text" name="txtPrice" value="<?php if (!empty($price)) echo $price; ?>" size="6"> </table> <p> <p>Commands: <input type="submit" name="submit" value="save"> </form> Now, how can I turn this into 10 rows, like an array?
  8. Thank you.
  9. If I have an array assigned like this: $myarray['one']=1; $myarray['two']=2; How do I count the number of values in this array? I need this count to do so me debugging. I think my array is empty but cannot be sure until I count the elements in it. Thanks.
×
×
  • 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.