Search the Community
Showing results for tags 'in'.
-
Need help badly! Setting up a new website with user logins. Pretty simple kind of stuff. Started working on letting the user upload a profile photo for their account, managed to get the user to be able to upload the photo in to a file on the site (upload/) and the image name entered in to their user details in SQL database. Worked fine. Only problem is when I try to recall the information, i've only been able to recall everybody's information and not just the logged in user. Here is the code I'm using. Bare in mind, I'm no pro with PHP and SQL so please help with as many details as possible. Thanks! ---------------------------------------------------------- <?php // Connects to your Database mysql_connect("localhost", "username", "password") or die(mysql_error()) ; mysql_select_db("database name") or die(mysql_error()) ; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM users") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=http://www.mysite/users/upload/".$info['photo'] ."> <br>"; Echo "<b>Name:</b> ".$info['name'] . "<br> "; } ?> ---------------------------------- This seems to recall everyones info. I only want the display photo to be shown for the logged in user. I have tried a lot of changes and either the image doesn't show or nothing shows.
-
I am trying to build search option in which I want to match multiple options with database values 1)When using the "where IN" clause the values compared are 'OR'd' and i need it 'AND' the array. 2) $do=mysql_query("SELECT * from hire WHERE sname=$sname AND lhname IN ($ser2) AND exnum IN ($ser3)"); while($row2=mysql_fetch_array($do)) { ?> <tr> <td><?php echo $row2['id']; ?></td> <td><?php echo $row2['fname']; ?></td> <td><?php echo $row2['lname']; ?></td> <td><?php echo $row2['lhname']; ?></td> <td><?php echo $row2['cnum']; ?></td> <td><?php echo $row2['exnum']; ?></td> <td><?php $id=$row2['id']; $row3=mysql_query("SELECT * from skill where id=$id"); while($val=mysql_fetch_array($row3)) { $bits=$val['sname']; $arr[]=$bits; } $imp=implode(",",$arr); echo $imp ; ?></td> </tr> The above code gives Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given at the while loop please help Thank you!
- 4 replies
-
- mysql
- fetch_array
-
(and 2 more)
Tagged with: