FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Creating Alias in mysql





bukaida
I want to perform the following--

A table contains the attribute Name, Address and Alias. Each name in the database should have multiple entries in alias column. If an user types the main name or any of the alias name, the main name and the address should be displayed. PHP can be used as scripting language.Please suggest the database structure and PHP script for this purpose. The main name and address is one entry per record.
rvec
If you have to be able to order by alias I think the best way is to make two tables. One with all aliases and the names (if the name is unique else an id), and the other one with name and address (and id if name isn't unique). You can join the 2 tables to combine the data.

A php script to the alias with the name:
Code:

<?php

$username = "Your_database_username";
$password = "Your_pass";
$database = "The_database_name";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "SELECT * FROM table1 RIGHT JOIN table2 ORDER BY alias";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){
   echo $row[alias] ."-". $row[name];
   echo "<br />";
}
?>


I think it should work like that.
Related topics
Mysql database problem
A very good PHP MySQL Tutorial
Flat file-based, MySQL-based counter
MYSQL Normalization double join
Creating a MYSQL "most common" query
How to Make A PHP Portal.
What happened to the server 2?
Technique Behind Adding a friend in a social website
How to install phpbb3
Crash course in PHP and MYSQL
Advanced MySQL db merging Tutorials
PHP Tutorial: Basic Shoutbox w/ MySQL
PHP MySQL Commands Question
[solved] Weird mysql error
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.