Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

select and echo a single field from mysql db using PHP

Tags:

php

mysql

Im trying to select the title column from a particular row

$eventid = $_GET['id'];
$field = $_GET['field'];
$result = mysql_query("SELECT $field FROM `events` WHERE `id` = '$eventid' ");
echo $result;

all i get is Resource id #19

How should i do this? What is best method?

like image 314
mrpatg Avatar asked Nov 20 '09 09:11

mrpatg


1 Answers

Try this:

echo mysql_result($result, 0);

This is enough because you are only fetching one field of one row.

like image 115
Franz Avatar answered Sep 17 '22 18:09

Franz