Jump to content

query only returns the last row from database


calmchess
Go to solution Solved by calmchess,

Recommended Posts

Why is this mysql query only returning the last row of data? I can't remember how to write this correctly. Please help.

 


<?php session_start();

$docID=7768;

if($docID===7768){__putreg($docID);}

function __putreg($docID){

if($docID===7768){

  //check database for credentials

  

  $conn0=mysqli_connect("localhost","calmchess","ptoK4ptoK4","book");

if($conn0){

$q0=mysqli_query($conn0,"select _logged_in_picpath,_logged_in_username from logged_in_users")or die(mysqli_error($conn0));

while($row = mysqli_fetch_array($q0)){

$picpaths0[]=$row['_logged_in_picpath'];

$usernames0[]=$row['_logged_in_username'];

}    

for($i=0;$i<count($picpaths0);$i++){

$picspaths00 = $picpaths0[$i].":::";

$picassets0=$picspaths00."^^^".$usernames0[$i];

if($i/4==0){

$picassets0=$picassets0."xxx";

}

if($i==count($picpaths0)-1){

 

echo $picassets0;

}

}


}

}

 

?>
Link to comment
Share on other sites

  • Solution

yeah you are correct Here How I solved it

 

 

 
<?php session_start();
$docID=7768;
if($docID===7768){__putreg($docID);}
function __putreg($docID){
if($docID===7768){
  //check database for credentials
  
  $conn0=mysqli_connect("localhost","calmchess","ptoK4ptoK4","book");
if($conn0){
$q0=mysqli_query($conn0,"select _logged_in_picpath,_logged_in_username from logged_in_users")or die(mysqli_error($conn0));
$j=-1;
while($row = mysqli_fetch_array($q0)){
$j++;
$picpaths0[]=$row['_logged_in_picpath'];
$usernames0[]=$row['_logged_in_username'];
$picspaths00 = $picpaths0[$j].":::";
$picassets0=$picspaths00."^^^".$usernames0[$j];
if($j/4==0){
$picassets0=$picassets0."xxx";
}
echo $picassets0;
}       
} 
}
}
 
?>
 
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.

Guest
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.