zero-perfoliate
zero-perfoliate

Author Topic: Passing more than one paramenter in funcion mysql_result()  (Read 346 times)

Offline CompStudent

  • New PHP Members
  • Posts: 3
  • Karma: +0/-0
Passing more than one paramenter in funcion mysql_result()
« on: November 07, 2010, 06:26:19 AM »
Hi, I am a beginner at this and I am creating a shopping website.  I want to display all my items, 3 per row going down the page, the code that i found is this:

$dbQuery="SELECT * from shoppingItems";
   
$display_columns = 3;

$result = mysql_query($dbQuery);
$count = mysql_numrows($result);
$dbRow=mysql_fetch_array($result);

$padding = ($display_columns-1)-(($count-1)%$display_columns);

echo '<table>';
// Let's begin our loop.
for($i=0; $i<$count; $i++)
{    // Whenever $i is a multiple of $display_columns (including 0),
    // it's a sign that we're hitting the start of a new row.
    if($i%$display_columns == 0)
        echo '<tr>';
    //Now for an item.
    echo '<td>';
    echo mysql_result($result,$i,'ID');  //Here is were I want to add in more fields, atm, only field 'ID' from my table is being displayed ???
    echo '</td>';
    //Whenever $i is one less than a multiple of $display_columns,
    // it's a sign that we're hitting the end of the current row.
    if($i%$display_columns == $display_columns-1)
        echo '</tr>';
}
if($padding!=0)
{    for($i=0;$i<$padding;$i++)
        echo '<td></td>';
    echo '</tr>';
}
echo '</table>';    
?> 
at line 'echo mysql_result($result,$i,'ID');' I tried writing in echo mysql_result($result,$i,('ID','description','price'));
but this just caused an error.
I believe that it should be able to pass more than one field name in this function but i do  not know how.  Can anyone help?
thanks

Offline CompStudent

  • New PHP Members
  • Posts: 3
  • Karma: +0/-0
Re: Passing more than one paramenter in funcion mysql_result()
« Reply #1 on: November 12, 2010, 02:42:50 PM »
Got it! so silly of me, I just added in more of the lines:
    echo '<tr>';
    //Now for an item.
    echo '<td>';
    echo mysql_result($result,$i,'name');
    echo "
";
    echo mysql_result($result,$i,'description');
    echo "
";
    echo mysql_result($result,$i,'price');
    echo "
";