Jump to content

MySQLi Select Statement


EPUKBen

Recommended Posts

Hi All, I have the following Query:

 

$query = 'SELECT `BookingID`,`OfferID`, `name`, `OfferCount`,`OfferPrice` FROM `Offers_Finance` JOIN offers_details ON `OfferID` =  `o_d_id` WHERE `BookingID` ="' .$bookerid. '"';
if ( !$result = $mysqli->query( $query ) ) { die( $mysqli->error ); } 
$field = $result->fetch_object();

 

This will return anywhere between 0 and 50 Rows of Data.  For Each Row returned, I want to do the following:

 

        echo '<tr>';

echo '<td>' . $field->name.'</td>';

echo '<td></td>';

echo '<td>£' . $field->OfferPrice.'</td>';

echo '<td></td>';

echo '<td>' . $field->OfferCount . '</td>';

echo '<td></td>';

echo '<td>£' . $field->OfferPrice * $field->OfferCount . '</td>';

echo '</td>';

echo '</tr>';

 

The problem I have is - how do I loop through the results returned from the query to output multiple rows?

 

Sorry if this doesn't make much snese, I'm new to PHP and the whole web development world, but have been landed with finishing a project someone else started!

 

If someone would be kind enough to turn this into a working example, it would help no end as I have about 20 of these things to figure out across the project!

Link to comment
https://forums.phpfreaks.com/topic/250760-mysqli-select-statement/
Share on other sites

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.