cell

(/rs/public/functions.mysql.php)

cell -- One cell from a database table.

Description

mixed cell ($query)

This function executes a SELECT statement on a databae table and returns the first column selected in the first row returned.

$query is a valid MySQL SELECT statement without the word "SELECT". The function prepends $query with the word "SELECT" and a space.

The function then checks the number of rows in the query, and if that number is at least 1, it returns the value of the first selected column in the first row.

This function returns false on failure.

Examples

cell ("* FROM table_with_multiple_lines") /* Returns the first column in the first row of table_with_multiple_lines. */

cell ("A, B, C FROM table WHERE D = E") /* Returns A in the first row in table that satisfies the WHERE clause D = E. If no row satisfies the WHERE clause, returns false. */

cell ("SELECT A FROM table") /* Returns false. Do not use "SELECT" in $query. */

cell ("1 + 1") /* Returns 2. */

Related Functions

row

Dependencies

rows, data

Function Index