Jump to content

tkdasearls

New Members
  • Posts

    9
  • Joined

  • Last visited

tkdasearls's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. got it. didn't realize there was a difference between ' and "
  2. I realized where my error is at. it is returning a blank for "$_POST[$name1] when I actually need it to return $_POST[$name1]. How do I make it do this? I tried putting this part inside of quotes, but it is still returning blank and not the actual term "$_POST[$name1]". How do I make it do this?
  3. Is there a way to evaluate a php variable as code instead of a string? $sql1 = mysql_query("SELECT * FROM form WHERE id='".$id."'"); while($row1 = mysql_fetch_array($sql1)){ $id1 =$row1["id"]; $name1 =$row1["name"]; $name1 = str_replace(' ', '', $name1); $name1 = str_replace('-', '', $name1); $errorline .= "".$_POST[$name1]."=='' || "; } $errors = "if(".$errorline."){"; $errors .= '$error=1}'; eval($errors); echo $error; I am able to make $errors look the way I want it to.: if(=='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || ){$error=1} Where before the "==" is a post variable, thats why its not showing. I need to know how I can change this to code instead of a variable. As you can see, I tried the "eval" function, but it gives a T_IS_EQUAL error. Can anyone help? If I have to change my logic I will, but I think you probably get the point as to what I am trying to achieve. This is for error checking of a dynamically created form.
  4. I have a table named form with fields of id, name, type, and required. I have a script that currently only inputs a type, but not a name. the id is auto incremented so so I am using that has the "name" of the fields for now. my script then pulls these back and creates a form based on what is in this database, with field names of 1,2,3 etc. Then I need my code that I posted to update the "name" field in the data base when I type into the field in the form that was created. so if I type in the name of test for id 1, I need that to update in the database accordingly
  5. so, I think I figured out my looping problem so that it creates a query for each field. What I am running into now is syntax I guess as it isn't updating my database. here is what I have $sql = mysql_query("SELECT * FROM form"); while($row = mysql_fetch_array($sql)){ $id =$row["id"]; $name =$row["name"]; $type =$row["type"]; $required =$row["required"]; $line ="Update form Set name='".$_POST[$id]."' Where id='".$id."'"; if ($_POST['submit']){ mysql_query("".$line.""); } echo " ".$line; } So what this is doing is it is in code not shown, it is forming my form by grabbing data from the database and creating a form. this code then is creating the variables for this form for submission to the database. I think I got the basic structure down to create multiple updates when submit is clicked, but for some (obvious I'm sure) reason, it is not working. Can anyone offer any assistance to get the update query working correctly?
  6. I know it sounds kind of crazy. Like I said, I am newer to this so I am sure there is a better way, Im just not sure what that way would be. What I'm basically trying to do is build a "form builder" where each of the fields are stored in the database with an id, name, type, and if it is required. Then for any field type that is a "select" I have a different table where I will store those values. Do you have any recommendations on a way to easily do this?
  7. What Im trying to get at is how would i construct the update query I guess. I know how to do it if I set the names and the fields aren't created dynamically....but how do I create a query where the fields are created dynamically and there could be anywhere from 1 field to 100 fields with the "id" number being the fields "name".
  8. I am new to this and I was wondering if there is a way to update all form fields that are present. So here is the situation. I am storing multiple field types/fields in a database. The database then gets queried for all the form types and creates a field for each entry. So lets say that I have 2 entries that are text fields. I then use PHP to show the fields on the page. I then want to be able to type into these fields and store them in my database under the column "value". The only thing that I can't seem to figure out is how I submit these back to the database so that the proper field gets updated with the proper value. does this make sense? any help would be greatly appreciated!
×
×
  • 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.