Jump to content

query only returns the last row from database


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;

}

}


}

}

 

?>

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;
}       
} 
}
}
 
?>
 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.