Jump to content

Is there a better way to write this php / mysql script?

Recommended Posts

Is this code correct. If there's an errors or a better way of writting this can you please say?

    $photos = Array();

    $result = mysqli_query($connection,"SELECT * FROM member WHERE uniqueIdentifier = '".$_POST['deviceID']."' AND currentDate = '".$_POST['matchDate']."'");
    while($row = mysqli_fetch_array($result))
        $media[$row["id"]]['cameraPicture'] = $row["cameraPicture"];
        $media[$row["id"]]['photoAlbum'] = $row["photoAlbum"];
        $media[$row["id"]]['videoData'] = $row["videoData"];
        $media[$row["id"]]['audioData'] = $row["audioData"];
        $media[$row["id"]]['textMessage'] = $row["textMessage"];
        $media[$row["id"]]['callData'] = $row["callData"];
        $media[$row["id"]]['activityData'] = $row["activityData"];
        $media[$row["id"]]['latitudePos'] = $row["latitudePos"];
        $media[$row["id"]]['longitudePos'] = $row["longitudePos"];
        $media[$row["id"]]['currentDate'] = $row["currentDate"];
        $media[$row["id"]]['currentTime'] = $row["currentTime"];

    $result2 = mysqli_query($connection,"SELECT * FROM member WHERE
      uniqueIdentifier != '".$_POST['deviceID']."' AND currentDate = '".$_POST['matchDate']."'
      OR latitudePos BETWEEN '".$_POST['latMin']."' AND '".$_POST['latMax']."'
      AND longitudePos BETWEEN '".$_POST['longMin']."' AND '".$_POST['longMax']."'");

    while($row2 = mysqli_fetch_array($result2))
        $media[$row["id"]]['associated'][] = Array('cameraPicture' => $row2["cameraPicture"]);
        $media[$row["id"]]['associated'][] = Array('photoAlbum' => $row2["photoAlbum"]);
        $media[$row["id"]]['associated'][] = Array('videoData' => $row2["videoData"]);
        $media[$row["id"]]['associated'][] = Array('audioData' => $row2["audioData"]);
        $media[$row["id"]]['associated'][] = Array('textMessage' => $row2["textMessage"]);
        $media[$row["id"]]['associated'][] = Array('callData' => $row2["callData"]);
        $media[$row["id"]]['associated'][] = Array('activityData' => $row2["activityData"]);
        $media[$row["id"]]['associated'][] = Array('latitudePos' => $row2["latitudePos"]);
        $media[$row["id"]]['associated'][] = Array('longitudePos' => $row2["longitudePos"]);
        $media[$row["id"]]['associated'][] = Array('currentDate' => $row2["currentDate"]);
        $media[$row["id"]]['associated'][] = Array('currentTime' => $row2["currentTime"]);




Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.