Calling a specific row in Sql when ever i like

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rmariano02
Forum Newbie
Posts: 8
Joined: Mon Feb 20, 2012 8:46 am

Calling a specific row in Sql when ever i like

Post by rmariano02 »

How can i call a specific row when ever a like.

example :

Code: Select all

$record = mysql_query("select * from table_name");
($getValue= mysql_fetch_row($record)   //i'm not sure what should i use. should i use mysql_fetch_array, mysql_ fetch_ assoc, mysql_ fetch_ object,  mysql_ field_ name and etc.
		
print $getValue[$column_name][0];
0 = value 1st row in the database/table_name
1 = value 2nd row in the database/table_name
2 = value 3rd row in the database/table_name
......
....
......
.....
etc.

is there a code i can do except from using sql_fetch_array then loop and put in into a multidimensional array?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Calling a specific row in Sql when ever i like

Post by McInfo »

If you switch to MySQLi, you can use mysqli_fetch_all() to load the rows into an array. Otherwise, you will need to write a loop or your own fetch-all function (or use this one).
rmariano02
Forum Newbie
Posts: 8
Joined: Mon Feb 20, 2012 8:46 am

Re: Calling a specific row in Sql when ever i like

Post by rmariano02 »

It's the first time i heard MySQLi, can you give me a good link on how to install or use that?
rmariano02
Forum Newbie
Posts: 8
Joined: Mon Feb 20, 2012 8:46 am

Re: Calling a specific row in Sql when ever i like

Post by rmariano02 »

Thank you so much
rmariano02
Forum Newbie
Posts: 8
Joined: Mon Feb 20, 2012 8:46 am

Re: Calling a specific row in Sql when ever i like

Post by rmariano02 »

Can i still use the same code in SQL to SQLi?
or
i still need to declare both SQL and SQLi?

because i'm not familiar with those -> arrow thing xD sorry
Last edited by rmariano02 on Thu May 10, 2012 11:24 am, edited 1 time in total.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Calling a specific row in Sql when ever i like

Post by Celauran »

Any code involving mysql_ functions will need to be rewritten. The SQL queries themselves won't change.
x_mutatis_mutandis_x
Forum Contributor
Posts: 160
Joined: Tue Apr 17, 2012 12:57 pm

Re: Calling a specific row in Sql when ever i like

Post by x_mutatis_mutandis_x »

rmariano02 wrote:Can i still use the same code in SQL to SQLi?
or
i still need to declare both SQL and SQLi?

because i'm not familiar with those -> arrow thing xD sorry
mysqli also has procedural based api. Read the manual and each class function has a corresponding mysqli_ function
Post Reply