Jump to content

Add a row to a table if not found


katlis

Recommended Posts

function map_clicks_to_row($row_id) {

global $dbConnection;

$query = "SELECT * FROM clickable_rows_table WHERE id = %s";

$result = mysql_query(sprintf($query, $row_id), $dbConnection);

if (0 !== mysql_num_rows($result)) {

// row exist, make it extra clickable..

}

}

 

@dannyb785 and all other phpfreaks forum regulars mysql_query() has a second optional parameter called $link_identifier, leaving this parameter empty will use the latest used open connection to the database, if you like me, use more then one database will this result in a serious rewrite of your code, in my opinion the second parameter shouldn't even be optional

Link to comment
Share on other sites

function map_clicks_to_row($row_id) {

    global $dbConnection;

    $query = "SELECT * FROM clickable_rows_table WHERE id = %s";

    $result = mysql_query(sprintf($query, $row_id), $dbConnection);

    if (0 !== mysql_num_rows($result)) {

          // row exist, make it extra clickable..

    }

}

 

@dannyb785 and all other phpfreaks forum regulars mysql_query() has a second optional parameter called $link_identifier, leaving this parameter empty will use the latest used open connection to the database, if you like me, use more then one database will this result in a serious rewrite of your code, in my opinion the second parameter shouldn't even be optional

 

 

why on earth would you need to have 2 separate database connections in the same script? I've never needed it nor can I ever see needing it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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