Jump to content

Pulling simple values from forms MySQL/PHP


stewart715

Recommended Posts

i have a form where you can choose either 1 or 2 and when submitted it is put into a database table along with that persons uid..the column is INT(10)

i justt need script that pulls the data where the uid is that persons uid and if the value is 1, show this..if the vaule is 2, show this

would i use mysql_fetch_object?
I'd use mysql_fetch_array()

[code]
<?php
$sql = "SELECT column FROM table WHERE uid = '$uid'";
$result = mysql_query($sql) or die ("Unable to run $sql: " . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);

if ($row['column'] == 1){
  // do something here
}
else {
  // do something here
}
?>
[/code]

Regards
Huggie
Thanks for the quick reply.

for some reason it's not getting the data....

[code]<?php
function phptemplate_user_profile($user, $fields = array()) {
$link = mysql_connect("localhost","thepdcom_popnew","pass");
mysql_select_db("thepdcom_popnew",$link);
$sql  = mysql_query("SELECT privacyid FROM `privacymode` WHERE uid = $user->uid ");
$result = mysql_query($sql) or die ("Unable to run $sql: " . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);

if ($row['privacyid'] == 2){
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));

} else  if ($row['privacyid'] == 1){

if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) {
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));

}

else if ($account->uid != $user->uid && user_access('maintain buddy list')) {
return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields));

}

} else  if ($row['privacyid'] == NULL){
return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields));

}
  }
?>


[/code]

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.