Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 4th, 2007, 01:44 PM
Authorized User
 
Join Date: Sep 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying Information Php/mysql

I am trying to create a user profile system, and I need to make it so users can choose whether or not to display information on their profiles.

How would I use PHP to retrieve information from a MySQL table, and if the table says display="yes", display the user's name.
__________________
Visit my website at GladiatorStudios.com!
 
Old November 12th, 2007, 04:14 PM
Authorized User
 
Join Date: Dec 2006
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to paagle
Default

Simple:
make an enum field 'display' wid 'y' and 'n'

in the form give an option field

then in php code
<?php
$connect = mysql_connect($host,$user,$pass);
$db = mysql_select_db($dbname,$connect);
$sql = "SELECT `display` FROM `table` WHERE `user` = '".$some_user_variable."'";
$query = mysql_query($sql,$a);
$fetch = mysql_fetch_rows($query);
if($fetch[0] = 'y')
{ //Code to display username}
else
{//some other code}
?>

---
Paagle
TEAM LEADER-Team Xuberance(http://www.xuberance.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
displaying images and information cherniin J2EE 0 April 23rd, 2007 01:12 AM
Displaying images stored in MySQL through in PHP trufla PHP Databases 3 May 2nd, 2006 04:55 AM
How to write files information to mysql db using p method PHP Databases 4 February 14th, 2006 09:18 PM
getting information from php into a iframe robertjshillito Beginning PHP 1 February 25th, 2005 04:05 PM
PHP ( Cannot modify header information) squared_ring Beginning PHP 6 August 14th, 2004 05:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.