Jump to content

bidgeir

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bidgeir's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi. I am trying to call a function inside a while loop which returns a array.  The script seems to stop running when I call the function and I dont know why. Here is part of my code: The bold code is where I call my function. while ($row=mysql_fetch_array($result)) { $types = $row['type']; echo '<h3>' . $types . '</h3>'; [b]$ar = getProduct($types);[/b] echo "bla"; foreach($ar as $value) { echo "<tr height='30'><td width='150'>" . $value . "</td><td width='50'>&nbsp;</td><td width='50'> 9 tommur</td><td width='50'><input type='checkbox' name='9inch'></td><td width='50'>12 tommur</td> <td width='50'><input type='checkbox' name='12inch'></td><td width='50'>16 tommu</td> <td width='50'><input type='checkbox' name='16inch'></td><td width='50'>Fjöldi</td><td width='50'><input type='text' name='qt'></td></tr>"; } $counter++; } Here is the function: function getProduct($type) { include 'db.php'; if (!($connection = @ mysql_pconnect($hostName,                                         $username,                                         $password)))         die("Could not connect to database");     if (!mysql_select_db($databaseName, $connection))         showerror(); $theType = $type; $query = "SELECT name FROM products WHERE type='$theType'"; if (!($result = @ mysql_query($query1, $connection)))         showerror(); $row=mysql_fetch_array($result); return ($row); } The script shows everything until I call the function. I added echo "bla"; to see if anything happend after the call, but it doesnt. Hope someone can help, Ásgeir
×
×
  • 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.