Hi Dean
You can probably do this in about 6 lines of php code, me on the other hand, I am at the level of "See Spot Run" (first grade reader).
Could you post a good copy of code that does something like this:
It returns user data based on an assigned id number which is used in their URL to access the website. ie: www.site.com?id=xxxxx The assigned id #
In my case userID is held in user3 of lm_user
The function unique which returns the unique UID is used to send email to user with link to profile.php
Basically php that finds the right line in lm_user and bring back everything from uid to user10. Other ListMailPro users can just make minor edits and do the same on their websites. OK.. Other inexperienced php'ers can do the same thing.
Or a least give me your assessment.
Thanks
Tom
(Trying to get from kindergarten to first grade in php. I would not be able to write this from scratch, I just copy bits of code and try to make it work.)
<?php##functions.phpfunction dbc() { //connect to database. mysql_connect("localhost","user","pasword"); mysql_select_db("listmail");}dbc();function set_uid() { global $id; $result = mysql_query("select user3 from lm_users where user3='$id'") or die(mysql_error()); $field = mysql_result($result, 0, 'user3'); return $field;}// All data returned from db to be based// from the ?id=user_id $uid = set_uid();// Get f_namefunction f_name($uid) {$result = mysql_query("select fname from lm_users where user3='$uid'") or die(mysql_error());$field = mysql_result($result, 0, 'fname');return $field;}$f_name = f_name($uid);// Get l_name function l_name($uid) {$result = mysql_query("select lname from lm_users where user3='$uid'") or die(mysql_error());$field = mysql_result($result, 0, 'lname');return $field;}$l_name = l_name($uid);// Get user_name function user_name($uid) {$result = mysql_query("select user5 from lm_users where user3='$uid'") or die(mysql_error());$field = mysql_result($result, 0, 'user5');return $field;}$user_name = user_name($uid);// Get e_mail function _mail($uid) {$result = mysql_query("select email from lm_users where user3='$uid'") or die(mysql_error());$field = mysql_result($result, 0, 'email');return $field;}$email = _mail($uid);// Get offer function _offer($uid) {$result = mysql_query("select user4 from lm_users where user3='$uid'") or die(mysql_error());$field = mysql_result($result, 0, 'user4');return $field;}$_offer = _offer($uid);// Get uniquefunction unique($uid) {$result = mysql_query("select uid from lm_users where user3='$uid'") or die(mysql_error());$field = mysql_result($result, 0, 'uid');return $field;}$unique = unique($uid);?>
Tom,
There are numerous ways this can be accomplished. I think you chose a very complicated one. :) Here's how I would do it:
<?php// connect to mysql// select db// SQL query + addslashes prevents SQL injection (important!)$row = mysql_query("select uid,fname,lname,email,user1,user2,user3,etc from lm_users where id = '".addslashes($id)."';");// if no row returned then the userID did not exist - exitif(@mysql_num_rows($row)==0) exit('ID not found!');// row found, list user datalist($uid,$fname,$lname,$email,$user1,$user2,$user3,$etc)=mysql_fetch_row($row);echo "UID=$uid<br>First Name=$fname<br>Last Name=$lname<br>Email=$email<br>etc<br>";?>
I hope that helps!
Ok how is this?
I can't write this stuff, only adapt what I already have.
- Rather then the traffic being lost from a id=xxxx not found, it defaults to "1246"
- In my case sponsor's id will be in the record of users of list 2, so I have to specify list 1
- Since lm_user also contains the records of unconfirmed users I need to specify confirmed.
Here's my edit.
Let me know if there are any, "OMG you can't do that" in it.
Thnaks
Tom
<?php##function.phpfunction dbc() { //connect to database. mysql_connect("localhost","user","paswrd"); mysql_select_db("listmail");}dbc();// SQL query find id=xxxx or default + addslashes prevents SQL injection (important!) $row1 = mysql_query("select uid,fname,lname,email,user1,user2,user3 from lm_users where list = 1 and cnf = 1 and user3 = '".addslashes($id)."';"); // if no row returned then default row2 if(@mysql_num_rows($row1)==0) { $row2 = mysql_query("select uid,fname,lname,email,user1,user2,user3 from lm_users where list = 1 and user3 = 1246;"); list($uid,$fname,$lname,$email,$user1,$user2,$user3)=mysql_fetch_row($row2); }else{ list($uid,$fname,$lname,$email,$user1,$user2,$user3)=mysql_fetch_row($row1); }// Testecho "UID=$uid<br> First Name=$fname<br> Last Name=$lname<br> Email=$email<br> id=$user3<br>"; ?>