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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.