Page 1 of 1

Calling a specific row in Sql when ever i like

Posted: Thu May 10, 2012 9:00 am
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?

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

Posted: Thu May 10, 2012 9:13 am
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).

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

Posted: Thu May 10, 2012 9:27 am
by rmariano02
It's the first time i heard MySQLi, can you give me a good link on how to install or use that?

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

Posted: Thu May 10, 2012 9:36 am
by x_mutatis_mutandis_x

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

Posted: Thu May 10, 2012 9:52 am
by rmariano02
Thank you so much

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

Posted: Thu May 10, 2012 11:05 am
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

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

Posted: Thu May 10, 2012 11:22 am
by Celauran
Any code involving mysql_ functions will need to be rewritten. The SQL queries themselves won't change.

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

Posted: Thu May 10, 2012 12:58 pm
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