Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Creating A New MySQL Database


I run a small horse racing based website that has a 'fantasy league' type competition each season. Last year i looked after all the entries, leaderboards etc.. using excel and copying and pasting to webpages each week.

However this year i am going to attempt to use MySQL and PHP to have it automatic bar result entry. I have built a basic php and MySQL site before with the usual insert, edit etc.. But this one will need features im not sure how i go about making.

Basically there will be a list of horses (around 150) divided into 4 grades. Entrants pick 2 horses from each grade so a total of 8 horses. Winning horses score 5, 2nd = 3 and 3rd =1.

I was thinking of having the following 2 tables - one for the horses - listing their name and grade. One for entrants - the peoples contact details and their chosen horses.

However from there im not sure how to able to enter the latest results and how i can create a leaderboard page and list the points each horse has. I was thinking of a new table with a row for each result showing horse name and points scored but i then dont't know how this table can be used to create a column on the horse table that lists each horses total points. And also how it can be used to create the total points each entranant has got so far (i.e. the total point for all 8 of their horses)




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Problems Creating Database MySQL In PHP
Hello, here is an interesting problem: I can connect to MySQL and create there normally databases via command line. The problem is when I want to create a database in PHP, I have problems apparently with the configuration of username and password in MySQL. I have PHP 4.3.9 as a module Apache2. and MySQL 4.1. I repeat, I can connect normally to MySQL in PHP, using mysql_connect() with the right hostname, username, password values. but when I write a script to create a database in PHP, it has these problems. This is the simple script:

Problem Creating A Mysql Database Named M#2 Using Php
I am serving a website using apache. All the php and mysql code I have
written works, except for one thing. When I try to create a database
named M#2 using the following call, no database is created.

$db = 'M#2'
$query = "create database '$db'";
$result = @mysql_query($query);

I am able to create a database just fine using this technique when it
is named other things (such as M$B, or Global1). I am able to create
the database using CocoaMySQL. The MySQL documentation I read says the
only characters you cannot use are , . / and , but they don't mention
"#". Also, it mentions that if you can have any database name that can
be used as a directory name. I am able to create a directory name in
unix called "M#2".

Creating Database
1. How do you create a MySQL Database??
2. How Do You Assign A Password And Username To It??
3. How Do You Access It??

Creating An Album Database
i'm trying to create a database of some cds. my database design has 2 tables for every cd.

1) album_details (some info for each album)

- album_id
- album_title
- album_sleeve
etc.....

2) album_tracks (songs for each album)
- album_id
- track_title
etc.....

the problem with my database design is that there is redundant data! for example, a cd with album_id 1 may have 20 tracks. the album_tracks table would have 20 instances of the album_id.

when i pull out the data from the database, the tracks keep repeating the 1st record from the album_tracks table.

my SQL statement:

SELECT album_details.album_title, album_details.album_sleeve, album_tracks.track_title
FROM album_details, album_tracks
WHERE album_details.album_id = $album_id
AND album_tracks.album_id = $album_id

Creating A Website Tree From Database
I have been given the task of creating a website tree-type diagram. I have details about web pages stored in a MySQL database. There is a reference column in the database using the format:

1.0
1.1
1.1.1
2.0
2.0.1
2.0.2
2.0.2.1

I'm sure you get the gist. What I need to do is loop through these rows in the table, outputting them in their heirarchical structure, turning this into a graphical representation in HTML.

This has me confounded from the start. I'm not sure how I would loop through these numbers in the correct order. Also, I'm not sure how I would now when I've got to the next level of numbers e.g. after looping through 1.1 - 1.6 (which should all be in the same row), how I would know that I now need to create a new row for 1.1.1, and that on this row should also be 1.6.1 --- I'm confused just writing it out.

Creating A Search Class That Searches Any Database
I've been requested by a client to implement a search engine on it's website. I told him that he does not need it, but he thundered on and well...Who cares, he' s gonna pay for it.

I've made search methods for other sites, but I would like to implement a portable one. A Search Class that could work for any DataBase and with ease of configuration.

Maybe de constructor could receive a database name in which to search.

