Jump to content

aschk

Staff Alumni
  • Posts

    1,245
  • Joined

  • Last visited

    Never

Posts posted by aschk

  1. I'll provide you with an example so you can see what I mean:

     

    <?php
    
    
    while($row=mysql_fetch_array($query)){
    
       echo $theFid=$row['member_id'];//member"
       echo $themsg=$row['emailmsg'];//message
       echo $thedate=$row['recdate'];//date received
       echo $theid=$row['main_id'];//id
      };
    
    ?>
    

     

    Put that in your code and you'll see what I mean.

  2. I think when the op refers to "banks can do it" he means, when you're going through a "step" situation , like a transaction. What happens is that the server side (session) maintains a record of the last state you were in (i.e. step 3) , and on going "back" in the browser, or "refreshing" the server asks what step the last one was (from session info), and decides upon logic depending on that.

     

    You can't disable a persons browser capabalities. And even if you could I wouldn't recommend it as you're interfering with a common user interface (making your site less usable).

     

    Describe to us what your problem is and why you want to faciliate this. Is your problem regarding "double posting" of information? i.e. they fill in a form, post to another page, and then refresh that page (asking for re-post) ?

  3. Mmm, I concur session_register() is deprecated.

    You probably change the lines to

     

    <?php
          // Register the session variables
          $_SESSION["ses_basket_items"] = $ses_basket_items;
          $_SESSION["ses_basket_name"] = $ses_basket_name;
          $_SESSION["ses_basket_amount"] = $ses_basket_amount;
          $_SESSION["ses_basket_price"] = $ses_basket_price;
          $_SESSION["ses_basket_stockcode"] = $ses_basket_stockcode;
          $_SESSION["ses_basket_id"] = $ses_basket_id;
    ?>
    

     

    You will also need to intialise all the proper variables above.

  4. 
    while($row=mysql_fetch_array($query)){
    
      $theFid=$row['member_id'];//member"
      $themsg=$row['emailmsg'];//message
      $thedate=$row['recdate'];//date received
      $theid=$row['main_id'];//id
      };
      ?>
    
    

     

    You are already looping through your dataset by using the while loop I have quoted above.

  5. So basically you're looking to generate an invoice number based on current date + XX.

    Thus you need to count the number of invoices that have a date of today, and append 1 to that count.

     

    ...
    $query = "SELECT CONCAT(REPLACE(CURRENT_DATE,'-',''),COUNT(*)+1) 
               FROM invoice 
               WHERE inv_date = CURRENT_DATE";
    $result = mysql_query($query);
    $row = mysql_fetch_row($result);
    $count = $row['inv_num'];
    

  6. For anyone else interested I have generated a SQL schema for testing:

     

    CREATE TABLE items (
    site_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    site_name VARCHAR(255) NOT NULL,
    site_category INT UNSIGNED NOT NULL
    );
    
    INSERT INTO items(site_name, site_category)
    VALUES('yahoo.com',1)
    ,('msn.com',1)
    ,('google.com',2)
    ,('youtube.com',3)
    ,('yahoovideo.com',3);
    
    CREATE TABLE Sums(
    site_id INT UNSIGNED NOT NULL,
    `day` DATE NOT NULL,
    visitors INT UNSIGNED NOT NULL DEFAULT 0
    );
    
    INSERT INTO Sums(site_id, `day`, visitors)
    VALUES(1,'2009-01-01',851075)
    ,(1,'2009-01-02',172083)
    ,(2,'2009-01-01',1750207)
    ,(2,'2009-01-02',2357)
    ,(3,'2009-01-01',123);
    

  7. I'll break this down:

     

    Total Visitors (for all days) for site_id 1

    SELECT site_id
          , SUM(visitors)
    FROM Sums
    WHERE site_id = 1
    GROUP BY site_id
    

     

    Linking the above to a "Site Name"

    SELECT i.site_id
          , i.site_name
          , SUM(s.visitors)
    FROM items i
    LEFT JOIN Sums s ON i.site_id = s.site_id
    GROUP BY i.site_id, i.site_name
    

     

    P.S. you never supplied a SQL query for us to start working with, so I can only really guess at what you were doing before.

     

    P.P.S it might also be worth me pointing out you are storing your dates in a non-standard format. Use MySQL DATE datatype please instead.

  8. Of course not... $result is a "resource" type. If you want the actual data from that query you'll need to use any of the mysql_fetch_* functions to pull the data from that query.

     

    Anyway you'll want to do a query using the INFORMATION_SCHEMA tables, not using the "SHOW TABLES" cmd.

  9. So which fields are duplicated? This is key to the query.

    I'll take a guess:

     

    SELECT p1.id, p1.title, p2.id, p2.title
    FROM photo p1
    JOIN photo p2 ON p1.title = p2.title AND p2.id != p1.id
    

     

    The above should give you all the id's (assuming "id" is the name of your primary key) and title's of duplicated records.

     

    This also points to an issue with indexes. If your titles need to be unique make sure your application checks for duplicate titles before it starts the insert, AND you have a UNIQUE index on the title field, to stop duplicate entries.

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