php - How to store the sql result into a variable? -


why isn't working me:

$item_id = "select item_id items item_id=(select max(item_id) items)"; 

i'm trying insert sql query result variable item_id.

if write echo"$item_id"; sentence in between quotes output.

you must have connection out var , need fetch array try this:

// connection data //

$link = mysql_connect("localhost", "youruser"); mysql_select_db("yourdb", $link);

// select //

$result = mysql_query("select yourvalue yourtable", $link);

$row = mysql_fetch_array($result)

your item var

$item_id = $row ["yourvalue"]

regards


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -