Closed

PHP Code Help fix php code to update database

Posted Apr 15, 2021 4 bids 2,085 views Job #76000

Job details

The brief
I am new to php and spent hours trying to get some code to work, looking for someone to fix my code so that it works..I have the code below, I am trying to get it to show a random url in an iframe, which i have working...However, for the life of me, I cannot get it to update the associated row and deduct 1 credit.
So, this job is for $15 for someone to fix my code so that it pulls a random url from database and puts it in iframe, and then deducts 1 credit from the ID / row that it pulled the url from.

Below is the code I have...

[code]
 
<?php

include 'config.php'; ?>

<?php

$result = mysqli_query($conn,"SELECT id, url FROM oto_msites order by RAND() limit 1"); ?>

<?php

$i=0;

while($row = mysqli_fetch_array($result)) {

>

<?php

mysqli_query($conn,"UPDATE oto_msites SET credits = credits-1 WHERE id = echo .$id."); ?>



<main>

<iframe border="0" frameborder="0" height="100%" width="100%" id="banner" marginheight="0" marginwidth="0" scrolling="yes" src="<?php echo $row["url"]; ?>"></iframe>

</main>

<?php

$i++;

}

>

Requirements

Get the php code working so that it pulls random url from database to show in iframe and then deducts 1 credit from the id / row that it pulled url from.

Skills required

php

Attachments

Bids (4)

Average bid $11
Proposals stay private. Only the buyer and each bidder can see that bid's price and message.
Mohamed5550 Mohamed5550 Level 1 · Apr 15, 2021
Around average

Private proposal submitted

shamim1288 shamim1288 Level 1 · Apr 15, 2021
Around average

Private proposal submitted

IAMOFRUN IAMOFRUN Level 3 · Apr 15, 2021
Above average Over budget

Private proposal submitted

SEOConsultant92 SEOConsultant92 Level 1 · Apr 16, 2021
Around average

Private proposal submitted

Questions

Public, answered by the buyer
Budget Up to $10 / project
  • Delivery1 day
  • Seller level neededAny
  • Bids4
  • Average bid$11

About the buyer

nabennett
nabennett
Level 1 · Offline ·
  • Orders placed34
  • Ratings0
  • Response9 hours
  • JoinedOct 29 2016