Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2005
    Thanked 0 Times in 0 Posts

    How to avoid redundant results


    I have a php script that fetches a unique record from master table and sends it to the webpage.(I have javascript on the page to perform autorefresh)

    If i open multiple webpages and run the script. Instead of getting unique record each time i get the record repeated. I i go to the id siiued table i get two or more tickets with same id number.

    Please tell me how can i avoide it.

    Below is the code.

    PHP Code:
    ="localhost";    // PARAMETERS OF THE DB

    mysql_pconnect($db_host,$db_user,$db_pass) or die("Unable to connect to database");
    mysql_select_db($database) or die( "Unable to select database");
    $row=mysql_query("SELECT * FROM t_master")or die (mysql_error());
    mysql_query("delete from t_master where ticketid=$id");
    $song1 $result['songno1'];
    $song2 $result['songno2'];
    $song3 $result['songno3'];
    $song4 $result['songno4'];
    $song5 $result['songno5'];
    $songno_1 $result['songno_1'];

    $songno_2 $result['songno_2'];
    $songno_3 $result['songno_3'];
    $songno_4 $result['songno_4'];
    $songno_5 $result['songno_5'];
    $row=mysql_query("SELECT * FROM lookup_new where songno=$song1")or die (mysql_error());
    $songname1 $song1;
    $song1name substr($songname1,0,28); 

    $row=mysql_query("SELECT * FROM songs_lookup_new where songno=$song2")or die (mysql_error());
    $songname2 $song2;
    $song2name substr($songname2,0,28);
    $row=mysql_query("SELECT * FROM songs_lookup_new where songno=$song3")or die (mysql_error());
    $songname3 $song3;
    $song3name substr($songname3,0,28);
    //echo $song3movie;    
    $row=mysql_query("SELECT * FROM songs_lookup_new where songno=$song4")or die (mysql_error());
    $songname4 $song4;
    $song4name substr($songname4,0,28);
    $row=mysql_query("SELECT * FROM songs_lookup_new where songno=$song5")or die (mysql_error());
    $songname5 $song5;
    $song5name substr($songname5,0,28);

    //for sms test
    $messageid $_GET['MSGID']; 
    $message $_GET['MSG']; 
    $email '-NA-';
    $username '-NA-';
    $sex 'not required';
    $smstime $_GET['TIME'];
    $language $_GET['DC'];

    $query "INSERT INTO sms_test
        ) VALUES(
    mysql_query($query) or die('Error, insert query failed:'.mysql_error());
    $query "INSERT INTO t_issued 
        ) VALUES(
    mysql_query($query) or die('Error, insert query failed:'.mysql_error());
    //Return the user to the location page
    echo "<HTML><head><script type=\"text/JavaScript\">function timedRefresh(timeoutPeriod){setTimeout(\"location.reload(true);\",timeoutPeriod)};</script><body onload=\"JavaScript:timedRefresh(1000);\"><STATUS></STATUS><DETAILS></DETAILS><REPLYSMS>Ticket#$id. $songno1)$song1name $songno2)$song2name $songno3)$song3name $songno4)$song4name $songno5)$song5name</REPLYSMS><LANG></LANG></body></head></HTML>";

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Thanked 79 Times in 77 Posts
    if you want the songs to be random, you need to add the mysql RAND() function.

  • #3
    New Coder
    Join Date
    Nov 2005
    Thanked 0 Times in 0 Posts
    No, I am only generating the mobile number randomly for simulation.

    But the ticket ID and the song combinations are already avilable in the DB.

    the php script just moves it from master table to issued table and deletes the record in the master table.

    If there are multiple access at the same time two or more people will get the same record and if i check the issued table there will be duplicate ticket ids i dont want this to happen i want unique ticket from the master.At the end all the records from master table will be availabe in issued table and the number shoild match i mean to say if there are 10 records in the master table at the end of execution of the script master will have 0 records and issued sould have 10 records even if multiple users access the same page at the same time.

  • #4
    New Coder
    Join Date
    Nov 2005
    Thanked 0 Times in 0 Posts

    Picking the records in sequence

    I have the records arranged in a preditermined sequence.i want to fetch it in that order itself and insert that record to issued table along with two other fields ( the moble number to whom it is sent to and the time it was sent )and finally delete that record from master after it is fetched.

    It works fine.The only problem is if more than one person/webpages acesses the page at the same time there are chances that the same record/data gets issued to two mobile numbers so that should not happen every time it has to pick unique record.

    Is there anyway i can tweak the code to make it happen?


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts