Search Results

Search found 2 results on 1 pages for 'budove'.

Page 1/1 | 1 

  • Select multi-select form from array

    - by Budove
    Here's the issue. I have a database column called pymnt_meth_pref, which contains a comma separated string of payment methods chosen from a multiselect form. <td>Payment Methods Used:<br /> <input type="checkbox" name="pyment_meth_pref[]" value="Cash">I can pay with cash.<br /> <input type="checkbox" name="pyment_meth_pref[]" value="Check">I can pay by check.<br /> <input type="checkbox" name="pyment_meth_pref[]" value="Credit Card">I can pay by credit card.<br /> <input type="checkbox" name="pyment_meth_pref[]" value="Paypal">I can pay with Paypal.<br /> </td> This array is posted to a variable and turned into a comma separated string if (isset($_POST['pyment_meth_pref'])) $pymntmethpref = implode(", ", $_POST['pyment_meth_pref']); if (isset($_POST['pyment_meth_acc'])) $pymntmethacc = implode(", ", $_POST['pyment_meth_acc']); This is then inserted into the database as a comma separated string. What I would like to do, is take this string and apply the values to the original form when the user goes back to the form as 'pre-selected' checkboxes, indicated that the user has already selected those values previously, and keeping those values in the database if they choose to edit any other information in the form. I'm assuming this would need to be done with javascript but if there is a way to do it with PHP I'd rather do it that way.

    Read the article

  • MySQL query to find the most popular value in a column joined by another value in a second table

    - by Budove
    I have two tables: users: user_id, user_zip settings: user_id, pref_ex_loc I need to find the single most popular 'pref_ex_loc' from the settings table based on a particular user_zip, which will be specified as the variable $userzip. Here is the query that I have now and obviously it doesn't work. $popularexloc = "SELECT pref_ex_loc, user_id COUNT(pref_ex_loc) AS countloc FROM settings FULL OUTER JOIN users ON settings.user_id = users.user_id WHERE users.user_zip='$userzip' GROUP BY settings.pref_ex_loc ORDER BY countloc LIMIT 1"; $popexloc = mysql_query($popularexloc) or die('SQL Error :: '.mysql_error()); $exlocrow = mysql_fetch_array($popexloc); $mostpopexloc=$exlocrow[0]; echo '<option value="'.$mostpopexloc.'">'.$mostpopexloc.'</option>'; What am I doing wrong here? I'm not getting any kind of error from this either.

    Read the article

1