SELECTING column FROM TABLE does not work

software development

#1

Hi all,

I have a query which I want to recall from mysql tables. But there seems to be an error in it.

My code as follows:

<?php //Query for references for herb $refherb_1 = 'SELECT refherb_1 FROM cam_pk WHERE acronym = "'.$CAM.'"'; $refherb_2 = 'SELECT refherb_2 FROM cam_pk WHERE acronym = "'.$CAM.'"'; $refherb_3 = 'SELECT refherb_3 FROM cam_pk WHERE acronym = "'.$CAM.'"'; $refherb_1_result = mysql_query($refherb_1); $refherb_2_result = mysql_query($refherb_2); $refherb_3_result = mysql_query($refherb_3); foreach (mysql_fetch_row($refherb_1_result) as $refherb_1_output) { } foreach (mysql_fetch_row($refherb_2_result) as $refherb_2_output) { } foreach (mysql_fetch_row($refherb_3_result) as $refherb_3_output) { } //in a results table cell I enter the following code if ($refadr_1_output == 'N/A' OR $refadr_1_output == ''): echo ""; elseif ($refadr_2_output == ''): echo $refadr_1_output; elseif ($refadr_3_output == ''): echo $refadr_1_output; echo "
" . $refadr_2_output; else: echo $refadr_1_output; echo "
" . $refadr_2_output; echo "
" . $refadr_3_output; endif; ?>

Somehow, my results for $refadr_2_output and $refadr_3_output can be seen, but not for the first $refadr_1_output

Can anyone help troubleshoot?

Thanks a lot


#2

The logic of your loops looks odd. It looks like you are only going to get results for the last rows of your tables, because your loops are running without any instructions inside them.

si-blog
Max discount on any plan with promocode SCJESSEYTOTAL


#3

Thanks for your help.
I think I managed to resolve it.