And the function search, could receive an array of tables in which to search on and a string to search for on those tables. The question is...how would u implement the way that the class returns results?

Nowadays any pro site has the MVC controller. That means that almost all tables in the database have its corresponding model.  Table clientes correspond to the Client Model. How would you implement the results return?

What Is Indexing In Mysql And How It Will Be Useful And How We Can Retrieve Database Content Easily From A Database Table Containing About 5lakhs Datas
I need to select data from a database table containing huge amount of
data. Now I am storing data using one primary key and I am just using
simple select statement, and this process gives me the output but it is
taking long to execute the query. As much I had heared I want to use
some indexing or cluster indexing which might help me but I am not so
familiar with these things.

Creating XML From Mysql
I am trying to pull data from an MYSQL table. Right now I am only getting the first record out because I am not using a check array. Here is my code, I have been bashing my brains in all day over this hopefully someon can shed some light on this. I tried a basic array earlier and it didn't work. Code:

Creating Mysql Table
I have PHP script that creates a mysql table. My problem is when I goto the following php page to access the table it says "missing table 'table name'" I look in phpmyadmin and its clearly there. Eventually after refreshing the page like ten times it detects and works. Do I have to reconnect the mysql connection or something?

Creating Variable Using Mysql And Php
I am trying to create a variable but it just will not work. Anyone
see the error?

<?
$query = "SELECT Name FROM dataAA WHERE
NameId='".mysql_real_escape_string($_GET["Id"])."'";
$result = mysql_query($query)
or die ("no can do.");
while($row = mysql_fetch_array($result))
{

$Name = "echo $row["Name"]";
}
?>

Creating Table Using PSP And MySQL
Ok, so Ive overcome the first hurdle of connecting to MySQL and MyDatabase on my
web server using PHP scripts. Now I want to create a simple table with 3
fields. Don't have a clue where to start using PHP.

Creating A Mysql Dbase Via Php?
I was wondering if anyone could tell/show me how to create a mysql database via a php script as my hosts do not support telnet(dont ask).

Creating A PHP/MYSQL Scheduler
I am trying to do is create a schedule that will block off times that are already booked, as well as color code a small calendar depending on whether there are AM or PM openings. I managed to create a working edition, but I took the easy route of making the time in 30min intervals and creating a column for each time (0800, 0830, 0900, etc) in the DB.

Now I need to create it allowing ANY time to be booked for ANY interval. I have an idea as to what needs to be done, I am just not sure how to go about doing it.

What I set-up was a table with the technicians names and times they can work that day. It simply had a column for name, column for start time (datetime field) and column for finish time (another datetime field).

Then I had a bookings table with many columns for different fields to do with the booking, but it also had a field for the name and start/finish datetime columns.

What I think I need to do is run a query first to grab the time range that someone is available that day. Format it somehow into a PHP array. Then look at the existing bookings and find the time free between the booking and the available hours using PHP. Display a color if there is availability in the AM, PM, or both.

Then I need to create an HTML table to display the bookings and free time based on the DB info to allow creation of new bookings. Can anyone provide some guidance who has done something similar or would know how to do it? I just need the base of finding the free time between bookings and available hours and displaying a table with such info.

PHP, MYSQL With Creating Waitlist
Would anyone have any suggestions as to how to set up a waitlist? Here is what I have:
A user goes on to my site and registers for workshop. They are offered a list of open workshops or they can be waitlisted for workshops that are full.  What would be the best way to structure this? I currently have 3 basic tables:

users
register (transaction info that connects users to workshop, has timestamp)
workshops (info about each workshop, date, time, cap, etc.)

My idea was to have an "order" field in the register table that would renumber itself every time someone registers or changes registration, but I am having difficulty with this renumbering. I was thinking I could use this order field to tell if someone's order has changed.  So for instance, I cap the workshop at 5 people, and 6 people are registered.  The 6th person is actually on a waiting list. 

Then someone drops out of the workshp and now that 6th person is the 5th person and is no longer on the wait list.  I could create some php code that said, if the person's old order field is 6 and the new order field is 5, then send an email "you are registered!"  That is what I am trying, but I am having difficult storing the old value and then renumbering and finding the new value.

Creating A MySQL Table
I'm trying to create a table in PHP.  I can use phpmyadmin to do it but I can't create it in PHP.  I even copied the code generated in phpmyadmin and it still didn't work.  Here is the code:

Creating Link To From A Mysql Row...
I have the following code:

echo "<td>" . $row['title'] . "</td>";
I want it to link to $row['url'].

I have tried multiple methods, but I seem to be missing something.

MySQL Creating Links From Query
As I am still learning PHP could someone tell tell me how to achieve the following?

Display only the first four records from a sql query and have 'next page' links and number of pages so users can navigate the next four records and so on. The usual navigation you find on search engines.

I have the query and the num_rows function, I just need to know how to implement it.

Creating Search Engine In Php And Mysql
I want to create a search option for my site (ONLY searches my pages, NOT a web search).
A lot like the one on these forums actually. I was just wondering if anybody who has done this before had any suggestions as to how I should go about doing it.

Is it possible just using php and mysql... or would I need to use some other type of language (to make the spider). Or do I even NEED a spider for something like this?
Here is how I think it could be done. I'd have 2 columns. One for the location of each page on the site. Another would have text from the page (perhaps the first 40 words on the page).

From there, I could have my searching script compare the search value against anything the text column. if it found the search value in the text column it could display the link in the results page, with the text from the page to serve as a description.

Creating Directories From MySQL Query
I'm trying to create a subdirectory within a directory. The directory uses $rows['link'] from the category table, and the subdirectory uses $subcategory2 from the subcategory table. The directory that gets created is always based on the last record in the table, rather than the parent.

I have tried using another query, but only the subdirectory gets created then......

Creating A Tree And Storing It In MySQL
I'm wanting to create a tree structure and store this in a database, which can then be retrieved and displayed. I'm looking to implement this with PHP and MySQL. From what I gather it is possible using a table with two or three columns: ID, Parent_ID, Description.

