Page 1 of 1

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

Posted: Thu Dec 07, 2006 7:50 am
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]

Posted: Thu Dec 07, 2006 8:29 am
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);
}

Posted: Thu Dec 07, 2006 10:34 am
by impulse()
Is it because "$query_mark" doesn't exist?

Posted: Thu Dec 07, 2006 10:55 am
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'";

Posted: Thu Dec 07, 2006 11:13 am
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.

Posted: Thu Dec 07, 2006 10:55 pm
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