DisplayError Posted May 2, 2021 Share Posted May 2, 2021 Example Code: $sql=$baglan->prepare("SELECT * FROM img where id='$getx') and if (FirstImage==1 echo FirstImage=1 ; else FirstImage==0 echo FirstImage=0 ) "); // AS ETC. $sql->execute(); $rs = $sql->fetch(); if FirstImage=1 is absent, continue with FirstImage=0 Thanks for your idea and effort. Quote Link to comment https://forums.phpfreaks.com/topic/312587-using-if-in-the-select-data-code/ Share on other sites More sharing options...
Barand Posted May 2, 2021 Share Posted May 2, 2021 Can you tell us what you are trying to achieve? It's impossible to tell from that hotchpotch of code. Quote Link to comment https://forums.phpfreaks.com/topic/312587-using-if-in-the-select-data-code/#findComment-1586282 Share on other sites More sharing options...
DisplayError Posted May 2, 2021 Author Share Posted May 2, 2021 where id = '$ getx') and FirstImage =1 FirstImage=0 If there is no 1, the ones with 0 should be listed Quote Link to comment https://forums.phpfreaks.com/topic/312587-using-if-in-the-select-data-code/#findComment-1586287 Share on other sites More sharing options...
dodgeitorelse3 Posted May 2, 2021 Share Posted May 2, 2021 I think you are going to want to run your if/else statement on your results instead of in your query. Quote Link to comment https://forums.phpfreaks.com/topic/312587-using-if-in-the-select-data-code/#findComment-1586288 Share on other sites More sharing options...
Barand Posted May 2, 2021 Share Posted May 2, 2021 WHERE id = ? AND FirstImage IN (0,1) 1 Quote Link to comment https://forums.phpfreaks.com/topic/312587-using-if-in-the-select-data-code/#findComment-1586290 Share on other sites More sharing options...
DisplayError Posted May 2, 2021 Author Share Posted May 2, 2021 WHERE id = ? AND FirstImage IN (0,1) order by FirstImage desc view selected picture first - if not view other pictures. i thank all my friends who help. with love... Quote Link to comment https://forums.phpfreaks.com/topic/312587-using-if-in-the-select-data-code/#findComment-1586291 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.