Hello,
I am trying to random selection from my database. Suppose i have 1000 posts but i want to select last 20 posts and from those 20 posts ORDER BY postTime i will select 4 posts from that 20 posts and echo them.
But i am able to echo those 20 posts but i am unable to echo only 4 posts from those 20 posts randomly. If you know then please help me.
Thanks in advance
Agreed but I tend to help with the OP issue, not preach. There are plenty who will. If I were, I would suggest PDO.
[quote=“anturj, post:4, topic:111061”]
This is working but you closed the while so how i can fetch data from the while ? When that is closed.
[/quote]You are building $data array with the rows in the WHILE. As the comment in code shows you use data then key then field name to grab data.
$data[$key]['id']
$data[$key]['name']
etc.
[quote=“anturj, post:5, topic:111061”]
Ya it will be. I will convert it but before that i am working on it now.
[/quote]It is much easier to learn for example PDO and write your code this way then to convert a bunch of code. I’ve done a few conversion projects and they’re a pain. Much easier to write it correctly in the first place.