duangan6797 2016-06-16 15:09
浏览 45

获取小于给定id的所有mysql结果

i am working on a timeline for my website but i am having some problem when i ran the query to select all id that is less than given identifier its still return the identifier result upon every query example if identifier is id=4 i want to select everything less than 4 and not from 4 > 3 > 2 > 1 i want it to be 3 > 2 > 1

here is my php. i know its not secure or what not but i have written it in prepared statement and get the same thign so i need some here.

if(isSet($_POST['lastmsg']))
{
    $feed_id = mysqli_real_escape_string($con, $_POST['lastmsg']);
    $get1 = mysqli_query($con, 'SELECT receiver FROM connection where sender="'.$_SESSION['userid'].'"');
    $id_feed = array();
    while($id_result1 = mysqli_fetch_array($get1)){
    $id_feed[] = $id_result1['receiver'];
    $ids1 = join(',', $id_feed); 
    $get_feed1 = mysqli_query ($con, "select * from feed where users in '".$ids1."' or users='".$_SESSION['userid']."' and 'feed_id' < '".$feed_id."'  ORDER BY feed_id DESC LIMIT 2");

    }

    while($res1 = mysqli_fetch_array($get_feed1)){ 
    echo $load = $res1['feed_id'];


    }

    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害