how to print mysql result RESOURCE_ID(7) without mysql_fetch_array

Is there any way to print the resource_id without mysql_fetch_array.I dont want to loop through result.I want print only the first row at top.I know mysql has been depreciated.This is for old project.


You can make use of arrays in your case

$all_rows = array();
.     // your query
while($dbrow = mysql_fetch_array($query))
   $all_rows[] = $dbrow;

$first_row_array = $all_rows[0]; // first row will be stored here
   uncomment the below line if you do not want to use the 
   first row again while looping through the remaining 
/* unset($all_rows[0]); */

foreach($first_row_array as $first_row)
    // do something with first row data

foreach($all_rows as $dbrow)
    // loop through all the rows returned including the first row

A resource in itself is a pretty meaningless type. It only means something to specific functions, like mysql_*. When querying the database, there are certain resources allocated on the MySQL server which hold your requested result; PHP doesn't really have access to those results yet. To give you a handle on those resources on the MySQL server, you get a resource type variable. It's basically just your ticket, saying "if you ever want to access that data waiting for you on the MySQL server, use this number."

So, if you want to output the data from the MySQL server, you will have to fetch it from there, e.g. with mysql_fetch_assoc. That then returns the data to you which you can print.

If you just want the first result, just call that function once.

Need Your Help

best sensor selection for ar application

android augmented-reality android-sensors

Hello i want to ask which is the best sensor i can use for an augmented-reality application? my augmented reality app is using the mobiles camera and finds points of interest in the live view. i wa...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.