Jump to content

Canman2005

Members
  • Posts

    669
  • Joined

  • Last visited

    Never

Posts posted by Canman2005

  1. Hi all

     

    Wondering if anyone can help.

     

    Basically I have a `members` table which looks like

     

    `MEMBERS` - TABLE
    
    ID      NAME     MYID
    1       John     11
    2       Dave     2
    3       Emma     11
    4       Sarah    11
    5       Steve    8

     

    What I do then is run a QUERY on this table to get all the members which belong to me (I am ID number 11), this would be done with a QUERY like

     

    SELECT * FROM `members` WHERE `myid` = 11

     

    that would get the following rows back from the `members` table

     

    `MEMBERS` - TABLE
    
    ID      NAME     MYID
    1       John     11
    3       Emma     11
    4       Sarah    11

     

    This shows that ID numbers 1 / 3 / 4 belong to me as my member ID is stored on thier row.

     

    What I want to do is run another QUERY on a table called `posts` which gets all the rows which belong to those members returned from the `members` table.

     

    The posts table looks like

     

    `POSTS` - TABLE
    
    ID      TITLE     MEMBERID
    1       Hello     2
    2       Holiday   4
    3       Travel    9
    4       Boats     4
    5       Planes    6

     

    So when I run the QUERY i'm trying to figure out, it would basically return the following rows

     

    `POSTS` - TABLE
    
    ID      TITLE     MEMBERID
    2       Holiday   4
    3       Travel    3
    4       Boats     4

     

    because the `member` id's that belong to me (1 / 3 / 4) are contained the the `memberid` field in the `posts` table.

     

    Does this make any kind of sense to anyone?

     

    Can anyone help me? Been up for 7 hours trying to do this, but no where fast

     

    Any help would be ace

     

    Thanks in advance

     

    Ed

  2. Hi all

     

    Wondering if anyone can help.

     

    I have the following array code

     

      $name_array =  array ('steve', 'jon', 'george', 'admin');
    
      if (in_array($input, $name_array)) {
        return true;
      }
      else {
        return false;
      }

     

    and I want to run a SQL QUERY for the array data using something like

     

    $sql = "SELECT * FROM `members`";
    $show = @mysql_query($sql,$connection) or die(mysql_error());
    while ($row = mysql_fetch_array($show))
    {
    }

     

    which would replace the

     

    'steve', 'jon', 'george', 'admin'

     

    part of the array with data from the SQL database.

     

    Can anyone help? Been on this for 6 hours and im not managing to crack it.

     

    Any help would be ace

     

    Thanks in advance

     

    Dave

  3. Hi all

     

    I have an array in my php code

     

    $aUsers = array(
    "Ädams, Egbert",
    "Zaun, Jillie",
    );

     

    Is there anyway to populate the array with a SQL query such as

     

    $sql = "SELECT * FROM `members`";
    $show = @mysql_query($sql,$connection) or die(mysql_error());
    while ($row = mysql_fetch_array($show))
    {
    print "name"
    }

     

    Any help would be smashing

     

    Thanks in advance

     

    Dave

  4. Hi all

     

    I am wondering if anyone knows if a script exists to do the following.

     

    What I need is 2 html text form fields, when you enter text into one of the text fields, it would automatically update the other form field with the first letter of what was typed.

     

    So for example, if you have the 2 form fields and you enter

     

    Google

     

    into the field, then it would automatically enter G into the other text field.

     

    Does anyone know if this exists?

     

    Thanks

    Dave

  5. hi all

     

    i have a php code which prints a month, such as

     

    March 2008 or April 2009

     

    Is it possible to give php a date, such as

     

    $date = "march 2008";

     

    and get php to output everyday in that month, so with the above date it would output everyday in March in the format

     

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    ...

     

    is suggestions anyone?

     

    thanks in advance

     

    dave

  6. Hi all

     

    I have a simple script to print all months since a defined date, the code is

     

    $startdate = "1 december 2007";
    
    function printMonths($var)
    {
    $start = strtotime($var);
    $now = strtotime("Now");
    while ($start < $now)
    {
    echo date("F Y", $start);
    echo "<BR>";
    $start = strtotime("+1 month", $start);
    }
    }
    printMonths($startdate);

     

    Which prints something like

     

    December 2007

    January 2008

    February 2008

    March 2008

     

    Is it possible to list all the days in each month under the month, so for example

     

    December 2007

    1

    2

    3

    4

    5

    6

    7

    .etc.

    January 2008

    1

    2

    3

    4

    5

    6

    7

    .etc.

     

    is this possible?

     

    cheers

     

    ed

  7. Hi all

     

    I have been asked to do a project in which I am recieving a 10% of the revenue generated from the site rather than being paid, which im happy with.

     

    The site is going to be hosted on their server and I am just a little worried they could duplicate the code and launch a similar site on another server, therefore excluding me from the deal.

     

    Does anyone know any good ways to secure code? Something I can do which would make it impossible for them to duplicate the site or continue the site without me involved.

     

    Any suggestions?

     

    Thanks

  8. Hi all

     

    I have a question.

     

    I am building a login form which makes the user enter an email address and password, I think the best method to sent the data would be a POST, this is because if I send the form data as GET, then it will be stored in the web history log and someone could find out what the password is.

     

    The problem is that when I send the data as a POST, if the login fails and the user clicks the back button, if they then hit the forward button, you get an alert box with

     

    The page you are trying to view contains POSTDATA that has expired from cache.

     

    Is there a way to avoid this message? It's really bugging me :(

     

    Thanks

     

    Dave

  9. Hi

     

    I wanted to make each checkbox that is ticked into a seperate INSERT statement, the reason is that my database table that the data is being inserted into looks like

     

    ID  |  MEMBERID  |  ITEMNUM

     

    so an example data dump could look like

     

    ID  |  MEMBERID  |  ITEMNUM

    1      5433              2

    2      5433              4

    3      8965              8

    4      5433              1

     

    The list of checkboxes is generated with

     

    <?php
    $sql = "SELECT * FROM `tickboxes`";
    $query = @mysql_query($sql,$connection) or die(mysql_error());
    while ($row = mysql_fetch_array($query))
    {
    ?>
    <input name="<?php print $row['id']; ?>" type="checkbox" id="<?php print $row['id']; ?>" value="<?php print $row['id']; ?>" />item <?php print $row['id']; ?><br />
    <?php
    }
    ?>

     

    So there could be 10 checkboxes or there could be 3 checkboxes

     

    Does that make any sense? Kinda hard to explain

     

    Thanks

  10. Hi all

     

    I have a series of checkboxes in a form, the code looks like

     

    <form>
    <input name="1" type="checkbox" id="1" value="1" />item 1<br />
    <input name="2" type="checkbox" id="2" value="2" />item 2<br />
    <input name="3" type="checkbox" id="3" value="3" />item 3<br />
    <input name="4" type="checkbox" id="4" value="4" />item 4<br />
    <input name="5" type="checkbox" id="5" value="5" />item 5<br />
    <input type="button" value="submit" />
    </form>

     

    The above is generated from a QUERY on a table, so the list of checkboxes can be longer or shorter.

     

    What I want to do is to run a query when the form is submitted and run a INSERT statement for all the checkboxes which were ticked

     

    INSERT INTO `itemtable` SET `itemnum` = $_GET[''] AND `memberid` = $_SESSION['idnum']

     

    So the value of the checkbox is inserted into `itemnum`, if 3 checkboxes were ticked, it would run that query 3 times for the ones which were ticked.

     

    Does that make sense?

     

    Any help would be ace

     

    Thanks in advance

     

    Dave

  11. Hi all

     

    I have a very simple fileupload script

     

    $code = rand(111111, 999999);
    $uploaddir = 'fileupload/';
    $uploadfile = $uploaddir . $code. basename($_FILES['upfile']['name']);
    move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile);

     

    Is there a way to totally rename that file? So rather than the old filename, it would rename it to just the code.

     

    image33_234532.jpg

     

    would become

     

    234532.jpg

     

    Any help would be great

     

    thanks in advance

     

    ed

  12. Hi

     

    Well my query is the following, it basically takes keywords entered and searches the database for anything matching, I need to get these to order with the closest match showing first.

     

    Is that possible?

     

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

     

    Any help would be ace as ive been trying to crack this for days now.

     

    Thanks

     

    Ed

  13. Hi all

     

    Im currently running a complex query and I need to try and sort the results into an order which the closest match first.

     

    I was told there is a simple ORDER BY function which can be used.

     

    Has anyone done a ORDER BY CLOSEST MATCH or whatever the query should be?

     

    Any help would be sweet

     

    Thanks

     

    Ed

  14. Hi all

     

    I have a form which posts a month & year such as

     

    mypage?month=3&year=2009

     

    What I need to do is take the month and year which with the above is 3/2009 (march 2009) and then print every day which is in that month, so with the date 3/2009 (march 2009) it would output

     

    31

    <font>1/3/2009</font>

    <font>2/3/2009</font>

    <font>3/3/2009</font>

    <font>4/3/2009</font>

    <font>5/3/2009</font>

    <font>6/3/2009</font>

    <font>7/3/2009</font>

    <font>8/3/2009</font>

    <font>9/3/2009</font>

    <font>10/3/2009</font>

    <font>11/3/2009</font>

    <font>12/3/2009</font>

    <font>13/3/2009</font>

    <font>14/3/2009</font>

    <font>15/3/2009</font>

    ........

     

    and so on

     

    and then when the url that is posted is

     

    mypage?month=4&year=2009

     

    it would output

     

    <font>1/4/2009</font>

    <font>2/4/2009</font>

    <font>3/4/2009</font>

    ....

     

    and so on.

     

    Is this possible?

     

    Any help would be ace

     

    Thanks

     

    Dave

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