Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with one MySQL query

Status
Not open for further replies.

Mury

Programmer
Nov 15, 2002
3
BG
Hello again,
Now I have different problem, which I cannot solve.
Here is the problematik source cod :
<?php
$lst1 = mysql_query(&quot;SELECT id, brand, vid FROM table1 WHERE vid = 'rdtelpl' GROUP BY brand&quot;, $dbh);
while(list($id, $brand, $vid) = mysql_fetch_row($lst1)) {
echo &quot;<tr><td>$brand</td><td>$brand</td><td>$brand</td></tr>&quot;;
echo &quot;\n&quot;;
}
?>
The result from this query is that it repeats the one value of $brand 3 times by one row, and the next value of $brand gives me on the second row again 3 times for each cell.
I do not want this to happen, I want the result from this query to be on one row to give me 3 different values from $brand and if there are more values to give me one the second, third etc. row.
What should I change in this script to work properly??? Should I do something with ID or to use some king of an array to keep the results from the query.
Thank you in advance.
 
<?php
$lst1 = mysql_query(&quot;SELECT id, brand, vid FROM table1 WHERE vid = 'rdtelpl' GROUP BY brand&quot;, $dbh);
while($myrow = mysql_fetch_array($lst1)) {
printf(&quot;<tr><td>%</td><td>%</td><td>%</td></tr>\n&quot;,$myrow[0],$myrow[1],$myrow[2]);

}
?> ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top