473,320 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to get only the first path from Mysql?

13
Ok, let see if I can explain.
I have a query from my db which inserts id of the inputted objects. The result is in a string which I use to show the content. In one of the sql tables, there are path names to images. One id can have up to 3 images assigned which gives 3 path names. But here is the catch, I only want to display the first path name. My query looks like this:
Expand|Select|Wrap|Line Numbers
  1. $data = "
  2.                 SELECT
  3.                   a.annonsid,
  4.                   a.datum,
  5.                   a.datumtid,
  6.                   a.lan,
  7.                   a.radio1,
  8.                   a.rubrik,
  9.                   a.stad,
  10.                   a.pris,
  11.                   a.typ,
  12.                   a.kategori,
  13.                   b.annonsid,
  14.                   b.bildpath
  15.  
  16.                 FROM
  17.                   annonser AS a
  18.                 LEFT JOIN
  19.                   annonser_bilder AS b
  20.                 ON
  21.                   a.annonsid=b.annonsid
  22.  
  23.                 WHERE
  24.                   a.kontrollerad = 'ja'
  25.                   $sokord
  26.  
  27.                 LIMIT
  28.  
  29.                   $offset, $antal_bilder";
  30.  
  31.                 $query = mysql_query($data);
  32.                 $no=1;
  33.                 while ($templista = mysql_fetch_array($query))
  34.                 {
  35.  
  36.  
My code for the output looks like this:
Expand|Select|Wrap|Line Numbers
  1.  if($templista[bildpath])
  2.                  {
  3.                echo "</td>";
  4.                echo "<td width=\"60\" height=\"30\">";
  5.                echo "<a href=\"?annonsID=".$templista[annonsid]."\">";
  6.                $size = getimagesize($templista[bildpath]);
bildpath is the path name for the image.

I'm not a programmer by all means and I have been struggling to learn. Hopefully someone can help me with this?

Best regards,
Morgan
Mar 30 '10 #1
18 2035
Markus
6,050 Expert 4TB
Can you please do the following, after you have queried your database so we can see what data is being stored:

Expand|Select|Wrap|Line Numbers
  1. var_dump($templista['bildpath']);
Also, when accessing elements of an array, surround the array key (if it's a string) with quotation marks.
Mar 30 '10 #2
Fynd
13
Thanks for your suggestions and reply. The VAR DUMP outputs this:
Expand|Select|Wrap|Line Numbers
  1. string(46) "annonsbilder/201003300702531217.210.81.146.jpg"  string(46) "annonsbilder/201003300658152217.210.81.146.jpg"  string(46) "annonsbilder/201003300829383217.210.81.146.jpg"  
I have 3 images in that id and I just wanna display the first. It should be OK with GROUP BY a.annonsid but doesn't work as I have a string in the WHERE statement because this string handles the search function. If there was a way to delimit or reduce or extract the "bildpath" so only the first image was shown but I can not see it right now. Hoping for your help.
I'm really grateful that you took your time to answer.
Mar 30 '10 #3
Markus
6,050 Expert 4TB
Well, in your SQL query, you could LIMIT 1, or you could access the first element of your array: $templista['bildpath'][0];

Mark.
Mar 30 '10 #4
Fynd
13
Thanks Markus, if I LIMIT 1, I could not list the other records in my db as I now LIMIT with $offset,$number_of_records.
I tried the [0] in my array but the VAR_DUMP came up with this:
string(1) "a" string(1) "a" string(1) "a"
It seams like the path to the image is lost. Any more ideas? Sorry to bother you with questions, but now I'm lost. I know and understand why it happens but to be able to make it..........

Best regards,
Morgan
Mar 30 '10 #5
Markus
6,050 Expert 4TB
Please post your revised code.

P.S. Remember to use [code][/code] tags around the code.
Mar 30 '10 #6
Fynd
13
Ok, here is the full query down to the img src. It will then continue showing the other arrays but I thought there was no meaning with that as the problem is located in the bildpath.
The code is a mess right now and I haven't cleaned it up due to development so here it is:
Expand|Select|Wrap|Line Numbers
  1. $antal_bilder = ANTAL_SENAST_INLAGGDA_ANNONSER;
  2.  
  3.               $sql = "
  4.  
  5.                 SELECT
  6.  
  7.                   a.annonsid,
  8.  
  9.                   a.datum,
  10.  
  11.                   a.datumtid,
  12.  
  13.                   a.lan,
  14.  
  15.                   a.typ,
  16.  
  17.                   a.rubrik,
  18.  
  19.                   a.stad,
  20.  
  21.                   a.pris,
  22.  
  23.                   a.marke,
  24.  
  25.                   a.kategori,
  26.                   b.id,
  27.                   b.bildnamn,
  28.  
  29.                   b.bildpath
  30.  
  31.                 FROM
  32.  
  33.                   annonser AS a
  34.  
  35.                 LEFT JOIN
  36.  
  37.                   annonser_bilder AS b
  38.  
  39.                 ON
  40.  
  41.                   a.annonsid=b.annonsid
  42.  
  43.                 WHERE
  44.  
  45.                   a.kontrollerad = 'ja' 
  46.  
  47.  
  48.                 $sokord
  49.  
  50.  
  51.                 LIMIT
  52.  
  53.                   $offset, $antal_bilder
  54.  
  55.                 ";
  56. $rs = mysql_query($sql);
  57.  
  58.                 while ($visa = mysql_fetch_array($rs))
  59.  
  60.  
  61.                 {
  62.  
  63. //$result = mysql_query("SELECT bildpath FROM annonser_bilder LIMIT 0");
  64. //if (!$result) {
  65.     //echo 'Could not run query: ' . mysql_error();
  66.     //exit;
  67. //}
  68. //$row = mysql_fetch_row($result);
  69.  
  70. //$path = $row[0]; // 42
  71. //echo $row[1]; // the email value
  72.  
  73.  
  74. //-------------------Slut gamla frågan----------------------------------------------------//  
  75.       echo "\t<tr onmouseover=\"javascript:style.background='".$varannan."'\" onmouseout=\"javascript:style.background=''\">\n";
  76.  
  77. //--------------------Nya visa---------------------------------------------------------//
  78.                  echo "</td>";
  79.                  echo "<td width=\"60\" height=\"30\">";
  80.                  echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  81.                  echo "<span class=\"small\">";
  82.                  echo "$visa[datum]";
  83.                  echo "</td></span>";
  84.                   echo '</a>';
  85.  
  86.         var_dump($visa['bildpath'][1]);            
  87.                  //test=$visa[bildpath];
  88.  
  89.  
  90. //echo $test;
  91.  
  92.  
  93.                if($visa[bildpath])
  94.                  {
  95.                echo "</td>";
  96.                echo "<td width=\"60\" height=\"30\">";
  97.                echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  98.                $size = getimagesize($visa[bildpath]);
  99.        $height = $size[1];
  100.        $width = $size[0];
  101.      if ($height > 199)
  102.           {
  103.                $height = 60;
  104.                $percent = ($size[1] / $height);
  105.                $width = ($size[0] / $percent);
  106.           }
  107.      else if ($width > 199)
  108.           {
  109.                $width = 60;
  110.                $percent = ($size[0] / $width);
  111.                $height = ($size[1] / $percent);
  112.           }
  113.                //echo "<img src=\"thumbnails.php?src=$row1[bildpath]\" style=\"border: 0;\" />";
  114.                echo "\t\t<img src=\"{$visa[bildpath]}\" width=\"$width\" height=\"$height\" border=\"1\"><br>";
Mar 30 '10 #7
Fynd
13
Hi Markus,
It seems like that the string I am searching, shows up as string46 when the var_dump($visa['bildpath']); is used but when using var_dump($visa['bildpath']['0']); I only get the single letters from the image path. In this case var_dump($visa['bildpath']['0']); will output string 1 "a" var_dump($visa['bildpath']['1']); will output string 1 "n" and so on.
Well if we could find a way to output string46 one time we have it.

The string 46 is the container for the array bildpath, now I have to find the method to show the row of string 46.

Cheers,

//Morgan
Mar 31 '10 #8
Atli
5,058 Expert 4TB
Hey.

@Fynd
Could you show us the query after the string has been constructed?
You could just do echo $sql; exit; before the mysql_query($sql); and print the results.


You really should limit the query, rather than do this in the PHP code, but if all else fails you can always just record which ID's you have already printed and skip each subsequent row that has that ID.
For example:
Expand|Select|Wrap|Line Numbers
  1. $used_ids = array();
  2. while($row = mysql_fetch_assoc($result)) {
  3.     if(in_array($row['id'], $user_ids)) {
  4.         continue; // Skip this row.
  5.     }
  6.     $used_ids[] = $row['id'];
  7.  
  8.     // etc...
  9. }
  10.  
Mar 31 '10 #9
Fynd
13
God dag Atli,
Well the application itself is a advertising script which contains a number of adverts. The info from the adverts are stored into 2 db's of the mysql database, 1 for the information about the advertiser etc, and 1 for the id, path and path name of the images stored with the adverts. This complicates things as I had to join 2 db's hence the code.
The id of the advert, which is stored in the first db, can have multiple images attached to the same id. This works well with 1 image, but when there are more than 1, there will be problem as that the search function is also a parameter of the query. You can search the db for whatever you want. But when there are 2 images you also get 2 image paths from the db and the script is doing the right thing when listing all adverts in the search function. It treats every extra image path as an extra advert and I just want to extract the first image path from the adverts id.

Id1 lot of information 3 images makes the output repeating 3 times
Id2 lot of information 2 images makes the output repeating 2 times
Id3 lot of information 1 images makes the output 1 times

The code before the query is quite complex but I think I post the whole lot. Pls. bare in mind I'm not a programmer and the code is really messy right now.
Thanks for helping out!
Some strings are in swedish but I think you understand them :-)
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //----- Kollar vilken annons som visats mest sista veckan- //
  3. $hetAnnons =  date("Y-m-d", mktime (0,0,0,date("m"),date("d")-7,date("Y")));
  4. $antal[2] = mysql_fetch_array(mysql_query("SELECT annonsid,datum,visad FROM annonser WHERE datum > '$hetAnnons' ORDER BY visad DESC LIMIT 0, 1"));
  5.  
  6. //----- Kollar antal personer som är online -------------- //
  7. $antal[0] = mysql_num_rows(mysql_query ("SELECT DISTINCT ip FROM online")) + 11;
  8.  
  9. //----- Fyller arrayen med alla veckodagar ----------------//
  10. $dagar = array("Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag");
  11.  
  12. //----- Fyller arrayen med alla månader -------------------//
  13. $manader = array(1 => "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December");
  14. ?>
  15. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
  16. </script>
  17. <script type="text/javascript" src="jquery.magnifier.js">
  18.  
  19. /***********************************************
  20. * jQuery Image Magnify- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
  21. * This notice MUST stay intact for legal use
  22. * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
  23. ***********************************************/
  24.  
  25. </script>
  26. <?php
  27. //----- Om sökknappen blivigt intryckt gör vi en söksträng //
  28. $ord = trim($ord);
  29. if($sok)
  30.   {
  31.   $sortera ="datumtid DESC";
  32.   $sokvag = "";
  33.   $sokord = null;
  34.   $offset = 0;
  35.   $prev = $offset - $antalpersida;
  36.   $next = $offset + $antalpersida;
  37.   if($typ)
  38.     {
  39.     $sokvag = $typ;
  40.     $sokord = $sokord . " AND typ = '".$typ."'";
  41.     }
  42.   else
  43.     {
  44.     $sokvag = $typover;
  45.     }
  46.   if($kategori)
  47.     {
  48.     $sokvag = $sokvag." : ".$kategori;
  49.     $sokord = $sokord." AND kategori = '".$kategori."'";
  50.     }
  51.   else
  52.     {
  53.     $sokvag = $sokvag." : ".$kategoriover;
  54.     }
  55.   if($ord)
  56.     {
  57. //----- Nu söker vi i både rubrik och text [OR text sist]--//
  58.     $sokord = $sokord." AND (rubrik like '%".$ord."%' OR info like '%".$ord."%')";
  59.     $sokvag = $sokvag." : ".$ord;
  60.     }
  61.   if($lan)
  62.     {
  63.     $sokvag = $sokvag." : ".$lan;
  64.     $sokord = $sokord." AND lan = '".$lan."'";
  65.     }
  66.   else
  67.     {
  68.     $sokvag = $sokvag." : ".$lanover;
  69.     }
  70.   if($pris)
  71.     {
  72.     $sokvag = $sokvag." : 0-".$pris."kr";
  73.     $sokord = $sokord." AND pris BETWEEN 0 AND ".$pris;
  74.     }
  75.   else
  76.     {
  77.     $sokvag = $sokvag." : ".$prisover;
  78.     }
  79.   $sokord = $sokord." ORDER BY ".$sortera;
  80.   }
  81. //----- Om next / prev blivigt intryckt sätt rätt värden --//
  82. elseif($nextprev)
  83.   {
  84.   $offset += 0;
  85.   $prev = $offset-$antalpersida;
  86.   $next = $offset+$antalpersida;
  87.   }
  88. //----- Om Om någon har tryckt på kat. på startsidan ------//
  89. elseif($visatyper)
  90.   {
  91.   $sortera ="datumtid DESC";
  92.   $sokvag = "";
  93.   $sokord = " AND typ = '".$visatyper."'";
  94.   $sokord = $sokord." ORDER BY ".$sortera;
  95.   $offset = 0;
  96.   $prev = $offset - $antalpersida;
  97.   $next = $offset + $antalpersida;
  98.   }
  99. //----- Tar bort dom satans bakslasarna ------------------ //
  100. $sokord = stripslashes($sokord);
  101.  
  102.  
  103. echo "<table width=\"680\" height=\"800\" class=\"tabellram\" bgcolor=\"".$bgtabell."\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n";
  104.     echo "\t\t<form method=post action=".$PHP_SELF.">\n";
  105.   echo "\t<tr>\n";
  106.   echo "\t<td width=\"680\" height=\"15\" colspan=\"4\">\n";
  107.   echo "\t</td></tr>\n";
  108. //-- listar upp sökformuläret ------------------------------//
  109.   echo "\t<tr>\n";
  110.   echo "\t<td width=\"10\" height=\"20\">\n";
  111.   echo "\t</td>\n";
  112. //-- listar alla typer -------------------------------------//
  113.   echo "\t<td width=\"190\" height=\"20\">\n";
  114.     echo "\t\t<select name=\"typ\" size=\"1\">\n";
  115.     echo "\t\t<option value=\"\">".$typover."</option>\n";
  116.     echo "\t\t<option value=\"\">".$typstreck."</option>\n";
  117.     foreach($cmbtyp as $namn)
  118.       {
  119.       echo "\t\t<option value=\"".$namn."\"";
  120.       if (isset($typ) and $typ == $namn)
  121.         {
  122.         echo " selected=\"true\"";
  123.         }
  124.       echo ">".$namn."</option>\n";
  125.       }
  126.     echo "\t\t</select>\n";
  127.   echo "\t</td>\n";
  128. //-- listar köp sälj eller bytes ---------------------------//
  129.   echo "\t<td width=\"190\" height=\"20\">\n";
  130.     echo "\t\t<select name=\"kategori\" size=\"1\">\n";
  131.  
  132.     echo "\t\t<option value=\"\">".$kategoriover."</option>\n";
  133.     echo "\t\t<option value=\"\">".$kategoristreck."</option>\n";
  134.  
  135.     foreach($cmbkategori as $namn)
  136.       {
  137.       echo "\t\t<option value=\"".$namn."\"";
  138.       if (isset($kategori) and $kategori == $namn)
  139.         {
  140.         echo " selected=\"true\"";
  141.         }
  142.       echo ">".$namn."</option>\n";
  143.       }
  144.     echo "\t\t</select>\n";
  145.   echo "\t</td>\n";
  146. //-- textbox att skriva in sökord i ------------------------//
  147.   echo "\t<td width=\"190\" height=\"31\">\n";
  148.     echo "\t\t<input type=\"text\" size=\"20\" name=\"ord\" maxlength=\"30\" value=\"";
  149.     if(isset($ord))
  150.       {
  151.       echo $ord;
  152.       }
  153.     echo "\">\n";
  154.   echo "\t</td></tr>\n";
  155. //-- tom cell ----------------------------------------------//
  156.   echo "\t<tr>\n";
  157.   echo "\t<td width=\"10\" height=\"20\">\n";
  158.   echo "\t</td>\n";
  159. //-- listar alla län ---------------------------------------//
  160.   echo "\t<td width=\"190\" height=\"20\">\n";
  161.     echo "\t\t<select name=\"lan\" size=\"1\">\n";
  162.     echo "\t\t<option value=\"\">".$lanover."</option>\n";
  163.     echo "\t\t<option value=\"\">".$lanstreck."</option>\n";
  164.     foreach($cmblan as $namn)
  165.       {
  166.       echo "\t\t<option value=\"".$namn."\"";
  167.       if (isset($lan) and $lan == $namn)
  168.         {
  169.         echo " selected=\"true\"";
  170.         }
  171.       echo ">".$namn."</option>\n";
  172.       }
  173.     echo "\t\t</select>\n";
  174.   echo "\t</td>\n";
  175. //-- listar alla prisklasser -------------------------------//
  176.   echo "\t<td width=\"190\" height=\"20\">\n";
  177.     echo "\t\t<select name=\"pris\" size=\"1\">\n";
  178.     echo "\t\t<option value=\"\">".$prisover."</option>\n";
  179.     echo "\t\t<option value=\"\">".$prisstreck."</option>\n";
  180.     foreach($cmbpris as $namn)
  181.       {
  182.       echo "\t\t<option value=\"".$namn."\"";
  183.       if (isset($pris) and $pris == $namn)
  184.         {
  185.         echo " selected=\"true\"";
  186.         }
  187.       echo ">Max ".$namn." kr</option>\n";
  188.       }
  189.     echo "\t\t</select>\n";
  190.   echo "\t</td>\n";
  191. //-- sök knapp ---------------------------------------------//
  192.   echo "\t<td width=\"190\" height=\"20\">\n";
  193.   echo "\t\t<input type=\"submit\" name=\"sok\" class=\"knapp\" value=\" Sök annons  \">\n";
  194.   echo "\t<tr>\n";
  195.   echo "\t</td></tr>\n";
  196.     echo "\t\t</form>\n";
  197.  
  198.     /*
  199.     ?>
  200.  
  201.      <td colspan="4" align="right"<script type="text/javascript"> var uri = 'http://impse.tradedoubler.com/imp?type(js)pool(384489)a(1793211)' + new String (Math.random()).substring (2, 11);
  202. document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');</script></tr></td>
  203. <?
  204. */
  205. //-- Slut på sökformulär -----------------------------------//
  206.   //echo "\t<tr>\n";
  207.   echo "\t<td width=\"680\" height=\"10\" colspan=\"4\">\n";
  208.   echo "\t</td></tr>\n";
  209.  
  210. if(!($sok or $nextprev or $visatyper))
  211.   {
  212.  
  213. ?>
  214.   <tr>
  215.   <td width="680" colspan="4"><table width="650" height="12" border="0" cellspacing="0" cellpadding="0" align="center">
  216.     <tr align="top">
  217.       <td class="grabold12" align="left" width="400"><strong>Välkommen till Fyndklippet.se!</strong><br />
  218.           <span class="graboldsmall">Här annonserar privatpersoner <br />
  219.             och företag helt GRATIS!<br />
  220.             Mycket enklare kan det inte bli!<br />
  221.              </td>
  222.       <td><script type="text/javascript"> var uri = 'http://impse.tradedoubler.com/imp?type(js)pool(384489)a(1793211)' + new String (Math.random()).substring (2, 11);
  223. document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset="ISO-8859-1"></sc'+'ript>');</script></td>
  224.     </tr>
  225.   </table>
  226.     <?
  227.   echo "\t</td></tr>\n";
  228.   }
  229.   echo "\t<tr>\n";
  230.   echo "\t<td width=\"651\" colspan=\"10\" valign=\"top\">\n";
  231.  
  232. if($sok or $nextprev or $visatyper)
  233.   {
  234. //----- Checkar hur många poster det finns --------------- //
  235.   $total = mysql_num_rows(mysql_query("SELECT * FROM annonser WHERE kontrollerad='ja' $sokord"));
  236. echo "<table width=\"680\" class=\"grabold\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\">\n";
  237.   echo "\t<tr>\n";
  238.   echo "\t<td width=\"600\" height=\"25\" class=\"litenrubrik\" colspan=\"6\" background=\"".$bgrubrikbild."\" bgcolor=\"".$bgrubrik."\" align=\"center\">\n";
  239.     if($total > 0)
  240.       {
  241.       echo "\t\tVisar ";
  242.       echo $offset+1;
  243.       echo " till ";
  244.       if(($offset+$antalpersida) < $total)
  245.         {
  246.         echo $offset+$antalpersida;
  247.         }
  248.       else
  249.         {
  250.         echo $total;
  251.         }
  252.       echo " av ";
  253.       echo $total;
  254.       echo " träffar.\n";
  255.       }
  256.     else
  257.       {
  258.       echo "\t\tTyvärr fick du ".$total." träffar, försök med att göra en ny sökning.\n";
  259.       }
  260.     echo "\t</td></tr>\n";
  261.  
  262.  
  263.  //---------------Här---------------------------------//             
  264.  
  265. //$antal_bilder = ANTAL_SENAST_INLAGGDA_ANNONSER;
  266.  
  267.               $sql = "
  268.  
  269.                 SELECT
  270.  
  271.                   a.annonsid,
  272.  
  273.                   a.datum,
  274.  
  275.                   a.datumtid,
  276.  
  277.                   a.lan,
  278.  
  279.                   a.typ,
  280.  
  281.                   a.rubrik,
  282.  
  283.                   a.stad,
  284.  
  285.                   a.pris,
  286.  
  287.                   a.marke,
  288.  
  289.                   a.kategori,
  290.                   b.id,
  291.                   b.bildnamn,
  292.  
  293.                   b.bildpath
  294.  
  295.                 FROM
  296.  
  297.                   annonser AS a
  298.  
  299.                 LEFT JOIN
  300.  
  301.                   annonser_bilder AS b
  302.  
  303.                 ON
  304.  
  305.                   a.annonsid=b.annonsid
  306.  
  307.                 WHERE
  308.  
  309.                   a.kontrollerad = 'ja' 
  310.                    $sokord
  311.  
  312.                 LIMIT
  313.                 $offset, $antal_bilder
  314.  
  315.                 ";
  316. $rs = mysql_query($sql);
  317.  
  318.                 while ($visa = mysql_fetch_array($rs))
  319.  
  320.  
  321.                 {
  322.  
  323. //$result = mysql_query("SELECT bildpath FROM annonser_bilder LIMIT 0");
  324. //if (!$result) {
  325.     //echo 'Could not run query: ' . mysql_error();
  326.     //exit;
  327. //}
  328. //$row = mysql_fetch_row($result);
  329.  
  330. //$path = $row[0]; // 42
  331. //echo $row[1]; // the email value
  332.  
  333.  
  334. //-------------------Slut gamla frågan----------------------------------------------------//  
  335.       echo "\t<tr onmouseover=\"javascript:style.background='".$varannan."'\" onmouseout=\"javascript:style.background=''\">\n";
  336.  
  337. //--------------------Nya visa---------------------------------------------------------//
  338.                  echo "</td>";
  339.                  echo "<td width=\"60\" height=\"30\">";
  340.                  echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  341.                  echo "<span class=\"small\">";
  342.                  echo "$visa[datum]";
  343.                  echo "</td></span>";
  344.                   echo '</a>';
  345.  
  346.         //var_dump($visa['bildpath'],$sokord);            
  347.                  //test=$visa[bildpath];
  348.  
  349.  
  350. //echo $test;
  351.  
  352.  
  353.                if($visa[bildpath])
  354.                  {
  355.                echo "</td>";
  356.                echo "<td width=\"60\" height=\"30\">";
  357.                echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  358.                $size = getimagesize($visa[bildpath]);
  359.        $height = $size[1];
  360.        $width = $size[0];
  361.      if ($height > 199)
  362.           {
  363.                $height = 60;
  364.                $percent = ($size[1] / $height);
  365.                $width = ($size[0] / $percent);
  366.           }
  367.      else if ($width > 199)
  368.           {
  369.                $width = 60;
  370.                $percent = ($size[0] / $width);
  371.                $height = ($size[1] / $percent);
  372.           }
  373.                //echo "<img src=\"thumbnails.php?src=$row1[bildpath]\" style=\"border: 0;\" />";
  374.                echo "\t\t<img src=\"{$visa[bildpath]}\" width=\"$width\" height=\"$height\" border=\"1\"><br>";
  375.                echo '</a>';
  376.                echo "</td>";                 
  377.                  }
  378.                else
  379.                 {
  380.                 echo "</td>";
  381.                 echo "<td width=\"30\" height=\"30\">";
  382.                 echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  383.                 //echo "<img src=\"grafik/ingenkamera.gif\" border=\"0\" width=\"50\" height=\"40\">";
  384.                 echo '</a>';
  385.                echo "</td>";                 
  386.                  }
  387.  
  388.  
  389.             /*
  390.  
  391.                   echo "</td>";
  392.                   echo "<td width=\"90\" height=\"30\">";
  393.                   echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  394.                   echo "$visa[marke]";
  395.                   echo '</a>';
  396.                   echo "</td>";
  397. */
  398.                   echo "</td>";
  399.                   echo "<td width=\"250\" height=\"50\">";
  400.                   echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  401.                   echo "$visa[rubrik]";
  402.                   //echo "<a href=\"?annonsID=".$row1[annonsid]."\">";
  403.                   echo "<span class=\"small\">";
  404.                   echo "<br>";
  405.                   echo "$visa[pris]".":-";   
  406.                   echo '</a>';
  407.                   echo "</td></span>";
  408.  
  409.  
  410.                   echo "</td>";
  411.                   echo "<td width=\"71\" height=\"30\">";
  412.                   echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  413.                   echo "$visa[typ]";
  414.                   echo "<span class=\"small\">";
  415.                   echo "<br>";
  416.                   echo "$visa[lan]";
  417.                   echo '</a>';
  418.                   echo "</td><span/>";
  419.  
  420.  
  421.  
  422.  
  423. /*
  424.                   echo "</td>";
  425.                   echo "<td width=\"90\" height=\"40\">";
  426.                   echo "<a href=\"?annonsID=".$visa[annonsid]."\">";
  427.                   echo "$visa[radio1]";         
  428.                   echo '</a>';
  429.                   echo "</td>";
  430. */
  431.  
  432.  //------------------------Slut på nya visa--------------------------------------//
  433.       echo "\t<tr>\n";
  434.       echo "\t<td width=\"400\" height=\"1\" colspan=\"6\" background=\"".$bgstreck570."\" align=\"center\">\n";
  435.       echo "\t</td></tr>\n";
  436.       }
  437.     echo "\t<tr><td width=\"600\" colspan=\"6\" valign=\"top\" align=\"center\">\n";
  438.     echo "<table width=\"600\" align=\"center\">\n";
  439.       echo "\t\t<form method=post action=".$PHP_SELF.">\n";
  440.       echo "\t<tr><td width=\"270\" align=\"left\" valign=\"top\">\n";
  441.       echo "\t\t<input class=\"knapp\" type=\"submit\" value=\"Ny sökning / Hem\">\n";
  442.       echo "\t\t</td>\n";
  443.       echo "\t\t</form>\n";
  444. //----- Skapar knappar först bakåtknappen ------------------//
  445.       if(!($prev < 0))
  446.         {
  447.         echo "\t\t<form method=post action=".$PHP_SELF.">\n";
  448.         echo "\t<td width=\"150\" align=\"center\" valign=\"top\">\n";
  449.         echo "\t\t<input type=\"submit\" name=\"nextprev\" class=\"knapp\" value=\"<-- Förra ".$antalpersida."\">\n";
  450.         echo "\t\t<input type=\"hidden\" name=\"offset\" Value=".$prev.">\n";
  451.         echo "\t\t<input type=\"hidden\" name=\"sokord\" Value=\"".$sokord."\">\n";
  452.         echo "\t\t<input type=\"hidden\" name=\"sokvag\" Value=\"".$sokvag."\">\n";
  453.         echo "\t\t<input type=\"hidden\" name=\"typ\" Value=\"".$typ."\">\n";
  454.         echo "\t\t<input type=\"hidden\" name=\"kategori\" Value=\"".$kategori."\">\n";
  455.         echo "\t\t<input type=\"hidden\" name=\"ord\" Value=\"".$ord."\">\n";
  456.         echo "\t\t<input type=\"hidden\" name=\"lan\" Value=\"".$lan."\">\n";
  457.         echo "\t\t<input type=\"hidden\" name=\"pris\" Value=\"".$pris."\">\n";
  458.         echo "\t</td>\n";
  459.         echo "\t\t</form>\n";
  460.         }
  461.       else
  462.         {
  463.         echo "\t<td width=\"150\" align=\"center\" valign=\"top\">\n";
  464.         }
  465. //----- Sedan framåtknappen --------------------------------//
  466.       if($total > $next)
  467.         {
  468. //----- Sätter rätt antal på sista annonserna --------------//
  469.         if(($total - $next) > $antalpersida)
  470.           {
  471.           $sista = $antalpersida;
  472.           }
  473.         else
  474.           {
  475.           $sista = $total - $next;
  476.           }
  477.         echo "\t\t<form method=post action=".$PHP_SELF.">\n";
  478.         echo "\t<td width=\"150\" align=\"right\" valign=\"top\">\n";
  479.         echo "\t\t<input type=\"submit\" name=\"nextprev\" class=\"knapp\" value=\"Nästa ".$sista." -->\">\n";
  480.         echo "\t\t<input type=\"hidden\" name=\"offset\" Value=".$next.">\n";
  481.         echo "\t\t<input type=\"hidden\" name=\"sokord\" Value=\"".$sokord."\">\n";
  482.         echo "\t\t<input type=\"hidden\" name=\"sokvag\" Value=\"".$sokvag."\">\n";
  483.         echo "\t\t<input type=\"hidden\" name=\"typ\" Value=\"".$typ."\">\n";
  484.         echo "\t\t<input type=\"hidden\" name=\"kategori\" Value=\"".$kategori."\">\n";
  485.         echo "\t\t<input type=\"hidden\" name=\"ord\" Value=\"".$ord."\">\n";
  486.         echo "\t\t<input type=\"hidden\" name=\"lan\" Value=\"".$lan."\">\n";
  487.         echo "\t\t<input type=\"hidden\" name=\"pris\" Value=\"".$pris."\">\n";
  488.         echo "\t</td>\n";
  489.         echo "\t\t</form>\n";
  490.         }
  491.       else
  492.         {
  493.         echo "\t<td width=\"150\" align=\"center\" valign=\"top\">\n";
  494.         echo "\t</td>\n";
  495.         }
  496.       echo "\t</tr>\n";
  497.     echo "</table>\n";
  498.  
  499.     echo "\t</td></tr>\n";
  500.   echo "</table>\n";
  501.   }
  502. else
  503.   {
  504.  
  505. //-- Tabell med 4 billigaste/8 senaste/antal per kategori --//
  506.   echo "<table width=\"670\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n";
  507.  
  508.     echo "\t<tr valign=\"top\">\n";
  509.     echo "\t<td width=\"300\">\n";
  510.  
  511. //-- Tabell med 4 billigaste sista månaden/8 senaste -------//
  512. /*
  513.    $fraga = "SELECT annonsid,datum,datumtid,rubrik,pris FROM annonser ORDER BY datumtid DESC LIMIT 0, 13 ";
  514.    */ 
  515.  
  516.    $antal_bilder = ANTAL_SENAST_INLAGGDA_ANNONSER;
  517.               $fraga = "
  518.                 SELECT
  519.                   a.annonsid,
  520.                   a.datum,
  521.                   a.datumtid,
  522.                   a.lan,
  523.                   a.radio1,
  524.                   a.rubrik,
  525.                   a.stad,
  526.                   a.pris,
  527.                   a.typ,
  528.                   b.bildpath,
  529.                   b.bildnamn
  530.                 FROM
  531.                   annonser AS a
  532.                 LEFT JOIN
  533.                   annonser_bilder AS b
  534.                 ON
  535.                   a.annonsid=b.annonsid
  536.                 WHERE
  537.                   a.kontrollerad = 'ja'  
  538.                 GROUP BY
  539.                   a.annonsid
  540.                 ORDER BY
  541.                   a.datumtid DESC
  542.                 LIMIT
  543.                   0, 15
  544.                 ";
  545.                 //$rs = mysql_query($sql);
  546.   $data = mysql_query($fraga);
  547.  
  548.  
  549.     echo "<table width=\"300\" class=\"tabellram\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\">\n";
  550.       echo "\t<tr>\n";
  551.       echo "\t<td width=\"300\" height=\"25\" align=\"center\" class=\"rubrik\" colspan=\"4\" background=\"".$bgrubrikbild."\" bgcolor=\"".$bgrubrik."\">".$rubriker [1]."\n";
  552.       echo "\t</td></tr>\n";
  553.       while ($billigaste = mysql_fetch_array($data))
  554.         {
  555.  
  556.         echo "\t<tr onmouseover=\"javascript:style.background='".$varannan."'\" onmouseout=\"javascript:style.background=''\">\n";
  557.         echo "\t<td class=\"small\" width=\"70\">\n";
  558.         echo "\t\t<a href=\"index.php?annonsID=".$billigaste[annonsid]."\">";
  559.         echo $billigaste[datum];
  560.         echo "</a>\n";
  561.         echo "\t</td>\n";
  562.         echo "\t<td class=\"small\" width=\"130\">\n";
  563. //-- Kapar av rubriken i rätt längd och lägger till punkter //
  564.         echo "\t\t<a href=\"index.php?annonsID=".$billigaste[annonsid]."\">";
  565.         if(strlen($billigaste[rubrik]) > 30)
  566.           {
  567.           echo substr($billigaste[rubrik],0,33)."....";
  568.           }
  569.         else
  570.           {
  571.           echo $billigaste[rubrik];
  572.           }
  573.         echo "</a>\n";
  574.         echo "\t</td>\n";
  575.  
  576.         echo "\t<td class=\"small\" width=\"80\">\n";
  577.         echo "\t\t<a href=\"index.php?annonsID=".$billigaste[annonsid]."\">";
  578.         echo $billigaste[pris]." kr";
  579.         echo "</a>\n";
  580.         echo "\t</td>\n";
  581.  
  582.         echo "\t<td class=\"small\" width=\"20\">\n";
  583.         echo "\t\t<a href=\"index.php?annonsID=".$billigaste[annonsid]."\">";
  584.  
  585. //-------------Visa thumbs på framsidan-------------------//
  586.  
  587.         if($billigaste[bildnamn])
  588.  
  589.           {
  590.           echo "<img src=\"$billigaste[bildpath]\" border=\"1\" width=\"18\" height=\"18\">";
  591.           }
  592.         else
  593.           {
  594.           echo "&nbsp;\n";
  595.           }
  596.         echo "</a>\n";
  597.         echo "\t</td></tr>\n";
  598.         //echo "\t<tr>\n";
  599.         echo "\t<td width=\"340\" height=\"1\" colspan=\"4\" background=\"".$bgstreck570."\">\n";
  600.         echo "\t</td></tr>\n";
  601.         }
  602.  
  603.  
  604. //-- Tom cell-----------------------------------------------//
  605.       echo "\t<tr>\n";
  606.       echo "\t<td width=\"268\" height=\"40\" colspan=\"3\"\n";
  607.  
  608.       echo "\t</td></tr>\n";
  609.  
  610.  
  611.  
  612.       echo "\t<tr>\n";
  613.  
  614.  
  615.  
  616.     echo "</table>\n";
  617.     ?>
  618.     <?
  619.     echo "\t</td>";
  620.     echo "\t<td width=\"370\">\n";
  621.  
  622. //-- skriver ner antalet annonser --------------------------//
  623.     echo "<table width=\"360\" class=\"tabellram\" style=\"padding-top:0px\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\">\n";
  624.       echo "\t<tr>\n";
  625.       echo "\t<td width=\"360\" height=\"25\" align=\"center\" class=\"rubrik\" colspan=\"4\" background=\"".$bgrubrikbild."\" bgcolor=\"".$bgrubrik."\">".$rubriker [2]."\n";
  626.       echo "\t</td></tr>\n";
  627.       echo "\t<tr>\n";
  628.       echo "\t<td class=\"grabold\" width=\"180\" valign=\"top\">\n";
  629.       $i = 0;
  630.       foreach($cmbtyp as $namn)
  631.         {
  632.         if($i == 30)
  633.           {
  634.           echo "\t</td><td class=\"grabold\" width=\"180\" valign=\"top\">\n";
  635.           }
  636.         echo "\t\t<a href=\"index.php?visatyper=".$namn."\">".$namn." (<span class=\"rodbold\">";
  637.         echo mysql_num_rows(mysql_query("SELECT * FROM annonser WHERE typ = '".$namn."'"));
  638.         echo "</span>)</a><br>\n";
  639.         $i++;
  640.         }
  641.       echo "\t</td></tr>\n";
  642.     echo "</table>\n";
  643.  
  644.     ?>
  645.  
  646.   <tr>
  647.     <td><!-- Start of StatCounter Code -->
  648.  
  649. <!-- End of StatCounter Code -->
  650.  
  651.  
  652. </a></td></tr>
  653. <?
  654.     echo "\t</td></tr>\n";
  655.   echo "</table>\n";
  656.   }
  657.   echo "\t</td></tr>\n";
  658.  
  659. echo "</table>\n";
  660.  
  661. ?>
  662.  
Mar 31 '10 #10
Fynd
13
Atli I have posted a long explanation but I think someone had to review it first, hadn't time to read the note when posting.
Hope that works.

Best regards,

Morgan
Mar 31 '10 #11
Fynd
13
Think my latest post vanished into cyberspace..............:-)
I tried the loop for used_id above but still the output is as usual from var_dump($visa['bildpath']);

bildpath is then string(45) and this string contains 3 items with different paths.
string(45) "annonsbilder/20100331100815162.119.142.29.jpg"
string(45) "annonsbilder/20100331100815262.119.142.29.jpg"
string(45) "annonsbilder/20100331100815362.119.142.29.jpg"
So the trap for the id doesn't work as the id contains an image id that is unique in the same main id. If I could strip the string(45) into one? But I can not read only the first item from the string.
Thanks for helping out.

Best regards,
Morgan
Mar 31 '10 #12
Fynd
13
Anyone in for the issue? Or do you require more info?

Best regards,
Morgan
Apr 1 '10 #13
Markus
6,050 Expert 4TB
Is $visa['bildpath'] an array?
Apr 1 '10 #14
Fynd
13
Yes bildpath is an array caught from the sql query. If I follow the output from the query, it tells me that there's 3 images with the same id because there are 3 images on that id but I only want to display the first image of that id.
String(45) from above will be printed 3 times so the script actually is working as there are 3 writing in the same id. But the BIG question is how in *** do I print the first?

Explanation: in the query I connect the id with the db annonser with the id on the db annons_bilder but the images has got different names and path but yet connected to the same id.

Best regards,

Morgan
Apr 1 '10 #15
Markus
6,050 Expert 4TB
Right. Show me all of the output from this command: print_r($visa);
Apr 1 '10 #16
Fynd
13
Ok here's the lot, hope it will make any sense to you :-)
Array ( [0] => 271 [annonsid] => 271 [1] => 2010-03-31 [datum] => 2010-03-31 [2] => 20100331100815 [datumtid] => 20100331100815 [3] => Malmö kommun [lan] => Malmö kommun [4] => Affärsöverlåtelser [typ] => Affärsöverlåtelser [5] => Test igen [rubrik] => Test igen [6] => [stad] => [7] => 1 [pris] => 1 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => 271 [11] => IMG_0232.jpg [bildnamn] => IMG_0232.jpg [12] => annonsbilder/20100331100815162.119.142.29.jpg [bildpath] => annonsbilder/20100331100815162.119.142.29.jpg ) Array ( [0] => 271 [annonsid] => 271 [1] => 2010-03-31 [datum] => 2010-03-31 [2] => 20100331100815 [datumtid] => 20100331100815 [3] => Malmö kommun [lan] => Malmö kommun [4] => Affärsöverlåtelser [typ] => Affärsöverlåtelser [5] => Test igen [rubrik] => Test igen [6] => [stad] => [7] => 1 [pris] => 1 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => 271 [11] => IMG_0237.jpg [bildnamn] => IMG_0237.jpg [12] => annonsbilder/20100331100815262.119.142.29.jpg [bildpath] => annonsbilder/20100331100815262.119.142.29.jpg ) Array ( [0] => 271 [annonsid] => 271 [1] => 2010-03-31 [datum] => 2010-03-31 [2] => 20100331100815 [datumtid] => 20100331100815 [3] => Malmö kommun [lan] => Malmö kommun [4] => Affärsöverlåtelser [typ] => Affärsöverlåtelser [5] => Test igen [rubrik] => Test igen [6] => [stad] => [7] => 1 [pris] => 1 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => 271 [11] => IMG_0231.jpg [bildnamn] => IMG_0231.jpg [12] => annonsbilder/20100331100815362.119.142.29.jpg [bildpath] => annonsbilder/20100331100815362.119.142.29.jpg ) Array ( [0] => 270 [annonsid] => 270 [1] => 2010-03-30 [datum] => 2010-03-30 [2] => 20100330060044 [datumtid] => 20100330060044 [3] => Göteborgs kommun [lan] => Göteborgs kommun [4] => Affärsöverlåtelser [typ] => Affärsöverlåtelser [5] => Test 3 bilder [rubrik] => Test 3 bilder [6] => [stad] => [7] => 1 [pris] => 1 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => 270 [11] => IMG_0073.jpg [bildnamn] => IMG_0073.jpg [12] => annonsbilder/201003300702531217.210.81.146.jpg [bildpath] => annonsbilder/201003300702531217.210.81.146.jpg ) Array ( [0] => 270 [annonsid] => 270 [1] => 2010-03-30 [datum] => 2010-03-30 [2] => 20100330060044 [datumtid] => 20100330060044 [3] => Göteborgs kommun [lan] => Göteborgs kommun [4] => Affärsöverlåtelser [typ] => Affärsöverlåtelser [5] => Test 3 bilder [rubrik] => Test 3 bilder [6] => [stad] => [7] => 1 [pris] => 1 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => 270 [11] => IMG_0071.jpg [bildnamn] => IMG_0071.jpg [12] => annonsbilder/201003300658152217.210.81.146.jpg [bildpath] => annonsbilder/201003300658152217.210.81.146.jpg ) Array ( [0] => 270 [annonsid] => 270 [1] => 2010-03-30 [datum] => 2010-03-30 [2] => 20100330060044 [datumtid] => 20100330060044 [3] => Göteborgs kommun [lan] => Göteborgs kommun [4] => Affärsöverlåtelser [typ] => Affärsöverlåtelser [5] => Test 3 bilder [rubrik] => Test 3 bilder [6] => [stad] => [7] => 1 [pris] => 1 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => 270 [11] => IMG_0229.jpg [bildnamn] => IMG_0229.jpg [12] => annonsbilder/201003300829383217.210.81.146.jpg [bildpath] => annonsbilder/201003300829383217.210.81.146.jpg ) Array ( [0] => 259 [annonsid] => [1] => 2010-03-25 [datum] => 2010-03-25 [2] => 20100325173348 [datumtid] => 20100325173348 [3] => Örebro [lan] => Örebro [4] => Hobby [typ] => Hobby [5] => 17 olika darkkort [rubrik] => 17 olika darkkort [6] => [stad] => [7] => 99 [pris] => 99 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => [11] => [bildnamn] => [12] => [bildpath] => ) Array ( [0] => 258 [annonsid] => [1] => 2010-03-25 [datum] => 2010-03-25 [2] => 20100325172040 [datumtid] => 20100325172040 [3] => Örebro [lan] => Örebro [4] => Hobby [typ] => Hobby [5] => Shining Mewtwo Pokemonkort [rubrik] => Shining Mewtwo Pokemonkort [6] => [stad] => [7] => 299 [pris] => 299 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => [11] => [bildnamn] => [12] => [bildpath] => ) Array ( [0] => 257 [annonsid] => [1] => 2010-03-25 [datum] => 2010-03-25 [2] => 20100325171046 [datumtid] => 20100325171046 [3] => Örebro [lan] => Örebro [4] => Hobby [typ] => Hobby [5] => Lugia ex Pokemonkort [rubrik] => Lugia ex Pokemonkort [6] => [stad] => [7] => 99 [pris] => 99 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => [11] => [bildnamn] => [12] => [bildpath] => ) Array ( [0] => 255 [annonsid] => [1] => 2010-03-25 [datum] => 2010-03-25 [2] => 20100325140201 [datumtid] => 20100325140201 [3] => Västerbotten [lan] => Västerbotten [4] => Butikstillbehör [typ] => Butikstillbehör [5] => Gratulationskort [rubrik] => Gratulationskort [6] => [stad] => [7] => 600 [pris] => 600 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => [11] => [bildnamn] => [12] => [bildpath] => ) Array ( [0] => 250 [annonsid] => [1] => 2010-03-24 [datum] => 2010-03-24 [2] => 20100324074656 [datumtid] => 20100324074656 [3] => Örebro [lan] => Örebro [4] => Maskiner [typ] => Maskiner [5] => Minitraktor med plogblad [rubrik] => Minitraktor med plogblad [6] => [stad] => [7] => 10000 [pris] => 10000 [8] => [marke] => [9] => Köpes [kategori] => Köpes [10] => [11] => [bildnamn] => [12] => [bildpath] => ) Array ( [0] => 249 [annonsid] => [1] => 2010-03-23 [datum] => 2010-03-23 [2] => 20100323171018 [datumtid] => 20100323171018 [3] => Örebro [lan] => Örebro [4] => Prydnadssaker [typ] => Prydnadssaker [5] => Handmålad keramikvas [rubrik] => Handmålad keramikvas [6] => [stad] => [7] => 49 [pris] => 49 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => [11] => [bildnamn] => [12] => [bildpath] => ) Array ( [0] => 248 [annonsid] => [1] => 2010-03-23 [datum] => 2010-03-23 [2] => 20100323142446 [datumtid] => 20100323142446 [3] => Skåne [lan] => Skåne [4] => Maskiner [typ] => Maskiner [5] => Begagnad Oerlikon TIG [rubrik] => Begagnad Oerlikon TIG [6] => [stad] => [7] => 18700 [pris] => 18700 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => [11] => [bildnamn] => [12] => [bildpath] => ) Array ( [0] => 237 [annonsid] => [1] => 2010-03-20 [datum] => 2010-03-20 [2] => 20100320205341 [datumtid] => 20100320205341 [3] => Örebro [lan] => Örebro [4] => Motorsågar [typ] => Motorsågar [5] => Motorsåg Stihl köpes [rubrik] => Motorsåg Stihl köpes [6] => [stad] => [7] => 1200 [pris] => 1200 [8] => [marke] => [9] => Köpes [kategori] => Köpes [10] => [11] => [bildnamn] => [12] => [bildpath] => ) Array ( [0] => 236 [annonsid] => [1] => 2010-03-20 [datum] => 2010-03-20 [2] => 20100320110749 [datumtid] => 20100320110749 [3] => Örebro [lan] => Örebro [4] => Antikt [typ] => Antikt [5] => Antikt pottskåp [rubrik] => Antikt pottskåp [6] => [stad] => [7] => 500 [pris] => 500 [8] => [marke] => [9] => Säljes [kategori] => Säljes [10] => [11] => [bildnamn] => [12] => [bildpath] => )
Apr 1 '10 #17
Fynd
13
Hope it could shine a light on this but I could fetch the id from annonser_bilder for the different images but as they are connected to the same id from annonser I can not seperate them either. Tried the used_ids from above but can not make it to go further in the while loop from the query.
Thanks for helping out.

Best regards and happy easter.Morgan
Apr 2 '10 #18
Fynd
13
Sorry for double posting but if I use this:
Expand|Select|Wrap|Line Numbers
  1. WHERE
  2.                   a.kontrollerad = 'ja'  
  3.                 GROUP BY
  4.                   a.annonsid
  5.                 ORDER BY
  6.                   a.datumtid DESC
The loop works with showing one image per id but if I do it like this:
Expand|Select|Wrap|Line Numbers
  1. WHERE
  2.  
  3.                   a.kontrollerad = 'ja' 
  4.                 $sokord
  5.  
  6.                 LIMIT
  7.                 $offset, $antal_bilder
It will show 3 images per id. I can not attach GROUP BY and ORDER BY as the syntax will not handle the $sokord, which is a part of the search, so can anybody see if there's a way to attach $sokord in the first example?
Apr 2 '10 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: John | last post by:
Hello. If I want to set up my first database and start using it in Dreamweaver what do I need to do? The book I'm working on has a CD with the database on. It is telling me to put it in the...
19
by: Rodger | last post by:
Hi all, I am getting the following error. ***************************** Microsoft JET Database Engine error '80004005' 'O:\DATA\DSR\DSR_DATA.MDB' is not a valid path. Make sure that the...
2
by: david | last post by:
Hi, I have asp pages running from a MySQL database. I have placed a path in the required field (although not quite sure on the correct format). My asp page is just displaying the text path...
4
by: Claudio Grondi | last post by:
I need to unpack on a Windows 2000 machine some Wikipedia media .tar archives which are compressed with TAR 1.14 (support for long file names and maybe some other features) . It seems, that...
4
by: Bob | last post by:
Hi all, I've got a table that I've imported and it has junk at the top of the table, so after import I run a delete query to remove the junk lines then I'm left with the field names I want for...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
4
blossam
by: blossam | last post by:
hi friends i have install mysql in c drive i want to keep database in e:\ drive instad of "C:\Program Files\MySQL\MySQL Server 4.1\data" path is it possible? how?
0
by: Jacob Davis | last post by:
On Apr 3, 2008, at 10:54 AM, Trent Mick wrote: Thanks, that seems to have worked. I added "/usr/local/bin" to the PATH in the preferences Environment panel in Komodo. Then in preferences I...
1
by: HSXWillH | last post by:
I have an Access 2003 db that I've designed to run inventory for a sports memorabilia business. I'm realizing that I should get this data onto the web and run a storefront via MySQL & PHP. My...
2
by: whitep8 | last post by:
Hi All, The code at the bottom of this message is an example (1 of 3 i have tried) of trying to connect to a localhost mysql database. It wont, and the exception displayed is the one i have...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.