Jump to content

cK

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Posts posted by cK

  1. Hi,

     

    Due to security reasons and the fact our website is running php/mysql we want to export tables from our MSSQL server at our office to our MqSQL server at our hosting company.

     

    I heard this can be done with an ODBC driver. I only don’t know how this works exactly and couldn’t google-up an tutorial. Who can help me?!

     

    Next to this I\'m wondering if you can give a \"where statement/search routine\" on every table before exporting. This due to fact our MSSQL database is very larger and not all data is needed online. For example: only records with status \"active\" or \"changed last 15 days\" or only \"id,name,company,...,....,....,.....,....\" and so on...

     

    Thanks in advance,

     

    cK

  2. Hi,

     

    I know how to make a field in a table UNIQUE, but have no clue if it\'s possible to make 1 field on two (!) tables UNIQUE and how to do this!

     

    For example make sure the are no duplicates in the \"login\" data (= username) so never ever a client will login and get - by accident - the stuff of the supllier with the same login. Putting everything in one table would be a solution, however my current cms-system can\'t handle this.

     

    client_id | username | password | more clients stuff...

    supplier_id |username | password | more supllier stuff...

  3. Hi,

     

    Currently I have the following fields in my online form,

     

    
    <input type="text" name="var1">
    
    <input type="text" name="var2">
    
    <input type="text" name="var2">
    
    

     

    and save everything to the database like:

     

    
    $query = "INSERT INTO test_jobapplications (var1,var2,var3) VALUES (\'" . $_POST[\'var1\'] . "\',\'". $_POST[\'var2\'] . "\',\'" $_POST[\'var3\'] . "\')";
    
    mysql_query($query) or error ("Unable to connect to SQL server. Try again later.");
    
    

     

    But now I\'m working on a time-sheet system I would like to be able to have the following type of input-boxes and have a routine to extract each set a vars into an array so I could loop true the array and save each set of vars in the database.

     

    
    <input type="text" name="1-var1">
    
    <input type="text" name="1-var2">
    
    <input type="text" name="1-var3">
    
    
    
    <input type="text" name="2-var1">
    
    <input type="text" name="2-var2">
    
    <input type="text" name="2-var3">
    
    
    
    <input type="text" name="3-var1">
    
    <input type="text" name="3-var2">
    
    <input type="text" name="3-var3">
    
    

     

    So I made the following snippet:

     

     
    
    while (list ($key, $val) = each ($_GET)) {
    
    
    
    if (eregi("-", $key)) {
    
    
    
     $tmp = explode("-", $key);
    
     
    
     $id   = $tmp[0];
    
     $name = $tmp[1];
    
     
    
     $data[$id][$name] = $val;
    
    
    
    }
    
    }
    
    

     

    I\'m only wondering: is this the best/safest way? And how to loop true the array to save the data in the sql-database?! I have no clue!

     

    Thanks in advance,

     

    cK

  4. Doesn\'t seem to work with me :x

     

    I get \"titleresults\" with $title = $row->test_jobs.title . \"results\";

     

    
    
    
    function show_detail_page($id)
    
    {
    
    $query = \"SELECT test_jobs.id,test_jobs.title,test_jobs.description,test_jobcontacts.name FROM test_jobs LEFT JOIN test_jobcontacts ON test_jobs.contact_id = test_jobcontacts.id WHERE test_jobs.id=\'$id\' AND ((TO_DAYS(NOW()) - TO_DAYS(test_jobs.timestamp)) <= test_jobs.days_valid) AND ((TO_DAYS(NOW()) - TO_DAYS(test_jobs.timestamp)) >= 0)\";
    
    $result = mysql_query($query) or error (\"Unable to connect to SQL server. Try again later.\");
    
    $row = mysql_fetch_object($result);
    
    
    
    if ($row)
    
    {
    
     $title = $row->test_jobs.title . \"results\";
    
    
    
    (...)
    
    

  5. 
    $query = "SELECT test_jobs.id, test_jobs.title, test_jobcontacts.id FROM test_jobs LEFT JOIN test_jobcontacts ON test_jobs.contact_id = test_jobcontacts.id WHERE (test_jobs.category_id=\'$category[id]\' OR test_jobs.category_id=\'9\') AND ((TO_DAYS(NOW()) - TO_DAYS(test_jobs.timestamp)) <= test_jobs.days_valid) AND ((TO_DAYS(NOW()) - TO_DAYS(test_jobs.timestamp)) >= 0) ORDER BY test_jobs.timestamp DESC LIMIT $pager->offset,$pager->limit";
    
    

     

    How does this (JOIN ON) work in combination with \"while($row = mysql_fetch_object($result))\"?

     

    I used to take $row->id and so on... But do I know need to do $row->jobcontacts.id (what doesn\'t work) or....

  6. 
    $query = "SELECT * FROM test WHERE (TO_DAYS(NOW()) - TO_DAYS(timestamp)) < days_valid and category_id=\'$category[id]\' or category_id=\'9\' ORDER BY timestamp DESC LIMIT $pager->offset,$pager->limit";
    
    $result = mysql_query($query) or error ("Unable to connect to SQL server. Try again later.");
    
    

     

    Will the above query give all valid (=still public) results from category $category[id] or category 9 ?

     

    I\'m not sure how to write it; first and or first or? with () or without?

  7. metalblend thanks! I Forgot that PHP was so easy :D

     

    wompus, that\'s easy. But how about?

     

    $_POST[\'Name\'] and

    $_POST[\'Two words\']

     

    Because that\'s actually why I use [\'Name\'] and not [name]....

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