PHP: mysql - access array set row_value(FIELD) as variable

Hi guys!

I’ve been looking for nearly 2 days to find an answer to this problem online and am stuck. Would greatly appreciate any assistance any one might provide :)))

ENV: Linux(ubuntu), MySQL, PHP

I have the attached script that queries the db ok ( please see attached results: example.html ). I’m trying to access the array that is created by “mysql_fetch_array($Result))” at line: 171 (please see attached: view.php).

The query returns all rows from the PRODUCT table in my mysql DB… all goood. The first field is called BC_ID. I want to access this array in LINE:261- 279 so that i can set the BC_ID as a VARIABLE and then pass it to the URL construct in LINE:268. This will then let me use another .php to SQL INSERT Query with this BC_ID instead of the “&row_id” which is based on a counter in a foreach LOOP.

I know its painful reading other people’s code, so have tried to give exact LINE number to narrow the read time.

Specifically, I want to have LINE: 268 (view.php) to look something like this:


PHP_files.zip (4.83 KB)

My apologies, the code i want to “enhance” is LINE:264-279 ( attached: view.php )

This is an example of the current loop, before the section i want to change:

[php]

			foreach($Fields as $Field)
				{
					if(GetMapping($TableID,$Field) == $Field)
						{
							print("<td>$Raw[$Field] </td>");
						}
					else
						{
							$TMP = trim(GetMapping($TableID,$Field));
							$TMP = explode(".", $TMP);
							$TMP = $TMP[1];
							if($TMP == "")
								{
									$TMP = GetMapping($TableID, $Field);
								};
							print("<td>$Raw[$TMP]</td>");
						};		[/php]

Ideally would like to access the above line ( view.php) :

[php]
if(GetMapping($TableID,$Field) == $Field)
[/php]

and explode the mapping array in $TMP or $Field to set a VARIABLE eg.:
[php]
if(GetMapping($TableID,$Field) == $Field)
$TMP = trim(GetMapping($TableID,$Field));
$TMP = explode(".", $TMP);
$BC_ID = $TMP[0];
);[/php]

Then create the

href= ( view.php:LINE 268 ) to be something like :

[php]

<a href="image.php?action=Edit&table_id=<?php echo $TableID;?>&row_id=<?php echo $ResultCounter;?>&BC_ID=<?php echo $BC_ID?;>
[/php]
Hope that helps…

K

Fixed this please disregard… admin please CLOSE. thanks again

Sponsor our Newsletter | Privacy Policy | Terms of Service