MySQLi to MySQL

Status
Not open for further replies.

randrab33

Member
Sep 17, 2017
38
1
I've got a bunch of MySQLi code, can someone transfer these lines to mysql so I can learn to do the rest

Code:
$GetRooms = $engine->query("SELECT `users_now`,`caption` FROM `rooms` WHERE `users_now` > 0 ORDER BY `users_now` DESC LIMIT 10");
 $odd = false;
 while ($Room = $GetRooms->fetch_object()) {

    $bgColor = $Room->users_now >= 20 ? "#C1322B" : $Room->users_now >= 10 ? "#ffb01a" : "#62b061";
 echo '
    
<div style="padding:0 8px 0 6px">
<div class="navi-box '. (++$count%2 ? "odd" : "even") .'">
<div class="users-now" style="background-color: '.$bgColor.'">
<font class="users-number"><center><b>'.filter($Room->users_now).'</b></center></font></div><div class="room-name">'.filter($Room->caption).'
Thanks
 

Menkz

Member
Jul 9, 2010
374
167
Not sure why you'd want to go from MySQLi to MySQL.
MySQL was officially deprecated in PHP v5.5.0 and completely removed in PHP v7.
 
  • Like
Reactions: Joe

Menkz

Member
Jul 9, 2010
374
167
Nothing about it looks like mysqli - Try changing
PHP:
$engine->query(
to
PHP:
mysql_query(

No idea if this will work, I've not used MySQL in a while.
 

randrab33

Member
Sep 17, 2017
38
1
Hey it is mysqli, but I've translated over the first 2 lines, just need this bit now

Code:
$odd = false;
 while ($Room = $GetRooms->fetch_object()) {

    $bgColor = $Room->users_now >= 20 ? "#C1322B" : $Room->users_now >= 10 ? "#ffb01a" : "#62b061";
 echo '
    
<div style="padding:0 8px 0 6px">
<div class="navi-box '. (++$count%2 ? "odd" : "even") .'">
<div class="users-now" style="background-color: '.$bgColor.'">
<font class="users-number"><center><b>'.filter($Room->users_now).'</b></center></font></div><div class="room-name">'.filter($Room->caption).'
 

distributi0n

New Member
Jul 22, 2017
11
5
I would rather re-write a whole CMS to use MySQLi than use MySQL, but I guess you have your reasons.

If you post all of the code I'll translate it for you, I need to know what GetRooms actually is, and the command text for that object.
 
Last edited:

randrab33

Member
Sep 17, 2017
38
1
Hey,
Here's all the code
<div id="column1" class="column">

<link rel='stylesheet' href=' '>
<style>.users-now{background-repeat:no-repeat;background-position:center left;background-image:url(' }.navi-box{width:98%;height:23px;padding:2px;display:-webkit-box;border-radius:4px;}.even{background-color:#d5edff;}.odd{background-color:#ffffff;}.users-number{font-family:'Ubuntu';margin-top:4px;margin-left:30px;position:absolute;color:white;font-size:14px;}.room-name{font-size:15px;font-family:'Ubuntu';height:23px;margin-top:2px;margin-left:4px;}</style>
<div class="habblet-container ">
<div class="cbb clearfix red">

<?php
$GetRooms = $engine->query("SELECT `users_now`,`caption` FROM `rooms` WHERE `users_now` > 0 ORDER BY `users_now` DESC LIMIT 10");
$odd = false;
while ($Room = $GetRooms->fetch_object()) {

$bgColor = $Room->users_now >= 20 ? "#C1322B" : $Room->users_now >= 10 ? "#ffb01a" : "#62b061";
echo '

<div style="padding:0 8px 0 6px">
<div class="navi-box '. (++$count%2 ? "odd" : "even") .'">
<div class="users-now" style="background-color: '.$bgColor.'">
<font class="users-number"><center><b>'.filter($Room->users_now).'</b></center></font></div><div class="room-name">'.filter($Room->caption).'

</div></div></div>';
}
?>
</div>
</div>
</div>

<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>


<br /><br>
<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>

I got given this code by @Westyy but I just need to make it compatible with my cms with is in mysql
I use rev

Thanks
@distributi0n
 

Brad

Well-Known Member
Jun 5, 2012
2,320
993
haven't touched MySQL in time. So try this.
PHP:
$GetRooms = mysql_query("SELECT `users_now`,`caption` FROM `rooms` WHERE `users_now` > 0 ORDER BY `users_now` DESC LIMIT 10");
 $odd = false;
 while ($Room = mysql_fetch_assoc($GetRooms)) {

    $bgColor = $Room['users_now'] >= 20 ? "#C1322B" : $Room['users_now'] >= 10 ? "#ffb01a" : "#62b061";
 echo '
    
<div style="padding:0 8px 0 6px">
<div class="navi-box '. (++$count%2 ? "odd" : "even") .'">
<div class="users-now" style="background-color: '.$bgColor.'">
<font class="users-number"><center><b>'.filter($Room['users_now']).'</b></center></font></div><div class="room-name">'.filter($Room['caption']).'
 

randrab33

Member
Sep 17, 2017
38
1
Hey!
Didn't seem to work at all, it didn't kill the page, but where it should show the rooms it was just white.

Thanks
@Westyy

EDIT: Works now, didn't implement correctly. Thanks!
 
  • Like
Reactions: Kak
Status
Not open for further replies.

Users who are viewing this thread

Top