Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    making one text area dependant on another

    Hi, first time here and already apologizing that I can't put together the right search phrase for this...as i'm sure it's been covered.
    i have an sql db table: logos_invoices, and two fields: `ticketz` and `datez`. I also have a form with text areas, 'ticket' and 'date'.
    when the user enters the invoice # into the ticket field, I'd like for the correct date to automatically show up in date area, else null.

    the code i'm trying looks something like this, but is not working..any ideas? am I on the right path?

    Code:
    if ('ticket' == $query = "SELECT * FROM ".$DBPrefix."invoices_ticketz") {
    $query = "SELECT * FROM ".$DBPrefix. "invoices";
    $result = mysql_query($query);
    $system->check_mysql($result, $query, __LINE__, __FILE__);
    $INVOICES = mysql_fetch_array($result);	
    $template->assign_vars(array(
    		'DATE' => $INVOICES ['datez'],
    	
    ));
    )	
    	else ('DATE' == $null);
    Last edited by beliaz; 03-20-2009 at 06:26 PM. Reason: my question wasn't clear

  • #2
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    welcome to CF.

    please post a create table statement so we can be sure that you have it OK too.

    I think what you need is the INSERT IGNORE statement but I am not yet sure.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi bazz, thanks for welcome.

    Code:
    <!-- INCLUDE user_menu_header.html -->
    <link href="style.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    <!--
    body {
    	background-color: #FFF;
    }
    body,td,th {
    	font-size: 9px;
    	color: #000;
    }
    -->
    </style>
    <form name="user_info" action="user_data.php" method="POST">
      <table width="635" border="0">
        <tr>
          <td><p><span class="titTable5"><strong>{L_27_002}</strong></span></p></td>
          <td><input name="ticket" type="text" id="ticket" value="{TICKET}" />
            *If applicable. Use numbers/letters only. </td>
        </tr>
        <tr>
          <td><strong class="titTable5">{L_27_006}</strong></td>
          <td class="titTable5"><input name="date" type="text" id="date" value="{DATE}" /></td>
        </tr>
        <tr>
          <td height="23" valign="top">&nbsp;</td>
          <td class="titTable6"><label>
            <input type="submit" id="Submit" value="Submit" class="Button" />
            </label>
            <label>
              <input type="reset" name="Cancel" id="Cancel" value="Cancel" class="Button" />
            </label></td>
        </tr>
      </table>
    </form>
    <!-- INCLUDE user_menu_footer.html -->
    Last edited by beliaz; 03-20-2009 at 07:46 PM.

  • #4
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    oops, I shall explain better what I need.

    something like :
    Code:
    create table table_name
    ( col1   int   not null
    , col2  varchar(nn) not null
    )
    if using phpMyAdmin try looking at the table and click on the export tab at the top. copy the text that shows up and post it here.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #5
    New Coder
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh yea sorry, should have read properly..thought u meant create form, lol. u see there's an ID lead off too. I'm obviously keeping some sensitive info out to avoid detection by skynet. .


    Code:
    CREATE TABLE IF NOT EXISTS `logos_invoices` (
      `id` int(11) NOT NULL auto_increment,
      `ticketz` int(32) NOT NULL default '0',
      `datez` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,

  • #6
    New Coder
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    still stuck on this

    i think bazz went away for the weekend, lol. anyone got an idea?

  • #7
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    sorry

    Currently I am away with the 'Havana Club' fairies

    I should have said, I am not proficient in php so I don't actually understand your first-post query.

    I had hoped that by showing your create table statement that I could have confirmed that you needed to set a default of 'timestamp' to the 'datez' column but, you are ahead of me on that because you had already done that.

    I'll look again tomorrow and see if I can find some way to help.

    but giong back to your create table statement; you do not need the (11) or the (32) in there. int on its own is fine, except when you use zerofilling, to append zeros to the front of the digits. eg 000000001. In that case int (9) would do it but as you have it, no number is required. jfyi.

    At the risk of waffling on, I think this section of your post suggest you are looking for an ajax solution

    when the user enters the invoice # into the ticket field, I'd like for the correct date to automatically show up in date area, else null.
    bazz
    Last edited by bazz; 03-22-2009 at 03:40 AM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #8
    New Coder
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks man.
    btw, careful, some of them fairies can be witch hagar in disguise, lol!!

  • #9
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    tell me about it.

    on the updside, it tends to clear a load of crud from my brain and I can then code better for another while. a bit like a brain reset button.

    Now I am not sure whether that means I am a code wizard or that I am crap. but I make progress afterwards anyway and I have (limited) fun on the way.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #10
    New Coder
    Join Date
    Mar 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any form of ascension makes the brain wiser
    we crossed posts, but, yea, I was thinking about ajax, but wanted to keep it simple for such a small thing. I had a variation where it actually did enter a date after filling invoice field, but it was the id#1 date regardless of what invoice# you entered...also it wouldn't go away after that. I'll check into it..if you think of anything, let me know...and enjoy the ride!!

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,128
    Thanks
    80
    Thanked 4,556 Times in 4,520 Posts
    Bazz: FYI. If you use some of MySQL's standard tools to dump out your DB tables, those *TOOLS* will put the INT(11) and so on into their output. Even if you didn't have them there in the first place.

    I *think* it is mysqldump that does that, but I don't happen to have it here right now. But I remember using one of the tolls and being surprised at seeing that stuff appear. I never code like that, myself.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •