lingo5 Posted March 22, 2013 Share Posted March 22, 2013 hi, I have a table for my products: id_producto id_familia id_subfamilia id_marca producto_titulo_esp producto_desc_esp producto_precio producto_precio_oferta producto_novedad producto_visible producto_imagen_principal and I have a table where I store product brands (marcas): id_marca marca_title_esp marca_image as you can see they both share the id_marca field. I query the db to get products of a given sub_familia like so: $colname_subcategorias_RS = "-1"; if (isset($_GET['id_subfamilia'])) { $colname_subcategorias_RS = $_GET['id_subfamilia']; } mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_subcategorias_RS = sprintf("SELECT * FROM t_productos WHERE id_subfamilia = %s AND producto_visible=1", GetSQLValueString($colname_subcategorias_RS, "int")); $query_limit_subcategorias_RS = sprintf("%s LIMIT %d, %d", $query_subcategorias_RS, $startRow_subcategorias_RS, $maxRows_subcategorias_RS); $subcategorias_RS = mysql_query($query_limit_subcategorias_RS, $MySQLconnect) or die(mysql_error()); $row_subcategorias_RS = mysql_fetch_assoc($subcategorias_RS); this works fine, but what I need to do is to get the corresponding marca_title_esp from the table t_marcas ....how do I modify my query to do that??? Thanks a lot. Link to comment https://forums.phpfreaks.com/topic/276028-please-help-with-query/ Share on other sites More sharing options...
Barand Posted March 22, 2013 Share Posted March 22, 2013 SELECT t_productos.*, marcas.marca_title_esp FROM t_productos INNER JOIN marcas USING (id_marca) WHERE id_subfamilia = %s AND producto_visible=1 Link to comment https://forums.phpfreaks.com/topic/276028-please-help-with-query/#findComment-1420369 Share on other sites More sharing options...
lingo5 Posted March 22, 2013 Author Share Posted March 22, 2013 Thanks a lot Barand , but I am getting the same brand (marca) for all the records? this is my query now $colname_subcategorias_RS = "-1"; if (isset($_GET['id_subfamilia'])) { $colname_subcategorias_RS = $_GET['id_subfamilia']; } mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_subcategorias_RS = sprintf("SELECT t_productos.*, t_marcas.marca_title_esp FROM t_productos INNER JOIN t_marcas USING (id_marca) WHERE id_subfamilia = %s AND producto_visible=1", GetSQLValueString($colname_subcategorias_RS, "int")); $query_limit_subcategorias_RS = sprintf("%s LIMIT %d, %d", $query_subcategorias_RS, $startRow_subcategorias_RS, $maxRows_subcategorias_RS); $subcategorias_RS = mysql_query($query_limit_subcategorias_RS, $MySQLconnect) or die(mysql_error()); $row_subcategorias_RS = mysql_fetch_assoc($subcategorias_RS); Link to comment https://forums.phpfreaks.com/topic/276028-please-help-with-query/#findComment-1420373 Share on other sites More sharing options...
lingo5 Posted March 22, 2013 Author Share Posted March 22, 2013 Sorry Barand it wiorks....I had a typo. Many many many thanks for our help Link to comment https://forums.phpfreaks.com/topic/276028-please-help-with-query/#findComment-1420381 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.