Jump to content

Andy11548

Members
  • Posts

    163
  • Joined

  • Last visited

Everything posted by Andy11548

  1. Hello, Are you trying to make it so that while the mouse is on the navigation button the background of the button changes to red, once the mouse is removed, it should change back to it's default colour? Sorry, I didn't understand your query.
  2. Hello, I've got an overlay on my website which loads up when a button is clicked. Once the button it clicked, it parses a PHP file into a div which generates the content to be shown in the div. However, I can't seem to get the jQuery to work on buttons which are imported unless I call another Javascript file while populating the div. Does anyone know how I can get this so that it will work weather the buttons are there as the page is loaded or after extra content is brought in? I'm presuming it's due to the $(document).ready(function(){ }); Current jQuery $(document).ready(function() { $('.CloseOverlay').click(function() { $('.OverlayContainer').hide(); }); $('.Approve').click(function() { var UserID = $(this).val(); var Status = "GetData"; $.post('/Admin/Users/Verified/approveUser.php', { UserID: UserID, Status: Status }, function(data) { $('.OverlayWrapper').html(data); }); $('.OverlayContainer').show(); }); }); P.S - I'm pretty shocking at jQuery/Javascript! Thanks in advance, Andy
  3. As another bit of advice, I would upgrade from MySQL to MySQLi
  4. The most elegant way would be to have multiple tables in the database. Unfortunately, you will find it hard to find an elegant way of writing the code with the database structure you've got. It's probably not the best way in the example I've put, but it isn't going to get any better really without the multiple tables... Also, in the first query, you may want to put ORDER BY `company` ASC in there, otherwise it won't work 100% unless all of the specs/company names are directly under each other in the database.
  5. What do you mean you don't have control over this? Surely you have control over your MySQL Databases? This is a quick piece of code that works how you want it. It's far from elegant though... <?php $Connect = mysql_connect("HOST", "USER", "PASS") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $LastCompany = ''; $Query = mysql_query("SELECT * FROM `company`") or die(mysql_error()); while($Fetch = mysql_fetch_assoc($Query)) { if($LastCompany !== $Fetch['Company']) { echo '<ul>'; echo '<li>' . $Fetch['Company']; echo '<ul>'; $Query2 = mysql_query("SELECT * FROM `company` WHERE `Company`='" . $Fetch['Company'] . "'") or die(mysql_error()); while($Fetch2 = mysql_fetch_assoc($Query2)) { echo '<li>' . $Fetch2['Specs'] . '</li>'; } echo '</ul>'; echo '</li>'; echo '</ul>'; $LastCompany = $Fetch['Company']; } } ?>
  6. From a personal perspective, it may be better in this case to have two different tables to store the data: Example: tbl.company: company_id company_name tbl.specs: spec_id company_id spec Once it's set up like this, it should be easier to display *ALL* the specs for Company1 by selecting all the entries in tbl.specs by filtering only by the company ID. The code below is an example and doesn't use best practices. You should be using "JOIN" for these sort of queries, but as I don't understand them well and it takes me a little while to write it, I'll show you the bad practice way which does work... <?php $CompanyQuery = mysql_query("SELECT * FROM `company`") or die(mysql_error()); while($FetchCompany = mysql_fetch_assoc($CompanyQuery)) { $SpecsQuery = mysql_query("SELECT * FROM `specs` WHERE `company_id`='" . $FetchCompany['company_id'] . "'") or die(mysql_error()); echo '<ul>'; echo '<li>' . $FetchCompany['CompanyName']; echo '<ul>'; while($FetchSpec = mysql_fetch_assoc($SpecsQuery)) { echo '<li>' . $FetchSpec['spec'] . '</li>'; } echo '</ul>'; echo '</li>'; echo '</ul>'; } ?> Something like that would work (with a few tweaks), but as I said, this is NOT the best way to do it by any means.
  7. Hello All, If I had a table with results in from a Database, how would I go around moving a row up/down and refresh the data in the row? Would the best method be to have a seperate column in the database like 'RowOrder' and then once the arrow is pressed, swap it with the corresponding value and refresh the page? Thanks in advance, Andy
  8. Thanks both for the suggestions. I'll have a think, and when I get to that part, I'll choose the most appropriate. Thanks again! Andy
  9. Hello, I'm looking to build my own Shopping Cart (Just to have a mess around), and I'm wondering what the best way of Adding/Removing items to the cart would be? Any help/assistance would be grateful. Kind Regards, Andy
  10. Never said I wanted anyone to do it for me. I said I wanted help. Massive Difference.
  11. Ive made a tracking system for the main body of my website. Im now needing to implement it into the ohobb forums. however. i dont know how phpbb works properly so i need some help writing a script to get the IP, path name and page title. Thanks, Andy
  12. First of all, I cba editing PHPBB's code. Don't post useless shit.
  13. Hello, In the database I have a field named "topic_time", but the value is 1346880835. How do I display that in D/M/Y format? Thanks, Andy
  14. Well, it's give me no errors and the display is all the same. How would I go around using that then? Thanks, Andy.
  15. Hello, I could do with some help joining this query in to another query. I'm completely and utterly blagged on what I'm doing now. I need this query: mysql_query("SELECT * FROM `users` WHERE `username`='".$_SESSION[username]."'"); placed into this one: mysql_query(" SELECT f1.cat_name as CatName, f1.cat_id as CatID, f2.cat_id as SubCatID, f2.sub_id as SubID, f2.sub_name as SubName, f2.sub_desc as SubDesc, f3.topic_id as TopicID, f3.user_id as UserTopicID, f3.topic_name as TopicName, f3.topic_message as TopicMessage, f4.user_id as UserReplyID, f5.username as Username, (SELECT COUNT(*) FROM forum_topics as f3 WHERE f3.sub_id = f2.sub_id) as TopicAMT, (SELECT COUNT(*) FROM forum_replies as f4 WHERE f4.topic_id = f3.topic_id) as ReplyAMT FROM `forum_cats` as f1 LEFT JOIN `forum_sub` as f2 ON f1.cat_id = f2.cat_id LEFT JOIN `forum_topics` as f3 ON f2.sub_id = f3.sub_id LEFT JOIN `forum_replies` as f4 ON f3.topic_id = f4.topic_id LEFT JOIN `users` as f5 ON f4.user_id = f5.user_id WHERE f1.cat_id='$cat' $getSub $getTopic ORDER BY f2.sub_id ASC, f4.reply_id DESC "); Help would be appreciated. Thanks, Andy.
  16. Right, I'm running into a random problem. When I press the Bold Button it works fine, it replaces the string highlighted with '' tags around it. However, when I press the Italic/Underline button etc it doesn't work :/. var text = ""; function ShowSelection() { var textComponent = document.getElementById('topicMessage'); var selectedText; // IE version if (document.selection != undefined) { textComponent.focus(); var sel = document.selection.createRange(); selectedText = sel.text; } // Mozilla version else if (textComponent.selectionStart != undefined) { var startPos = textComponent.selectionStart; var endPos = textComponent.selectionEnd; selectedText = textComponent.value.substring(startPos, endPos) } text = selectedText; } $(document).ready(function() { $('#bbcode_bold').click(function() { //BBCODE BOLD var textarea = $('textarea').val(); textarea = textarea.replace(text, '[b]' + text + '[/b]'); $('textarea').val(textarea); }); $('#bbcode_italic').click(function() { //BBCODE ITALIC var textarea = $('textarea').val(); textarea = textarea.replace(text, '[i]' + text + '[/i]'); $('textarea').val(textarea); }); $('#bbcode_underline').click(function() { //BBCODE UNDERLINE var textarea = $('textarea').val(); textarea = textarea.replace(text, '[u]' + text + '[/u]'); $('textarea').val(textarea); }); $('#bbcode_strikethrough').click(function() { //BBCODE STRIKETHROUGH var textarea = $('textarea').val(); textarea = textarea.replace(text, '[strike]' + text + '[/strike]'); $('textarea').val(textarea); }); });
  17. Nevermind, I sorted it out after about a hour of trying shit on google. var textarea = $('textarea').val(); textarea = textarea.replace(text, '[b]' + text + '[/b]'); $('textarea').val(textarea);
  18. Nope. Do you know a way to use "replace" in jquery? I'm very new to this but would like to use it. Thanks for the help, Andy.
  19. Ok. Do I have a error with this because this doesn't work :/ var textarea=$('textarea'); textarea.html(textarea.html().replace('H',"111111"));
  20. Nevermind, sorted that problem. Now, is there a way, using jQuery I can replace text in a <textarea>? Thanks, Andy.
  21. I know that... But, how would I use it with jQuery then?
  22. Hello, this doesn't appear to work with jQuery, I think it's Javascript. Could someone please convert this into jQuery. function ShowSelection() { var textComponent = document.getElementById('topicMessage'); var selectedText; // IE version if (document.selection != undefined) { textComponent.focus(); var sel = document.selection.createRange(); selectedText = sel.text; } // Mozilla version else if (textComponent.selectionStart != undefined) { var startPos = textComponent.selectionStart; var endPos = textComponent.selectionEnd; selectedText = textComponent.value.substring(startPos, endPos) } alert("You selected: " + selectedText); } Thanks, Andy.
  23. Nope, I solved what I wanted, however, you've managed to read my mind on what I need help with next. How would I make it get the highlighted text from the textarea and output it into a variable? I've done quite a bit of research on this and have not found a solution to this yet. If you could help me with this it would be greatly appreciated. Thanks, Andy.
  24. Hello, I'm trying to create a button that will put text into a <textarea>. I've got this half working, so when I press the Button it puts in <textarea> [b][/b] </textarea> However, if I delete that or type something else, when I press the button again, it does nothing. Could anyone help? $('#bbcode_bold').click(function() { $('#topicMessage').append('[b][/b]'); });
×
×
  • 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.