Jump to content

balkan7

Members
  • Posts

    234
  • Joined

  • Last visited

Everything posted by balkan7

  1. Hi hansford Thanks for helping but i think this is not the best solution because if i had in database question with 5 answers and when i edit this will look same: <? foreach($result as $data) { echo '<input type="text" name="answers[]" class="required-fields" value="'.$data['answer'].'" />'; } ?> I think is better to use for loop for limit inputs....
  2. Hi How can limit only required input fields cannot be empty. <form name="test" method="post" action="test.php"> <label for="quest"> <input type="text" name="quest" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="submit"> <input type="submit" name="submit" value="Submit" /> </label> </form> Following function working only on all empty input fields, i need help to enable button when required fields is not empty. $(document).ready(function() { var $submit = $("input[type=submit]"), $inputs = $('input[name=quest], input[name=answers[]]'); function checkEmpty() { // filter over the empty inputs return $inputs.filter(function() { return !$.trim(this.value); }).length === 0; } $inputs.on('keyup', function() { $submit.prop("disabled", !checkEmpty()); }).keyup(); // trigger an initial blur });
  3. Hi, i need help for get data from following tables: questions: id question options: id ques_id value votes: id option_id voted_on ip Question: What is your favorite color. Option1: Test 1 - 83 votes Option2: Test 2 - 0 votes Option3: Test 3 - 51 votes I'm using this sql for result: SELECT options.id, options.value, COUNT(*) as votes FROM votes, options WHERE votes.option_id=options.id AND votes.option_id IN(SELECT id FROM options WHERE ques_id=2) GROUP BY votes.option_id; so i get this: id value votes 1 Test1 83 3 Test3 51 because there is not votes for option Test2 and doesn't show it. i need help to get all data like this: id value votes 1 Test1 83 2 Test2 0 3 Test3 51
  4. Hi Psycho Thanks for reply i found solution: $v = implode( "|", $votes ); $v = array($v); $a = implode( "|", $answers ); $a = array($a); $x = array_merge($check, $v, $a); echo json_encode($x);
  5. Thank you for reply DavidAM With this code i get result from array: function(data) { if (data[0] == "ok") { show_results(id,data[1],data[2], 'voted'); } data[1] = votes data[2] = values <button onClick="show_results('2','67|38|38|','Test1|Test2|Test3|','no'); return false;">Result</button>
  6. i have tried with this but i get this result: "ok","67|","38|","38|","Test1|","Test2|","Test3|" Pls help me to get this result: "ok","67|38|38|","Test1|Test2|Test3|" <? $answers = array(); $votes = array(); $check = array('ok'); foreach($results as $rows) { $votes[] = $rows['votes']."|"; $answers[] = $rows['value']."|"; } $test = array_merge($check, $votes, $answers); echo json_encode($test);
  7. Thank you for reply ginerjm. Actually i need this result: ok64|33|37|Test1|Test2|Test3| Because i send it to JSON: echo json_encode($check); After i get result i use javascript for each result: votes = votes.split("|"); values = values.split("|");
  8. Yes This is result of votes: 64|33|37| This is result of values: Test1|Test2|Test3| So i want this result push in array and get this result: ok64|33|37|Test1|Test2|Test3|
  9. I need help for get this result in foreach loop. ok64|33|37|Test1|Test2|Test3| But with my looping i get this result: ok64|Test1|33Test2|37|Test3| <? $check = array('ok'); foreach($results as $rows) { array_push($check, $rows['votes']."|"); array_push($check, $rows['value']."|"); } ?>
  10. Hi selathe Thanks for helping but i'm not able to install PECL extensions.
  11. Result for dates is: Quis nostrud 0510 Result for non dates is: Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat.
  12. $text= "Quis nostrud 05.10.2011 exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat."; $regExp = '/^([^.]+)\\.\s/'; $replace = '<strong>$1</strong>.'; $text = preg_replace ($regExp, $replace, $text); $test = explode(".", $text); $display1 = nl2br($test[0]); $display2 = nl2br($test[1]); Result is: Quis nostrud 0510 (without apply tags <strong>)
  13. I'm trying this one but doesn't work $regExp = '/^([^.]+)\\.\s/';
  14. For the first, just add a space after the period in the RegExp. Should handle dates just fine then. Please example with regex
  15. Tested and working, but if exist date like 05.10.2011 highlighting stop in 05. can be this skip ? And text separated with two variables: $highlighted = "Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."; $more = "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat.";
  16. Hi guys I need highlight text from variable like this one: $text = "Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat."; If preg_match first dot in text i want replace it like this bellow: Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat.
  17. Hello Barand How can add for each checkbox (checked='checked') $id = $_GET['id']; $sql = mysql_query("SELECT * FROM table WHERE id=$id"); $data = mysql_fetch_array($sql); $checkbox = data['c']; $test = array(1 => "A", 2 => "B"); foreach ($test as $k => $v) { if ($checkbox == $k) { $checked = " checked='checked'"; echo "<input type=\"checkbox\" name=\"c[]\" value=\"$k\"$checked> $v <br>"; } How can i retrieve if column: c == 1 only checked A c == 2 only checked B c == 3 checked A and B ?
  18. Hello guys I'm tried to save data from 2 checkbox into one column in database and retrieve. In this case i have this: <? $test = array(1 => "A", 2 => "B"); foreach ($test as $k => $v) { echo "<input type=\"checkbox\" name=\"c\" value=\"$k\"> $v <br>"; } ?> If those 2 checkbox selected i want save in base like array 1,2 After this check from database if column data is: 1 = show pic 1 2 = show pic 2 1,2 (array) = show pic 3
  19. Ok i have seo function for replace names from category like this: cname: Foo Bar cseo: foo-bar so i don't know which is the best method to update every cname column to cseo column
  20. I want to update empty columns in datebase, so i have this table: category - cid - cname - cparent - cseo Column cseo is empty i want update it with cname column with seo function. This foreach doesn't work code is: <?php $cats = mysql_query("SELECT * FROM category WHERE cparent ='4' ORDER BY cid DESC"); while ($data = mysql_fetch_array($cats)) { if ($data['cseo'] == ""){ foreach ($data['cname'] as $seo_names) { $seo_link = seo($seo_names); $result = mysql_query("UPDATE category SET cseo='$seo_link' WHERE cid='".$data['cid']."'"); if ($result) { echo "Done!"; } } } }
  21. If i use this code then show: gallery?show=5 if i remove $html = str_replace('gallery.php','gallery',$html); then show me gallery/5 How can fix it ? $html = str_replace('gallery.php','gallery',$html); $html = preg_replace('/gallery\.php\?show=([0-9]+)/i','gallery/$1',$html);
  22. Then what's wrong with my site show me gallery?show=5 .htaccess RewriteRule ^gallery/([0-9]+)/?$ gallery.php?show=$1 [QSA,L]
×
×
  • 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.