Jump to content

Canman2005

Members
  • Posts

    669
  • Joined

  • Last visited

    Never

Posts posted by Canman2005

  1. Hi all

     

    Wondering if someone can help me.

     

    Basically I have two dates in the format of YYYY-MM-DD, so for example I might have;

     

    2007-02-23 & 2007-03-12

     

    What I need to do is to work out

     

    1: how many weekends there are (sat & sun)

    2: how many weekdays there are (mon - fri)

    3: how many total weeks there are

     

    contained between the two dates I have.

     

    Is this easy to do? can anyone help?

     

    thanks so much

     

    dave 

     

     

  2. Hi all

     

    This is more a question than a problem.

     

    Is it easy enough to get data from a XML file displayed in PHP page and query it?

     

    It it also easy to work live with the XML file, editing and deleting from it etc

     

    Any advice would be sweet

     

    thanks

  3. Hi all

     

    I have a simple form which has two buttons and a form field, when you click one of the two buttons, it inserts the value of the selected button into the form field.

     

    The code is

     

    <form>
    <input type="text" name="tester">
    <input type="button" value="1" onclick="tester.value+='1'">
    <input type="button" value="2" onclick="tester.value+='2'">
    </form>

     

    At the moment, when you click one of the two buttons, it always inserts the value at the end of whatever has already been entered in the text field.

     

    I want to change this, so that it inserts the button value into the text field, but at the position of where the text cursor is blinking.

     

    Can this be done??

     

    Hope that makes sense

     

    Any help would be gratefully appreciated.

     

    Thanks in advance

     

    Thak

  4. Thanks rajivgonsalves

     

    I've been playing around with what you suggest and ended up with the following

     

    $arrSearches  = explode(" ",$_GET['keyword']);
    $arrMatches = array();
    
    foreach ($arrSearches as $strKey => $strValue)
    {
    array_push($arrMatches," `content` like '%$strValue%' ");
    }
    
    $sql = "SELECT * FROM mydata WHERE ".implode(" or ", $arrMatches)"";
    $query = @mysql_query($sql,$connection) or die(mysql_error());
    while ($row = mysql_fetch_array($query))
    {
    print $row['content'];
    }

     

    But im getting the error

     

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/npa/public_html/members/search/searchscript.php on line 10

     

    Do you know where im going wrong?

     

    Sorry, im only good at simple queries (but learning)

     

    Thanks in advance

     

    Dave

  5. Hi all

     

    I have a search form which has a field with the id of "keyword"

     

    I then have a query

     

    SELECT * FROM mydata WHERE `content` LIKE '%".$_GET['keyword']."%'

     

    This then returns results.

     

    Is it possible to split the value of the form field, then query each word separate?

     

    For example, if I enter "internet design" into the field and then run a query, it would query the words "internet" and "design" separate. So it basically splits the value and queries both words.

     

    Is this possible?

     

    Thanks in advance

     

    Dave

  6. Hi all

     

    I have a simple QUERY, it looks like

     

    $sql = "SELECT * FROM mydata WHERE uid = 22";
    $show = @mysql_query($sql,$connection) or die(mysql_error());
    while ($row = mysql_fetch_array($show))
    {
    print $row['title'];
    print "<br>";
    }

     

    I want to print a few full stops (........) after every 3 rows returned.

     

    So the results may look like

     

    title 1

    title 2

    title 3

    ...........

    title 4

    title 5

    title 6

    ...........

    title 7

     

    Can anyone help me?

     

    Thanks in advance

     

    Dave

  7. Hi all

     

    I have a page which contains 2 divs and a link, the divs are called DIV1 and DIV2, when the page loads I want to show DIV1, then when the link is clicked, the page would hide DIV1 and show DIV2. When the link is clicked again, it would hide DIV2 and show DIV1.

     

    A kinda show and hide div script.

     

    But I also need to say on the link when DIV1 is active

     

    <a href="#">show DIV2<a href="#">

     

    and when DIV2 is loaded, say

     

    <a href="#">show DIV1</a>

     

    Can anyone help? I've been working on this for 5 hours and I am getting nowhere fast.

     

    I also spent an hour or so looking on Google for a example, but no one seems to have done it this way, or not that I can find.

     

    Any help would be fantastic

     

    Thanks in advance

     

    Dave

  8. found one

     

    simple

     

    <script language="JavaScript">

    function preview(id1, id2){

      var NewText = document.getElementById(id1).value;

      splitText = NewText.split(/\n/).join("<br />");

      var DivElement = document.getElementById(id2);

      DivElement.innerHTML = splitText;

    }

    </script>

    <form action="#">

    <label>Name:</label>

    <input type="text" id="name" onkeyup="preview('name', 'preview-name');" />

     

    <label>Phone:</label>

    <input type="text" id="phone" onkeyup="preview('phone', 'preview-phone');" />

    </form>

     

    <h2>Preview</h2>

    <dl>

    <dt>Name:</dt>

    <dd id="preview-name"></dd>

    <dt>Phone:</dt>

    <dd id="preview-phone"></dd>

    </dl>

  9. Hi all

     

    I've done a function to replace swear words.

     

    The problem I have is if someone types "class" then it returns "cl***" thinking the last part of "class" (ie: "ass") is a swear word. I had to therefore remove it.

     

    Is there a separate replace function I can run just to check for the single word "ass" and then replace it?

     

    Thanks in advance

    Ed

  10. Hi all

     

    Im just wondering if there is anyway to automatically make any urls in my page content, into clickable links. Basically I have a small forum I built, and I want to make any URL the user enters, into a clickable link.

     

    So if I had www.google.com as plain text, then it would make it into a clickable link.

     

    Any help would be ace, tried looking in google but they all seem over the top complex scripts.

     

    Thanks in advance

     

    Dave

  11. Hi

     

    That look like the start of it, so thanks, but when I run that QUERY on the phase "public information", I get

     

    SELECT * FROM content WHERE title LIKE '%public%' title LIKE '%information%' OR content LIKE '%public%'description LIKE '%information%'

     

    I think its missing an OR somewhere.

     

    Any ideas how I can adjust that?

     

    Thanks

  12. Hi all

     

    I have a database table called "content" which im trying to search through using a simple QUERY.

     

    I have a HTML form with a form field called "q", I then run a query when the form is submitted which looks like

     

    $sql = "SELECT * FROM content WHERE title LIKE '%".$_GET['q']."%' OR content LIKE '%".$_GET['q']."%'";

     

    Which searches two fields of the database, "title" and "content".

     

    At the moment, if you search for something like

     

    "public" or "information" it returns a result, which is great, but if you look for "public information", then it returns nothing.

     

    How can I adjust the QUERY so that if someone enters "public information", then it would treat each word (ie: "public" and "information") as a seperate word and look for each one, thus returning a result.

     

    Can anyone help?

     

    Thanks in advance

     

    Dave

  13. Hi all

     

    I have a simple contact form which is POSTED to a simple email script.

     

    At the end of the email script, I have put the following

     

    print "<script>alert('Thank you, your message has been sent');</script>";
    print "<script>location.replace('index.php?id=25');</script>";
    exit;

     

    The problem is that once the script has run, if you click the back button, the form seems to want to POST again.

     

    Does anyone know why this happens and if I can stop it from happening

     

    Thanks

     

    Dave

  14. Hi

     

    I tried

     

    <?php
    $today = 2007-09-21;
    
    $day = mktime(nextfriday, $dateentered);
    while($day < $today){
    $day = mktime(nextfriday, $day);
    print $day;
    }
    ?>

     

    but that didnt seem to work, can anyone help me out?

     

    Thanks

     

    Ed

  15. Hi all

     

    Im wondering if anyone can help me, basically im trying to print a list of every Friday since a date defined.

     

    Let me try and explain.

     

    I want to define a date such as 2007-07-06 (which is a Friday) and then let php print each Friday since that date until today.

     

    For example, if the date defined was 2007-07-06 then it would print

     

    2007-07-06

    2007-07-13

    2007-07-20

    2007-07-27

    2007-08-03

    2007-08-10

    2007-08-17

    2007-08-24

    2007-08-31

    2007-09-07

    2007-09-14

     

    But I want to also be able to format the date it outputs, so it might look like

     

    Friday 06 July 2007

    Friday 13 July 2007

    Friday 20 July 2007

     

    and so on

     

    Can anyone help me?

     

    Thanks in advance

     

    Ed

×
×
  • 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.