GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Mar-2005, 14:20
Zurke Zurke is offline
New Member
 
Join Date: Dec 2004
Posts: 12
Zurke is on a distinguished road

choosing field within a row


PHP 5.0.2
MySQL 4.1.7
Apache 1.3.33

Hi all,

I am allowing my members to change their usernames after registering. I would prefer that if they do change their usernames for use within the forums that their new name is displayed within my members page.

I have blindly tried some "if" statements but cant seem to get anything to work. Here is something I tried but it was fruitless. Any Ideas?

"newname is the name they could change to from username after registering"

PHP Code:

$query='SELECT newname, username, createdate FROM chmembers';
$result = mysqli_query($connection,$query);
if (!$result){
exit('unable to retrieve table mysql_error())';
}

while ($row = mysqli_fetch_array($result)){

$newname=$row[newname];
$createdate=$row[createdate];

"if ($row[newname]==0) {$newname = $row[username]};"

} 
mysqli_close ($connection);

<body>
<table>$newname</table> 


Last edited by JdS : 02-Mar-2005 at 07:45. Reason: please insert your example PHP codes between [php] and [/php] bbcode tags
  #2  
Old 09-Mar-2005, 04:24
besttoolbars
 
Posts: n/a
Quote:
"if ($row[newname]==0) {$newname = $row[username]};"

what does these quotes do here?...
And could you show your errror?
  #3  
Old 24-Mar-2005, 21:14
jmumm jmumm is offline
Awaiting Email Confirmation
 
Join Date: Mar 2005
Location: Milwaukee, WI
Posts: 4
jmumm is on a distinguished road
Why do you have a separate row for newname and username? Why not just update username and use that universally?

Anyways...

Why are there quotes around the if statment, I don't think those are supposed to be there.

One more syntax thing, and I'm not sure if it matters I always forget, but try putting single quotes when using the $row array, like...

Code:
$newname=$row['newname'];

Other than that the code makes sense to me.
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Discussion] Choosing a Host Cash Web Hosting Forum 7 19-Sep-2005 07:21
User-agent field in robots.txt JdS Web Design Forum 7 02-Sep-2004 11:19
Choosing a Host AuroraHost Web Hosting Forum 0 17-Jan-2004 20:58
text field problm zuzupus Web Design Forum 3 04-Sep-2003 06:18
ambiguity in time field zuzupus MySQL / PHP Forum 9 28-Jul-2003 09:40

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:37.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.