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

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.

Archived

This topic is now archived and is closed to further replies.

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