So if we start from the top, the leaf would have an ID of 1, and a parent_id of 0. An item down the tree would have an ID of 2, and if a child of the first, a parent_id of 1, and so forth. How would I extract this from the database? Would I get all the data and then manipulate with PHP? Presumably I need to use some kind of recursion(another thing I'm a little shaky on).

PHP Code/libraries For Creating MySQL Databases
I am working on a registration system, and one of the things I am going to
need to be able to do it setup the database tables for each event that I
have registration for. Normally I would do this by hand, but I am wondering
if there are any code libraries out there that could generate the SQL for
me.

Basically I would have a list of column names and types. I know I could
just foreach() through the list, with a switch to divert control to the
different code segments depending on the column type, and at the end I would
have the SQL generated.

This seems like the sort of thing that somebody might have done before and
released a code snippet for. Maybe in PEAR DB? Any ideas?

Creating .xls And .doc Files With Page Breaks Using PHP / MySQL
Our company currently processes a few hundred form submissions through
our site. Up till now, the contents of the form has been sent to our
customer support staff in real-time. Each submission goes to a general
e-mail box where it's printed through our mail client. A copy of the
form is also stored in a MySQL db, although it's not used that often.

I have been asked to figure out a way to stop delivering the form
submissions in real-time and migrate to the following:

Each morning, provide an Excel spreadsheet and word document (or PDF)
with a certain number of form submissions to each customer support
rep. For example, say 200 form submissions were processed the day
before. This morning, I should split those 200 among the 5 support
reps and provide each of them a certain amount (which can change
daily). Assuming each person gets 40 form submissions, each person
would need to be given an excel file and .doc document that contains
their 40 form submissions.

One of the most important things is that the .doc file needs to have
each form submission separated by a page break, so that when they
print the document each form submission is printed on a separate page.

Finally, not all of the fields from the form submission should be
given to the support rep. Maybe date and time is left off.

Help In Creating Data Entry Forms With MySQL
I was wondering if any of you experts has some example of MySQL data
entry form either using PHP or any public domain software for my photo
album. I'd like to enter some description with it.

Copy And Paste On MySQL To MySQL Database
Would there be any issues if i literary Copy and Paste a mysql db from one server to another mysql db server? When i say "copy and paste" is just like tranferring one word doc from one pc to another pc.

I tried the copy and paste already and the new server had recognize the DB i had pasted. I just want to confirm if there would be issues doing it so.. Or should i use Mysql.com Migration toolkit?

Php/Mysql- Uploading Mysql Database
I've set up a basic database using Mysql (just creating a web blog I followed a tutorial) and then started writing the php code for interacting with the database. how do I put the Mysql database onto the the web server where I have server space (the server I use is just some company that I pay €100 a year for). I need the php file to get the data from the Mysql database...

Getting A Value From MYSQl Database
I want to get the value from a field in the database using the following PHP code:

$sql = "SELECT Paper_id from Papers WHERE Title= '$Paper_Title'";
$PaperID = mysql_query($sql);

However this returns some wierd response: "Resource id #2" how do I just get the value of the field in my new selected table which is 1*1.

Help With MySQL Database Retrieval
I am a total newbie and I am having problems retrieving multiple rows from a database...

when I try to get a printout of the whole table, I get the following error:

Warning: 0 is not a MySQL result index in C:HTTPDHTDOCStest.php3
My code is as follows:

<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("test",$db);
if ($myrow = mysql_fetch_array($result)) {
echo "<table border=1>n";
echo "<tr><td>Name</td><td>Position</td></tr>n";
do {
printf("<tr><td>%s %s</td><td>%s</tr>n", $myrow["first"], $myrow["last"], $myrow["address"]);
} while ($myrow = mysql_fetch_array($result));
echo "</table>n";
} else {
echo "Sorry, no records were found!";
}
?>

Check To See If Value Is Already In Mysql Database
I am looking for the most efficient way to check and see if an inputed email (via form) is already in the database under the column 'Email'.

Pdf Files In A Mysql Database
I have a mysql database which I reach with php-code.

I want to be able to download and open files I have stored(as a BLOB) in the database. Downloading and opening word documents and textfiles give no problems, but PDF-files aren't possible to open.

Has anybody the same troubles, or does anybody know a solution for this problem?

Insert Into Mysql Database
It sounds very simple, but for some reason I just can't figure it out, and it will save a lots of time to me, if someone can direct me into the right direction. I was trying to input data into mysql table through post method, but it was not working. I made it simple and just tried to enter anything from a php file, but it does not work, so there is something that i am doing wrong with the insertion query.

$link = mysql_connect($hostName, $userName, $password);
echo("connected");

mysql_select_db($databaseName, $link);
echo("database selected");
echo ($databaseName);

mysql_query("INSERT INTO image VALES('','','','','','','','','', 'hello', '', '', '','','','','')", $link);

echo ("done");

I am trying to enter into one of those fields, but it does not populate the table in mysql database.

Cant Connect To Mysql Database
I'm having a problem connecting to a database, when i use the following script to connect to a database (all the login details are correct) it connects to mysql but says it can't connect to the database any body got any suggestions...

Mysql Database Problem
I installed php4,MySQL,Apache on my Windows98 system. Everything works up to the point of connecting to Mysql. Then I can't get it to do anything else.
this works to connect:

$connection = mysql_connect("localhost", "user", "xxxxxxxx")
or die ("couldn't connect");
if ($connection) {
$msg = "success!";}?>
But when I try to anything like create a database I get the errors (in this case 'couldn't create database'.)

<?
$new_db = "cosmos";
$connection = @mysql_connect("localhost", "user", "xxxxxxxxx") or die ("Couldn't connect.");
$result = @mysql_create_db($new_db,$connection) or die ("Couldn't create database");
if ($result) {$msg = "<p>Database has been created</p>";}?>


Create Mysql Database?
How do I make PHP create a database for mysql please?

I can see how to make tables and I have read all the documents
I can find but I don't understand how to make the database itself.

All the tutorials I can find seem to bypass the issue by ignoring it?

Copying From One Mysql Database To Another
Is it possible to open a connection to two separate mysql databases in order to copy the data from one table in the first database into a table in the second database? I'm assuming the answer is yes, but I'm confused as to the proper php syntax.

Pictures Into A MySQL Database
I need to put pictures in to a MySQL -database with PHP and also be able to view them on a web page with PHP.

How I Setup My Mysql Database(s)...
Quick question on how I setup my mysql database(s)...

If my setup is such that I have multiple clients, and each client gets
10 tables to store their data, is it better for performance if I put all
of these tables into 1 large database (with a unique identifier
prepended to each one) or create a separate database for each client?
i.e., assuming 1000 clients, I either would have:

A) 1 database and 10,000 tables in it, 10,000 total tables

B) 1000 databases with 10 tables in each, 10,000 total tables

Intuition tells me that the multiple databases would be better for
isolating data between clients, but I am not sure if this would slow
things down.

All the info I found on this online was inconclusive and mostly was
people speculating, so I hoped you all could help more.

MySQL Country Database
Is there anyone out there willing to donate their country table fora web database. I have been looking all over for a sql script to create a country table populated with recent data, but I just can't seem to find one. People must do this ALL the time.

Parsing PHP From A MySQL Database
i am creating a CMS and i have a setup so you can add sections and they get stored in a db then you can call them with index.php/section. however this doesn't work right if you have PHP in the content of the section. the PHP code shows up instead of getting parsed.
PHP Code:

PHP/MySQL Bugs Database
Anyone know of a good, cheap PHP/MySQL bugs database around?
$100 kind of range.

MySQL Busiest Database
Is there a way (perhaps by using PhpMyAdmin?) to see which MySQL database is
getting the most queries on a server?

XML Datas To MySQL Database
Where to find a comprehensive document on how take datas from XML and put
them in a Mysql Database.
I've many sites sending us XML files. We have to parse datas and save those
datas on Mysql.

The problem is that we have many different file format (each company sends
us it's own XML structure).

How to provide a simple way to get those datas in Mysql, without having to
create a new PHP script for every new site's XML ?

Poll Without A MySQL Database
I'm trying to create a poll that uses a simple *.txt file as a "database". And I'm wondering how to do the following things:

1) How to open the *.txt file;
2) How to list each answer-option;
3) How to add 1 to the selected asnwer-option;
4) How to save the data to the *.txt again;
5) How to close the file.

XML Feed From Mysql Database With PHP
I'm finding myself with the task of writing a php script to automatically compile an XML feed with some standard tags and some tags with data taken from a MySql database.

How Often Do I Need To Connect To MySQL Database?
At present at the top of each of my php pages I reconnect to my
database

mysql_connect(...);

is that actually necessary/good practice. Isn't there something about
persistent connections.

MySQL Database Backup
I'm looking at using PHP and MySQL for a particular website application.
However, I was a bit concerned that if a PHP script went wrong then it would
be possible to accidentally delete or overwrite large chunks of the data in
the database which presumably would then be lost. What is the usual
procedure for these situations?. Is it possible to back up a database
somehow so that data from a previous time can be retrieved?.

Changing A Row In A Mysql Database
I was just wondering, once you have a row in a certain column set....how do you change it with php for example i have a column named "cookie_hash" in my table...when the user logs in i want to update it every time with an md5 hash of their email and login time..I just dont know how to do so

I have this part $hash= md5($email.date ("l dS of F Y h:i:s A")); But I just dont know how to do the query.

Backup MySQL Database
How does one go about using cron jobs to create a MySQL database dump each evening?

I have cPanel with my hosting and when i go to cron jobs i have a 'Command to run:

Getting Results From MySQL Database In PHP
I am trying to write a php page which connects to a MySQL
Database which is supposed to get the results from a table within a
database and display the results in a table.

Below is the code that I am using:

Images In MySQL Database.
I really do not want to put images in my database, but I want to be able to have a script where users can upload an image, and it will be stored in a database (the file name, name of owner, and the trick performed). Then it will be placed in a gallery.


Copyright © 2005-08 www.BigResource.com, All rights reserved