subhomoy Posted June 18, 2014 Share Posted June 18, 2014 hello every one I have some queries in mysql command.. I have a table schema like this id | name | url | img1 | img2 | img3 | img4| I want to randomly rotate the image by specific id.... suppose the select the id = 1, then the four images will be rotated randomly for with the tha id (i.e id = 1) Any help wil greatly appreciated Thank u..... Quote Link to comment https://forums.phpfreaks.com/topic/289192-need-help-in-mysql/ Share on other sites More sharing options...
Barand Posted June 18, 2014 Share Posted June 18, 2014 Then normalize the table data +--------+ +----------+ | Table1 | | image | +--------+ +----------+ | id PK|---------<| T1_id PK| | name | | img_no PK| | url | | img | +--------+ +----------+ Quote Link to comment https://forums.phpfreaks.com/topic/289192-need-help-in-mysql/#findComment-1482820 Share on other sites More sharing options...
subhomoy Posted June 18, 2014 Author Share Posted June 18, 2014 @Barand Thanks for the reply... Actually i dont want to normalize the table.... Is there any possible ways i can go with it??? Quote Link to comment https://forums.phpfreaks.com/topic/289192-need-help-in-mysql/#findComment-1482828 Share on other sites More sharing options...
Solution cyberRobot Posted June 18, 2014 Solution Share Posted June 18, 2014 suppose the select the id = 1, then the four images will be rotated randomly for with the tha id (i.e id = 1) Are you looking to randomly choose one of the images to display? If so, you could load the four images into a PHP array and then use array_rand() to pick the random image. http://www.php.net/array-rand Quote Link to comment https://forums.phpfreaks.com/topic/289192-need-help-in-mysql/#findComment-1482830 Share on other sites More sharing options...
subhomoy Posted June 18, 2014 Author Share Posted June 18, 2014 Thank u for the help... Really appreciated.... Quote Link to comment https://forums.phpfreaks.com/topic/289192-need-help-in-mysql/#findComment-1482852 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.