Php function to get data from mysql.

En curso Publicado hace 7 años Pagado a la entrega
En curso Pagado a la entrega

Using php get 10 values from a mysql table with a select and if the 10 values are not obtained then the function must get the rest of the values needed for the 10 under another select.

The following function must be modified to get the $array.

private function getTagArray($idChannel){

$array = array();

$sql = "SELECT idTagPhoto FROM ((SELECT idTagPhoto FROM ((SELECT idTagPhoto,votes FROM tagphotos_view WHERE (idChannel = $idChannel) ORDER BY idTagPhoto DESC limit 500) as tagphotos_view3) ORDER BY votes DESC limit 100) as tagphotos_view2) GROUP BY idTagPhoto ORDER BY RAND() LIMIT 10";

$result = mysqli_query($this->db, $sql);

$rows = mysqli_num_rows($result);

while($row = $result->fetch_assoc()){

array_push($array, $row["idTagPhoto"]);

}

return $array;

}

}

The "SELECT" of my code must be respected to get the same result, but the function must be modified so that if the select does not reach 10 data, for example if this select only obtains 7 data, the other 3 data must obtain them in another way:

"SELECT idTagPhoto FROM tagphotos_view WHERE (idChannel = 1) LIMIT 3"

I will try the code on my computer to see if it works.

MySQL PHP Arquitectura de software

Nº del proyecto: #12711134

Sobre el proyecto

21 propuestas Proyecto remoto Activo hace 7 años

21 freelancers están ofertando un promedio de $26 por este trabajo

Nawaz091993

Greetings! I am an expert PHP programmer and I have just seen your project description. I can complete this function modification within an hour max. Looking forward to hear from you.

$25 USD en 0 días
(128 comentarios)
6.9
shihan033010

A proposal has not yet been provided

$20 USD en 1 día
(328 comentarios)
6.9
webarox

Hello Greetings of the day!!! I’ve carefully gone through your job posting. I am having 5+ years of experience in Word press, Shopify, HTML and PHP. I have designed many e-commerce and woo-commerce websites in last Más

$30 USD en 1 día
(65 comentarios)
5.9
testotorko

Hi, I read carefully your project, and I wanna do it for you. If you wanna work together, send me a message to discuss details. I am an experienced Web Developer and Web Designer, and have worked with wide variety of s Más

$15 USD en 1 día
(104 comentarios)
5.7
DevvTime

Hello there i am a professional and have extensive experience, please contact to discuss in details.. i will be waiting thanks regards

$30 USD en 2 días
(28 comentarios)
5.3
carlamorillo2

Hi, hope you're fine. This is an easy task, should be something very quick. I'm a web developer and database admin. If you agree, I would suggest to use the same query with an "UNION" clause to merge the record fro Más

$15 USD en 1 día
(9 comentarios)
3.8
doublizer

Hello there. This looks like a simple task and I should be able to deliver it quickly. We can discuss more details over chat if you're interested. Thanks in advance. Best regards, Diogo Bragança

$30 USD en 1 día
(14 comentarios)
3.4
Hassan1859

Hey, I had a chance to go through your complete job description. And we think this is the best project matching with our skills. I would like to have a verbal conversation with you to walk through your web developmen Más

$25 USD en 1 día
(2 comentarios)
2.4
freegraph

from my profile you already see that I'm a motiongraphic artist. also by reviews u see how i work and that im professional what also means Im responsible for my work. right now Im trying to move back to programming ( Más

$25 USD en 3 días
(0 comentarios)
0.0