SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Echo MySQLi Inside HTML (Join Function)

    Hi,

    I have (some how) managed to build a MySQLi join query. However I cant figure out how to echo the resuls inside HTML.

    I have echoed $long_name and $name here

    Code:
    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    
    
    $room = mysql_real_escape_string($_GET['room']);
    
    echo $room; 
    
    $query = "SELECT long_name, name
    									FROM furniture_groups a
    									INNER JOIN productdbase b
    									ON a.id = b.product_id
    									WHERE `room` = '$room'  LIMIT 15
    									";	 	 
    								
    					if ($result = $mysqli->query($query)) {
    					
     while ($row = $result->fetch_assoc()) {
            printf ("%s (%s)\n", $row["long_name"], $row["name"]);
        	
    
    
        ?>
    But I would to echo it here inside the HTML.

    Code:
    <div class="productrangeborder">
    <div class="productsdetailsborder">
    <a href="http://domain.co.uk/products/product/<?php echo $query_row['long_name']; ?>" class='productlink' rel="nofollow" ><?php echo $query_row['name']; ?>
    </a>
    </div>
    
    </div></div>
    
    <?php
    
    }
    }
    
    ?>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    88
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    wrap your html inside of the while loop and leave out the php part where you have the while and printf lines.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •