astralaaron Posted December 4, 2007 Share Posted December 4, 2007 Just need to know how to fetch just one cell of information from a mysql database and store it in a variablethanks. Link to comment Share on other sites More sharing options...
Ingolme Posted December 4, 2007 Share Posted December 4, 2007 I suppose you understand a bit about connection to databases.<?php$con = mysql_connect("server","user","password");mysql_select_db("database name",$con);$query = mysql_query("SELECT * FROM table_name");$q = mysql_fetch_array($query);// the following line stores the table cell 'row name' into the variable $n$n = $q['row name'] Link to comment Share on other sites More sharing options...
justsomeguy Posted December 4, 2007 Share Posted December 4, 2007 That's not very efficient. If you're only interested in one field it's a waste of resources to get everything.$query = mysql_query("SELECT field_name FROM table_name"); Link to comment Share on other sites More sharing options...
killboy Posted December 5, 2007 Share Posted December 5, 2007 Besides the mysql_fetch_array() function, there's also mysql_fetch_object(), which I personally prefer, specially if you work with classes. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.