Jump to content

select function where = array ?


henricar

Recommended Posts

hey everyone, I am trying to fetch an array using the WHERE condition. What I would like to do is set the WHERE equal to multiple values (as an array). This is the code I have but it doesn't seem to be working.. could anyone please help me? Thank you!

$fetchfol = mysql_query("SELECT * FROM following WHERE bywho='$currentuserid'");
$folarray = mysql_fetch_array($fetchfol);
$folarray = $folarray['followwho'];

$fetchsresults = "SELECT * FROM posts WHERE (bywho = '$folarray') ORDER BY popularity DESC";

 

Link to comment
Share on other sites

If I want a couple fields specifically, sure. But where's the clarity in typing out everything by hand?

SELECT post_id, topic_id, forum_id, poster_id, icon_id, poster_ip, post_time, post_approved,
    post_reported, enable_bbcode, enable_smilies, enable_magic_url, enable_sig, post_username, post_subject,
    post_text, post_checksum, post_attachment, bbcode_bitfield, bbcode_uid, post_postcount, post_edit_time,
    post_edit_reason, post_edit_user, post_edit_count, post_edit_locked
FROM phpbb_posts...

Compare that with

SELECT * FROM phpbb_posts

Will I use every field that comes back? Maybe not. But I'd much rather have extra data than maintain a gigantic list of fields.

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.