wirewolf
05-10-2005, 05:33 AM
Need some help with writing a query to check the condition of two userfields in vbulletin after a user has uploaded photos in photopost. This query will be in a photopost php file (the file used just after a user has finished uploading). The photopost tables and the vbulletin tables are in the same database (makes it a little easier).
The scenario:
I have two userfields in vbulletin that if true (value = 1). field#x will display a link to that users photo gallery in the postbit and the member profile. field#xx will dispay the last photo uploaded as a thumbnail in the users' postbit with a link to that users' photo. Both of these are now user sectable in the user options (UserCP), and in the Admin user menu, but I would like this to be set automatically when the user uploads.
If this is the first time a user has uploaded photos, then the two values of these fields will be ' ' (null). But if the user has previously uploaded then most likely these values will be '1' (true). Most likely already set by me or the user.
So the first step is to check for the values of both fields. Then, based on their conditions, set or don't set the new value
The varible for the uploading user in the photopost script is $upuserid.
$userid is the variable (PRIMARY KEY) used by vbulletin in the userfield table.
This is what I have so far, but I'm stuck on the the two 'if' conditionals. And should I use UPDATE or INSERT INTO
Also, in the pohotopost scripting, they use - ppmysql_query - instead of mysql_query. Should I use the same syntax to query the vbulletin table.
$query = "SELECT fieldx, fieldxx FROM vbulletin_prefix_userfield WHERE userid = $upuserid";
$get_fields = mysql_query($query);
list( $fieldx, $fieldxx ) = mysql_fetch_row($get_fields);
mysql_free_result($get_fields);
if ($fieldx == 1) {
} else {
$query = "UPDATE vbulletin_prefix_userfield SET fieldx=1 WHERE userid = $upuserid";
}
if ($fieldxx == 1) {
} else {
$query = "UPDATE vbulletin_prefixuserfield SET fieldxx=1 WHERE userid = $upuserid";
}This is the my first time writing this type of code from scratch, so any assistance would be greatly appreciated.
John
The scenario:
I have two userfields in vbulletin that if true (value = 1). field#x will display a link to that users photo gallery in the postbit and the member profile. field#xx will dispay the last photo uploaded as a thumbnail in the users' postbit with a link to that users' photo. Both of these are now user sectable in the user options (UserCP), and in the Admin user menu, but I would like this to be set automatically when the user uploads.
If this is the first time a user has uploaded photos, then the two values of these fields will be ' ' (null). But if the user has previously uploaded then most likely these values will be '1' (true). Most likely already set by me or the user.
So the first step is to check for the values of both fields. Then, based on their conditions, set or don't set the new value
The varible for the uploading user in the photopost script is $upuserid.
$userid is the variable (PRIMARY KEY) used by vbulletin in the userfield table.
This is what I have so far, but I'm stuck on the the two 'if' conditionals. And should I use UPDATE or INSERT INTO
Also, in the pohotopost scripting, they use - ppmysql_query - instead of mysql_query. Should I use the same syntax to query the vbulletin table.
$query = "SELECT fieldx, fieldxx FROM vbulletin_prefix_userfield WHERE userid = $upuserid";
$get_fields = mysql_query($query);
list( $fieldx, $fieldxx ) = mysql_fetch_row($get_fields);
mysql_free_result($get_fields);
if ($fieldx == 1) {
} else {
$query = "UPDATE vbulletin_prefix_userfield SET fieldx=1 WHERE userid = $upuserid";
}
if ($fieldxx == 1) {
} else {
$query = "UPDATE vbulletin_prefixuserfield SET fieldxx=1 WHERE userid = $upuserid";
}This is the my first time writing this type of code from scratch, so any assistance would be greatly appreciated.
John