Posts

Showing posts with the label MYsql

Get random records from mysql

Get random records from mysql. To get randon records for current day and for current year using by order by rand() function. <?php //Connect To database $Con=mysqli_connect("127.0.0.1","root","pinturp1","contribu_yummy"); //To get randon records $SQL="SELECT keyword FROM `contribu_yummy`.`keywords` ORDER BY RAND() LIMIT 5"; $Result = mysqli_query($Con,$SQL); while($row = mysqli_fetch_array($Result)) {   echo $row['keyword'];   echo "<br>"; } //To get randon record for current day $SQL="SELECT keyword FROM `contribu_yummy`.`keywords` ORDER BY RAND(".date('Ymd').") LIMIT 5"; $Result = mysqli_query($Con,$SQL); while($row = mysqli_fetch_array($Result)) {   echo $row['keyword'];   echo "<br>"; } //To get randon record for current month $SQL="SELECT keyword FROM `contribu_yummy`.`keywords` ORDER BY RAND(".date('Ym')....

Using same query again inside while loop in PHP

 Using same query again inside while loop in PHP  The mysqli_data_seek() function adjusts the result pointer to an arbitrary row in the result-set. <?php     $con = mysqli_connect('127.0.0.1','root','pinturp1','test');     $sql = "Select * from test.keywords limit 20";     $resultQuery = mysqli_query($con,$sql);     while($queryrow = mysqli_fetch_array($resultQuery))     {         echo $queryrow['keyword']."<br>";     }         echo "<br>-------------------------------------------<br>";     mysqli_data_seek($resultQuery, 0);     while($queryrow = mysqli_fetch_array($resultQuery))     {         echo $queryrow['keyword']."<br>";     }         echo "<br>--------------------------...

Write and read txt file and insert into database with coldfusion

Write and read txt file and insert into database with coldfusion, mysql and SQL Server <cfoutput>     <cfset HTTPUploadPath = "C:\ColdFusion10\cfusion\wwwroot\pintu\uploads\">     <cfset inpFileName = "test.txt">     <!---******** Start: text File Write Session ***************--->         <cfparam name="fileExists" default="Yes">     <!--- Get unique file name --->     <cfset FileCounter = 0>     <cfloop condition='fileExists eq "yes"'>         <cfif FileExists("#HTTPUploadPath##inpFileName#") is "Yes">             <cfset FileCounter = FileCounter + 1>             <cfset fileExists="yes">             <cfset inpFileName = "test#FileCounte...

Change sequence no of multiple options field values using Javascript and mysql using coldfusion

Change sequence no of multiple options field values using Javascript and update database field values using coldfusion I hope this is usefull for new programmers.