Jump to content

Archived

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

stewart715

VERY SIMPLE QUESTION Converting data

Recommended Posts

I need to a script that will do this in the following order
1.  connect to a db
2.  select PID from tableb where UID=$user->uid (current user)
3.  if PID =1 print YES if PID=2 print NO

any suggestions?

Share this post


Link to post
Share on other sites
[code]
<?php
  // 1. connect to a db
  $conn = mysql_connect('localhost','username','password') or die(mysql_error());
  $db = mysql_select_db('dbname',$conn) or die(mysql_error());
 
  // 2. select info
  $id = $user->uid;
  $sql = "select PID from tableb where UID=$id";
  $result = mysql_query($sql, $conn) or die(mysql_error());

  // 3. print yes or no
  $yesorno = mysql_fetch_assoc($result);
  switch ($yesorno[0]) {
      case 1 : echo "yes"; break;
      case 2 : echo "no"; break;
      default : echo "1 or 2 not found..some kind of error";
  }
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.