Jump to content

Obtain MySQL different results


Julian

Recommended Posts

Hi Guys
  I have this query:

$colname_prices = "1";
if (isset($_GET['id_sub'])) {
  $colname_prices = (get_magic_quotes_gpc()) ? $_GET['id_sub'] : addslashes($_GET['id_sub']);
}
mysql_select_db($database_bb, $bb);
$query_prices = sprintf("SELECT * FROM prices WHERE id_sub = %s", $colname_prices);
$prices = mysql_query($query_prices, $bb) or die(mysql_error());
$row_prices = mysql_fetch_assoc($prices);
$totalRows_prices = mysql_num_rows($prices);

  When I call results from this query I do this:  <?php echo $row_prices['price']; ?>

  Here's my problem:  id_sub can be associated several times to the same id number(e.g. 4).  What changes is the price column.

  I want to retrieve the price info in different parts of the page (e.g. Price 1: xxxx, then Price 2: xxxx).

  But when call the DB it show me only the first record.

  Any help will be appreciated.  Thanks
Link to comment
https://forums.phpfreaks.com/topic/27264-obtain-mysql-different-results/
Share on other sites

The problem is that I have the same field.  Here's the database:

| id_prices  |  id_sub  |  rate_type  | rates_from  |
|    1        |      4    |      1        |      500      |
|    2        |      4    |      2        |      540      |
|    3        |      4    |      3        |      600      |

I want to retrieve all the rows from  "rates_from" when id_sub =4

In different parts of the page.  Like on the top rate_type 1, on the bottom rate_type 3....

Thanks again

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.