Jump to content

sql-query -> list -> click -> add to array


Zepur

Recommended Posts

Hi!

I am trying to make this site (http://karbotelling.com/TEST/index.php), and because I don't know any PHP I always encounter new problems.

Or rather I cant find the right solutions to the problems.

 

The search field gets values from mysql-query, and outputs it like this:

$querry = ("SELECT * FROM db WHERE ean LIKE '%$trimmed%' OR navn LIKE '%$trimmed%'
ORDER BY navn ASC LIMIT 37");
$numresults=mysql_query($querry);
$numrows=mysql_num_rows($numresults);
if ($numrows == 0)
{
   echo "Kunne dessverre ikke finne noe ved å søke på: " . $trimmed . ".";
}
else
{
// get results
   $bresult = mysql_query($querry) or die("Couldn't execfff query");
   while ($brow= mysql_fetch_array($bresult))
   {
      echo '<div id="mlist" style="width:672; padding-right:5px; align:left;">
      <div id="bulk2" style="padding-bottom:3px">
      <div id="mnavn" class="madd" style="width: 280px">'. $brow['navn'] . '<>
      <div id="mkcal" class="madd" style="width: 62px">'. (float)$brow['kcal'] . '<span id="mspan">kcal</span><>
      <div id="mkarb" class="madd" style="width: 65px">'. (float)$brow['karb'] . '<span id="mspan">g</span><>
      <div id="mprot" class="madd" style="width: 80px">'. (float)$brow['prot'] . '<span id="mspan">g</span><>
      <div id="mfett" class="madd" style="width: 60px">'. (float)$brow['fett'] . '<span id="mspan">g</span><>
      <div id="mean" class="madd" style="width: 125px">'.$brow['ean'].'</span><>
      <><>';
      $lll['navn'][] = $brow['navn'];
   } // end while
}

 

I want to be able to click each .madd-class, to add the values from the divs into a new array. So I can call the array in a separate link.

Its to make a meal, by selecting food you search.

 

I'm sorry if this should be done with javascript /jQuery/ajax and/or something else, but as I said, I have no clue as what to use. And truly sorry if I posted this in the wrong section.

Link to comment
https://forums.phpfreaks.com/topic/254832-sql-query-list-click-add-to-array/
Share on other sites

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.