Jump to content

Waddy

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Waddy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Awesome! That is so much more tidy than my effort, thanks for the help, I have implemented and it works great. Appreciate the help 2-d Marked as solved!
  2. Hi 2-d, Thanks for that, I did try that yesterday, I dont think it will work for this case as I think I may need to set a variable for each "option" to show a checked/unchecked checkbox for the options they choose when print to screen. I was trying to reduce the if statements, instead of doing one for each option as there are quite a few. Aicd Wash, neutralise, clean, grind and many more. I have a form with the usual, name, address etc, and have about 10 checkboxes for where they can choose options, these are stored in the DB. I want to get the data from the form and print it to a page for them, showing whats been chosen, with the options they chose shown as a checkbox, checked or unchecked. This now works thanks to your help, but it looks like i need an if statement for each one to create a variable to use in the html.. If that makes sense. Just not sure if its possible somehow due to my lack of knowledge, I have thought of creating a function but not sure if thats the solution either. Thanks for the help.
  3. Ok nearly there, just one question if you can help, I have several rows I need the if statement to run against if ! empty or empty, i.e clean, acid_wash, neutralise etc. Basically the user chooses the options they require using checkboxes on the form, about 10 options, I would like to display the options chosen with a checkbox checked or unchecked depending if the row is empty or not. How can i get the if statement it to use these several rows instead of writing multiple if statements? So i can use <tr> <td><?php echo "Acid Wash<input style='font-size:10px;' name='acid_wash' type='checkbox' $checked >";?> </td> </tr> <tr> <td><?php echo "Neutralise<input style='font-size:10px;' name='neutralise' type='checkbox' $checked>";?> </td> </tr>
  4. Thanks for the help 2-d, that did the trick, it works. I just need to now workout how to have that if statement run against several rows, not just clean. i.e clean, grind, neutralise rows in the DB and implement into the HTML some way. if ( ! empty ( $row ['clean'] ) ) { ///if it's 1 (true) then we add 'checked' to a variable we will use in the input //to cause it to be checked $checked = 'checked'; echo "Clean<input style='font-size:10px;' name='clean' type='checkbox' $checked>"; }else{ //if the value is 0 (false) we set the variable to be empty, not checked $checked = ''; echo "Clean<input style='font-size:10px;' name='clean' type='checkbox' $checked>"; }
  5. Hi, I just cannot seem to get this to work, have been testing and searching all morning and not getting anywhere. I have a form with a series of checkboxes which populates the MySqL database, this works fine. Trying to print the results from the form if the row is empty show an unchecked checkbox, if there is a value show a checked checkbox. I have tested my if statement and can echo correctly wether empty or not empty, just cannot get the checkbox to be unticked if there is no value in the row while ($row = mysql_fetch_array($qry, MYSQL_BOTH)) { // show total fields for debugging // $totalfields = mysql_num_fields($qry); // print ($totalfields) ; // if ( ! empty ( $row ['acid_wash'] ['neutralise'] ['clean'] ) ) { if ( ! empty ( $row ['clean'] ) ) { ///if it's 1 (true) then we add 'checked' to a variable we will use in the input //to cause it to be checked $checked = 'checked'; // test if row has data echo "full"; }else{ //if the value is 0 (false) we set the variable to be empty, not checked $checked = ''; // test for no value echo "empty" ; } To Display Result: <tr> <td>High Pressure Clean <input style='font-size:10px;' name='clean[]' type='checkbox' checked='$checked'></td> </tr> The empty and full test echos do seem to work, showing me the if statement works. The problem is even when the row is empty the checkbox shows checked.... Thanks.
  6. Hi, I found it hard to find the information to achieve this, suprised me. This is how i achieved the result. On one (clients) table have an auto increment row (id), use this as your primary key. Create another table say 'orders', add a row called client_ID then you need to create a foreign key on this table linking to the client_id. ALTER TABLE ORDERS ADD FOREIGN KEY (client_id) REFERENCES CLIENTS(ID); On your client insert grab the ID the client gets, use that to insert into order (client_ID), that will give both the same ID for when you use the above query. "WHERE client.ID = order.client_ID"; The result gives you the client and order related to the client. I hope that helps.
  7. Solved by Judda in IRC, thanks! Provided Example: <input type = 'checkbox' <?php if ( ! empty ( $row [ 'field' ] ) ) echo 'checked = \'checked\'';?></input>
  8. I have a number of fields to display on a page, from a mysql query, some fields are empty, some not. depends on what they choose on the original form. I am trying to display on the form results on a page formatted using the below: If the mysql field is empty, display an unchecked check box next to the result. If there is data in the field display a check box ticked. What can i do to achieve this, can you point me in the right direction? Results page using echo: </TD><TD>Options: <input type='checkbox' CHECKED>". $row[17]. " </TD> = is not empty field </TD><TD>Options: <input type='checkbox' UNCHECKED>". $row[17]. " </TD> = emtpy ,mysql field </TD><TD>Options: <input type='checkbox' CHECKED>". $row[18]. " </TD> = not empty mysql field from query </TD><TD>Options: <input type='checkbox' UNCHECKED>". $row[18]. " </TD> = Empty field in mysql I am trying to show Rows 1 to 16 to display normally, rows 17 to 30 use the above logic. There are about 30 fields to display like this, the others are required fields and are displayed no matter what.
  9. Hi, I spent ages trying to find the correct info for this myself. This is what i worked from and it works. My tables have foreign id's with relationship to primary key. Example: $query="SELECT * FROM table1,table2,table3 WHERE table1.t1_ID=table2.t2_ID AND table2.t2_ID=table3.t3_ID"; Hope it helps
  10. Thanks, thats what i was looking for, couldnt find and easy example to follow and wasnt sure what it was called. Kate helped me in IRC. (thanks Kate) I have made the query for the two tables and it works fine. Did a three table query and it worked also. Example: $query = "SELECT client.ID, order.client_ID ". "FROM client, order ". "WHERE client.ID = order.client_ID"; Edit: added query for others benefit.
  11. Hi, I have two tables, clients and options. In MySQL I have created a relationship, primary key is ID in clients table, Foreign key = client_ID in table options. I can insert using mysql_insert_id(); as the value for client_ID in options. This all works fine. Client ID matches ID My question is, how can i perform a select query to get the client details from table client and also the options values from the option table? Preferably using the matching ids... I have looked and tried many things and would appreciate a prod in the right direction, best method... In a nutshell i want to look at the client details and also see the options they picked.
×
×
  • 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.