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..... 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 | +--------+ +----------+ 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??? Link to comment https://forums.phpfreaks.com/topic/289192-need-help-in-mysql/#findComment-1482828 Share on other sites More sharing options...
cyberRobot Posted June 18, 2014 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 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.... Link to comment https://forums.phpfreaks.com/topic/289192-need-help-in-mysql/#findComment-1482852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.