Jump to content

PHP wont display all results


spencer9772

Recommended Posts

Hey guys so my code below is not working, it will get the app information for the user but its only display 3 results like every time a new user "installs" an new app like it stops showing the last result and starts displaying the new result. Like for example right now it should be showing 7 results but only displaying 3 is there something wrong with my query. (PS: this is just developement testing purposes so thats why my code is sorta sloppy) Thanks!

$default_apps = mysql_query("SELECT * FROM apps WHERE `default`='1'") or die(mysql_error());
$user_apps = mysql_query("SELECT * FROM user_apps WHERE `user_id`='$user_id'") or die(mysql_error());
while($row = mysql_fetch_array($default_apps))
{
$url = $row['download_url'];
$name = $row['name'];
   echo $row['name'];
   echo "<a href='$url'>$name</a><br />";
} 
while($raw = mysql_fetch_array($user_apps)){
$app_id = $raw['app_id'];
}
$select_user_apps = mysql_query("SELECT * FROM apps WHERE `app_id`='$app_id' ");
while($rop = mysql_fetch_array($select_user_apps))
{
$name = $rop['name'];
$url = $rop['download_url'];
echo $name;
echo $url;
}
Link to comment
Share on other sites

i bet that your last insert queries did not work.

 

You can retrieve users and apps in one query.

 

Maybe you should take a moment to read a bit on the internet?

SELECT
    u.user_id, u.firstname, u.email, a.app_id, a.name, a,download_url
FROM
    users u
JOIN
    users_apps j
ON
    u.user_id=j.user_id
JOIN
    apps a
ON
    a.app_id=j.app_id
WHERE
    u.user_id=123 AND a.default=1

If you are starting right now, do not use the mysql_ functions. They are deprecated! Instead try to learn PDO or minimal mysqli_ functions.

to improve security use prepared statements too.

 

If you are using the mysqli_ functions do not forget that these functions can return errors. If you do not handle these errors you wont see them and you want know what is going wrong.

Link to comment
Share on other sites

And try to write better English when you post such long descriptions.  It makes it easier for us to read and, uh, like, understand what you are saying.  Helps when you break up your thoughts into sentences with punctuation and capital letters.  Sloppy code is uh, like, forgivable in a uh, like, learning situation, but not uh like sloppy English.

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.