Unable to get records from " mysql_fetch_array(); &am

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
shyamkodase
Forum Newbie
Posts: 3
Joined: Thu Dec 07, 2006 7:38 am

Unable to get records from " mysql_fetch_array(); &am

Post by shyamkodase »

JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi Friends 

  Actually Am unable to display a set of results using mysql_fetch_array($result) 
 code is something like this

Code: Select all

$query= "SELECT `crm_email_subject` FROM `crm_emaildata` WHERE `crm_email_type` = 'marketingemail'"; 
$result_mark=mysql_query($query_mark) or die("An error occurred in : ".mysql_error());
$count_mark=mysql_num_rows($result_mark);
$resultset_mark=mysql_fetch_array($result_mark);
for($i=0;$i<$count_mark;$i++)
{
 echo $resultset_mark[$i];
}
When i run this ... only zeroth row ie resultset_mark[0]; is getting displayed...
Please Can You tell Me Why this thing is not working

i have run the same code in phpmyadmin .. its giving all result ..
but when i run in php its not working???


Thanks in advance
Shyam Kodase


JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

his should get you going

Code: Select all

$query= "SELECT `crm_email_subject` FROM `crm_emaildata` WHERE `crm_email_type` = 'marketingemail'";

$result_mark=mysql_query($query_mark) or die("An error occurred in : ".mysql_error());

while($resultset_mark = mysql_fetch_array($result_mark, MYSQL_ASSOC);
{
    print_r($resultset_mark);
}
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

Is it because "$query_mark" doesn't exist?
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

Ya, I think your query should be query_mark.

ie:

Code: Select all

$query= "SELECT `crm_email_subject` FROM `crm_emaildata` WHERE `crm_email_type` = 'marketingemail'"; 


$query_mark= "SELECT `crm_email_subject` FROM `crm_emaildata` WHERE `crm_email_type` = 'marketingemail'";
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

You really need to read the mysql_fetch_array documentation.

http://us2.php.net/mysql_fetch_array

The mysql_fetch_array only retrieves ONE array row. You need to call that function for EACH of the rows that was found by the query.
shyamkodase
Forum Newbie
Posts: 3
Joined: Thu Dec 07, 2006 7:38 am

Post by shyamkodase »

AKA Panama Jack wrote:You really need to read the mysql_fetch_array documentation.

http://us2.php.net/mysql_fetch_array

The mysql_fetch_array only retrieves ONE array row. You need to call that function for EACH of the rows that was found by the query.




Thank You..
i was using for loop instead of while loop .. now its working perfectly .. thanks again
Post Reply