Jump to content

[SOLVED] Help with a Function


JSHINER

Recommended Posts

Try this:

 

<?php 

function productList($prod_id, $id) {
   $str = '<p style="margin-left: 15px; font-size: 14px;"><a href="ticket.php?id='.$id.'&p=prod_3">'.$prod_id.'</a></p>';
   return $str;
}

echo productList('2', $_GET['id']);

?>

 

All I did was assign what you had printing inside of the function to a variable, and I returned it.

Ok it does work with my code. Figured out the issue is here:

 

When I do:

<?php 

function productList($prod_id, $id) {

if($prod_id=="1") { $prod = $page['ticket']['prod_1']; }
if($prod_id=="2") { $prod = $page['ticket']['prod_2']; }

print '<p style="margin-left: 15px; font-size: 14px;"><a href="ticket.php?id='.$id.'&p=prod_3">'.$prod.'</a></p>';

}

echo productList('2', $_GET['id']);

?>

 

It does not work. Assuming $prod is not working. How come?

 

I know $page['ticket']['prod_1'] exists because it's used elsewhere on the page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.