i am trying to loop rows from my database but i want to loop the first three rows and place an ad on the fouth row then i continue with my main loop.Aany help will be helpful. Thank you
SirMahlon 0 Junior Poster in Training
Recommended Answers
Jump to PostSo just keep row count in a variable, and use that to determine when to insert your ad.
Jump to PostShow your code, the part that loops your results.
Jump to Post$rowCount = 0; while ($row = mysql_fetch_array($result)) { $rowCount++; $id = $row['sale_property_id']; // etc. echo ' <div class="row"> // etc. '; if ($rowCount == 3) { echo 'YOUR AD HERE'; } }
Jump to Post@ihelpyou
if he wants to repeat the process for every 3 records.
That assumption wasn't clear from the OP, so I left it out on purpose.
Jump to PostCan you explain? It is not clear what your problem is.
All 18 Replies
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
SirMahlon 0 Junior Poster in Training
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
SirMahlon 0 Junior Poster in Training
SirMahlon 0 Junior Poster in Training
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
ihelpyou 0 Newbie Poster
SirMahlon 0 Junior Poster in Training
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
SirMahlon 0 Junior Poster in Training
SirMahlon 0 Junior Poster in Training
pritaeas 2,211 ¯\_(ツ)_/¯ Moderator Featured Poster
SirMahlon 0 Junior Poster in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
SirMahlon 0 Junior Poster in Training

diafol
SirMahlon 0 Junior Poster in Training
SirMahlon 0 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.