Log in

View Full Version : mysql query.


Vinney
08-25-2002, 09:41 PM
what is the db query i need to pull the custom user profile fields into a script am making please ?

:eek: cheers

NTLDR
08-25-2002, 10:00 PM
if you just want to select all the information, ie userid, fieldx, contents:

SELECT * FROM userfield;

Vinney
08-25-2002, 10:01 PM
Originally posted by NTLDR
if you just want to select all the information, ie userid, fieldx, contents:

SELECT * FROM userfield;

whats the whole query please ? am a noob ..... i dont know anything about mysql in php.

and what do i use to call the custom user fields of field5 and field9?

would $post[field9] and $post[field5] work in this case.? or is it something else?


thanks.

Vinney
08-26-2002, 07:59 PM
bump :(

NTLDR
08-26-2002, 08:04 PM
Originally posted by Vinney
[B]whats the whole query please ? am a noob ..... i dont know anything about mysql in php.

That is the whole query.

and what do i use to call the custom user fields of field5 and field9?

SELECT userid,field5,field9 FROM userfield;

would $post[field9] and $post[field5] work in this case.? or is it something else?

If in the postbit then yes.

Vinney
08-26-2002, 08:47 PM
Originally posted by NTLDR


That is the whole query.



SELECT userid,field5,field9 FROM userfield;



If in the postbit then yes.

it's not in the postbit, sorry i confused you. am trying to call the userfields for my own script.


<?php
error_reporting(7);
require ('../../mainfile.php');
$index = 1;
global $Pmenu,$breadcrumb;
$Pmenu="";
$breadcrumb="Contact Helpdesk";
$defaultmessage = "Dear Helpdesk... \n\n - $bbuserinfo[username]";
$defaultemail = "$bbuserinfo[email]";
$defaultmembership = "???????";
$defaultexpiry = "??????";
//getvbpvars();
include("header.php");
if ($bbuserinfo[usergroupid]==6 || $bbuserinfo[usergroupid]==1 || $bbuserinfo[usergroupid]==3 || $bbuserinfo[usergroupid]==11) {
eval("dooutput(\"".gettemplate('helpdesk_nologin')."\");");
} else {
eval("dooutput(\"".gettemplate('helpdesk')."\");");
}
include("footer.php");
?>



sorry i dont know the gargon, what $????? ( is it a called a variable ) to define each custom field, so that i can insert this in my template and they will be replaced with the members value when called.?

Vinney
08-26-2002, 09:42 PM
bump.

NTLDR
08-27-2002, 01:54 PM
Originally posted by Vinney
bump.

Try to leave it at least one or two days before bumping threads.

$customfield=$DB_site->query("SELECT field5,field9 FROM userfield WHERE userid='$bbuserinfo[userid]'");
while ($field=$DB_site->fetch_array($customfield)) {
$field5=$feild[5];
$feild9=$field[9];
eval("\$usercustomfield = \"".gettemplate('template_name')."\";");
}

Change template_name to the name of the template and create it with whatever formating and place $feild5 in that template for feild 5 and $feild9 in there for feild 9. Then in the main template for the page put in $usercustomfield where you want it to be displayed.

Vinney
08-27-2002, 02:42 PM
Cheers NDLR .....but i cant get it to work, i get this error :

Database error in vBulletin 2.2.6:

Invalid SQL: SELECT field5,field9 WHERE userid='1'
mysql error: You have an error in your SQL syntax near 'WHERE userid='1'' at line 1

mysql error number: 1064

Date: Tuesday 27th of August 2002 05:49:54 PM
Script: http://www.peugeot-gti.net/files/helpdesk/

where do i place your code in the following ? :-


<?php
<?php
error_reporting(7);
require ('../../mainfile.php');
$index = 1;
global $Pmenu,$breadcrumb;
$Pmenu="";
$breadcrumb="Contact Helpdesk";
$defaultmessage = "Dear Helpdesk... \n\n - $bbuserinfo[username]";
$defaultemail = "$bbuserinfo[email]";
include("header.php");
if ($bbuserinfo[usergroupid]==0 || $bbuserinfo[usergroupid]==1 || $bbuserinfo[usergroupid]==3 || $bbuserinfo[usergroupid]==11) {
eval("dooutput(\"".gettemplate('helpdesk_nologin')."\");");
} else {
$customfield=$DB_site->query("SELECT field5,field9 WHERE userid='$bbuserinfo[userid]'");
while ($field=$DB_site->fetch_array($customfield)) {
$field5=$feild[5];
$feild9=$field[9];
eval("\$usercustomfield = \"".gettemplate('helpdesk')."\";");
}
include("footer.php");
}
?>


my helpdesk template contains :


<table cellpadding="0" cellspacing="0" border="0" bgcolor="#0A293E" width="95%" align="center"><tr><td>
<table cellpadding="4" cellspacing="1" border="0" width="100%">
<tr>
<td colspan="2" bgcolor="#336D95" background="https://vborg.vbsupport.ru/images/catagory_backing.gif" align="left"><normalfont color="#000000"><b>
Welcome to PGAC Helpdesk - Follow instructions carefully.</b></normalfont></td>
</tr>
<tr>
<td bgcolor="#13486D" align="left" valign="top">
<p align="center">
<normalfont>Welcome to $bbtitle Helpdesk. </normalfont></p>
<p>
<normalfont>Please take the time to carefully read the following instructions.
This e-mail form has been created, so that forum members can place their questions, or
queries to a member of our help desk.
Please make sure you fill in all the mandatory fields in.<br><br>
If you have recently just joined the club and have received you membership
number and renewal date via the post, make sure you have placed them details
within your
<a target="_blank" href="http://www.peugeot-gti.net/forums/member.php?s=$session[sessionhash]&action=editprofile">
UserCP</a> (<a target="_blank" href="http://www.peugeot-gti.net/forums/member.php?s=$session[sessionhash]&action=editprofile">User Control Panel</a>), and then continue with this.<br>
<br>
-$bbtitle Staff</normalfont></td>
</tr>
</table>
</td></tr></table>
<form enctype="multipart/form-data" action="send.php" name="refer" method="post">
<table cellpadding="0" cellspacing="0" border="0" bgcolor="#0A293E" width="95%" align="center"><tr><td>
<table cellpadding="4" cellspacing="1" border="0" width="100%">
<tr>
<td colspan="3" bgcolor="#336D95" background="https://vborg.vbsupport.ru/images/catagory_backing.gif" align="left"><normalfont color="#000000"><b>Contact $bbtitle
Helpdesk!</b></normalfont></td>
</tr>
<tr>
<td bgcolor="#13486D" align="left" valign="top" nowrap><normalfont>Your
username:</normalfont></td>
<td bgcolor="#13486D" align="left"><input type="text" name="name" size="30" class="bginput" tabindex="1" value="$bbuserinfo[username]"></td>
<td bgcolor="#13486D" align="left"><b><font color="#FF0000">
*</font></b></td>
</tr>
<tr>
<td bgcolor="#1C5780" align="left" valign="top" nowrap><normalfont>Your email:</normalfont></td>
<td bgcolor="#1C5780" align="left"><input type="text" name="email" size="30" class="bginput" tabindex="1" value="$defaultemail"> </td>
<td bgcolor="#1C5780" align="left"><b>
<font color="#FF0000">*</font></b></td>
</tr>
<tr>
<td bgcolor="#13486D" align="left" valign="top" nowrap><normalfont>Your
m/ship N</normalfont><normalfont><font face="Times New Roman">?</font></normalfont><normalfont>:</normalfont></td>
<td bgcolor="#13486D" align="left">
<input type="text" name="mem" size="4" class="bginput" tabindex="1" value="$field5"></td>
<td bgcolor="#13486D" align="left"><b><font color="#FF0000">
*</font></b></td>
</tr>
<tr>
<td bgcolor="#1C5780" align="left" valign="top" nowrap><normalfont>Your
renewal date:</normalfont></td>
<td bgcolor="#1C5780" align="left">
<input type="text" name="expiry" size="8" class="bginput" tabindex="1" value="$field9"> example:
08/12/02</td>
<td bgcolor="#1C5780" align="left"><b>
<font color="#FF0000">*</font></b></td>
</tr>
<tr>
<td bgcolor="#13486D" align="left" valign="top" nowrap><normalfont>Subject:</normalfont></td>
<td bgcolor="#13486D" align="left">
<normalfont><input type="radio" name="title" value="General Feedback" checked>General Feedback<br>
<input type="radio" name="title" value="Bug Report">Bug Report<br>
<input type="radio" name="title" value="Registration Problem">Registration Problem
/ Activation request (<b><font color="#FF0000"><u>read above</u></font></b>)<br>
<input type="radio" name="title" value="">Other <input type="text" name="otitle" size="25" class="bginput" tabindex="5">
</normalfont>
</td>
<td bgcolor="#13486D" align="left">
<b><font color="#FF0000">*</font></b></td>
</tr>
<tr>
<td bgcolor="#1C5780" align="left" valign="top" nowrap><normalfont>Your message to us:</normalfont></td>
<td bgcolor="#1C5780" align="left">
<textarea name="message" wrap="virtual" cols="70" rows="15" class="bginput" tabindex="6">$defaultmessage</textarea></td>
<td bgcolor="#1C5780" align="left">
<b><font color="#FF0000">*</font></b></td>
</tr>
</table>
</td></tr></table>
<center>
<b><font color="#FF0000">* </font>= Mandatory field</b><br><br>
<input type="submit" value="Send Email" tabindex="7" accesskey="s" class="bginput"></center>
</form>

Vinney
08-27-2002, 02:55 PM
what is $usercustomfield there for ?

g-force2k2
08-27-2002, 04:11 PM
Vinney try this query instead ::

$flds = $DB_site->query_first("SELECT field5, field9 FROM userfield WHERE userid='$bbuserinfo[userid]'");
$field5 = $flds[field5];
$field9 = $flds[field9];

regards...

g-force2k2

NTLDR
08-27-2002, 07:13 PM
Originally posted by g-force2k2
Vinney try this query instead ::

$flds = $DB_site->query_first("SELECT field5, field9 FROM userfield WHERE userid='$bbuserinfo[userid]'");
$field5 = $flds[field5];
$field9 = $flds[field9];

Would help if I put in the query the table it was supposed to be getting the dara from :dead:

I've changed the code vinny, $usercustomfield is the template that has the HTML code for the custom fields and is put in the main template where you want them to display.

g-force2k2's option may be more efficent though.

Vinney
08-27-2002, 07:56 PM
g-force2k2 spot on ! cheers !

g-force2k2
08-27-2002, 08:43 PM
Originally posted by NTLDR
Would help if I put in the query the table it was supposed to be getting the dara from

eh don't worry about it man... we all make mistakes :) glad it worked Vinny ;)

regards...

g-force2k2