Jump to content

MDanz

Members
  • Posts

    728
  • Joined

  • Last visited

Everything posted by MDanz

  1. the following code doesn't work. If i change 'textarea[]' to just 'textarea' it works. But i need textarea in an array. <SCRIPT LANGUAGE="JavaScript"> function counter(field,cntfield,maxlimit) { if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit); else cntfield.value = maxlimit - field.value.length; } </script> <form name="submitform"> <textarea name="textarea[]" cols="30" rows="1" onKeyDown="counter(document.submitform.textarea[],document.submitform.charleft,1000)" onKeyUp="counter(document.submitform.textarea[],document.submitform.charleft,1000)"></textarea> <br> <input readonly type="text" name="charleft" size="3" maxlength="4" value="1000"> characters left </form>
  2. i have imploded the array '$scope'. i want to put the results into a multiple where clause. The problem is how do i implement OR into the WHERE clause? $scopetwo = implode("keywords=",$scope); $getresults=mysql_query("SELECT * FROM message WHERE '$scopetwo' ORDER BY posted ASC",$this->connect);
  3. Is a comma seperated list in a column in Mysql good practice? or should i just loop the INSERT clause... so each value has it's own row?
  4. i have an array in the loop but it isn't building up with results. i want it to check if the array exists, if not then create the array. Then in next loop it pushes a new value into the array. Below isn't working?... while($row=mysql_fetch_assoc($get)); { $key = $row['keyword']; $scope= $_SESSION['scope']; if (!is_array($scope)) { $scopenew = array($key); $_SESSION['scope'] = $scopenew; } else { $scopenew = array_push($scope, $key); $_SESSION['scope'] = $scopenew; } }
  5. nvm i found a solution .. thx anyway
  6. yes, i've determined the problem though.. it's unchecked checkboxes aren't added into the array.
  7. ok i realised what is wrong... if i didn't click on the checkbox it isn't added to the array. <?php if(isset($_POST['submit'])) { print_r($_POST['tags']); } else { ?> <form action="test16.php" method="post"> <input type="checkbox" name="tags[]" value="1" /> <input type="checkbox" name="tags[]" value="2" /> <input type="checkbox" name="tags[]" value="3" /> <input type="checkbox" name="tags[]" value="4" /> <input type="submit" name="submit" value="submit" /> </form> <?php } ?> How do i change the code above so it's four values in the array, indicating what i have clicked on and what i haven't.
  8. ok i removed value <input type='checkbox' name='test[]' /> <input type='checkbox' name='test[]' /> and it displays Array ( [0] => on ) but it should be Array ( [0] => off [1] => on )
  9. ok i did that and this the result Array ( [0] => ) is it because value is blank? <input type='checkbox' name='test[]' value='' />
  10. i have a form with multiple checkboxes, with the same name. so i put them in an array like this. <input type='checkbox' name='test[]' value='' /> <input type='checkbox' name='test[]' value='' /> <input type='checkbox' name='test[]' value='' /> <input type='checkbox' name='test[]' value='' /> Now when i do print_r($_POST['test']; , it should display an array and if each checkbox has been ticked or not. it just comes up blank. Any idea?
  11. would this query select the 14th row? $getslide2 = mysql_query("SELECT * FROM Slides LIMIT 1,14",$this->connect);
  12. onclick isn't working... information should be displayed in the div with id='info' echo "<div id='$id' style='display:none;'>$name - $information</div>"; echo "<div class='productcol' onclick='Info($id)'><img src='$image' alt='$name' style='width:95px;height95px;' /></div>"; echo "<div id='info'></div>"; function Info(number) { var information = document.getElementById(number).innerHTML; document.getElementByID('info').innerHTML = information; }
  13. This code adds a new textarea when i press the "add" button. How do i alter the code so it can remove a textarea. e.g. i added 4 textarea's but i only intended to add 3, how do i delete the 4th textarea? <div id='newdiv'> </div> <input type='button' onclick='new()' name='add' value='Add' style='font-size:12px;' /> function new() { var htmlText = "<div class='container'><textarea name='reason[]' style='font-size: 10px;width:500px; height:50px;' onFocus='if(this.value==\"type more information"\") { this.value=\"\"}'>type more information</textarea></div>"; var newElement = document.createElement('div'); newElement.id = 'new1'; // Give the DIV an ID, if you need to reference it later... newElement.innerHTML = htmlText; var fieldsArea = document.getElementById('newdiv'); fieldsArea.appendChild(newElement); }
  14. it should work... when i press the button a textarea should be displayed in the div "newreason". It isn't working though. <input type='button' onclick='newreason()' name='reasonbutton' value='Next reason' style='font-size:12px;' /> <div id='newreason'> </div> function newoutcome() { var htmlReason = "<span class='font'>More Information</span><img src='arrowdown.jpg' /><br /> <textarea name='reason[]' style='font-size: 10px;width:500px; height:50px;' onFocus='if(this.value==\"type more information\") { this.value=\"\"}'>type more information</textarea>"; var newElementone = document.createElement('div'); newElementone.id = 'newreason1'; newElementone.innerHTML = htmlReason; var fieldsAreaone = document.getElementById('newreason'); fieldsAreaone.appendChild(newElementone); }
  15. i did this but then realised it won't total the `rating` for a DISTINCT username. How can i change it so that it totals the rating for a username? $getuser = mysql_query("SELECT DISTINCT username, rating FROM block WHERE category='$category' ORDER BY `rating` DESC",$this->connect); while ($row = mysql_fetch_assoc($getuser)){ $theuser = ucfirst($row['username']); $rating = $row['rating']; echo "<div class='leaderboard'><ul><li><a href='profile.php?user=$theuser'>$theuser</a></li><li>$rating</li></ul></div>"; }
  16. nvm.. i had to put the echo in the while loop
  17. this is weird i have two rows.. name sid rating f 505 2 e 505 5 with that query it keeps on returning f? i need the sid='505' in the where clause .
  18. i tried this but it doesn't work. rating is a column with integer type. it is returning the wrong row with the lowest rating. how do i get the the highest rating(integer) in the WHERE clause? $getrest = mysql_query("SELECT * FROM block WHERE sid='505' ORDER BY 'rating' DESC LIMIT 1") or die(mysql_error()); while($row=mysql_fetch_assoc($getrest)) { $name= $row['name']; } echo $name;
  19. I've already copyrighted it... but is that enough?. incase someone stole the website idea (methodology)? ... can you protect those things in a website? i assume you can't because there would be only one website of it's kind.. like just youtube and no other video streaming sites.
  20. nevermind found out to use in_array() and i put apostrohes around $category..
  21. $c = "non-specific"; $categoryex = explode(", ",$c); $category = "non-specific"; if(array_key_exists('$category', $categoryex)) { echo "yes"; } it should echo yes because $category='non-specific' and 'non-specific' is in the array...
  22. i used LIKE $search% and it worked. thanks anyway
  23. but what if in the column it has "test1, test2, test3".. i can't use column_name="search_term"
  24. for example.. in one column it has "test1, test2, test3, test4" .... when i search for test1... i only want rows that have 'test1' in them. $search = test1 i've tried LIKE %$test1% but it get's all rows with the word 'test' in it... i want only rows with the word 'test1' in it.
×
×
  • 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.