Titan85
12-26-2006, 09:42 PM
Hello, i am working on a script that will take info from a form and input it into a mysql database for later use. I am looking to make it so that I can search for the title or description and it will return the corresponding data. I know how to make forms and process them in PHP, but I am not sure on how to use MySQL to hold the data because I have only used .txt files in the past.
I believe the first step is to create the mysql columns like this:
CREATE TABLE `job_recorder` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`job_title` varchar(20) NOT NULL default '',
`client_email` varchar(20) NOT NULL default '',
`client_name` varchar(20) NOT NULL default '',
`description` varchar(20) NOT NULL default '',
`price` varchar(20) NOT NULL default '',
) ENGINE=MyISAM ; If anything in there is wrong, i would appreciate someone letting me know ;) .
The next step should be to insert the data into the database like this:
INSERT INTO `job_recorder` VALUES (1, '$job_title', '$client_email', '$client_name', '$description', '$price',
'');Correct?
And to call it up again I would do:
<?php
$query = mysql_query("SELECT * FROM `site_config`");
while ($get = mysql_fetch_array($query))
{
echo '<title>$get[job_title]</title>';
echo 'Email: $get[client_email]';
echo 'Name: $get[client_name]';
echo 'Description: $get[description]';
echo 'Price: $get[price]';
}
?> Correct?
I guess this kinda turned out to be just me needing verification on if my ideas are right or not. But i do have a few questions, if I run this more than once, will it insert a second entry so that I can call that one too? Also, how might I go about searching for a certain entry?
I believe the first step is to create the mysql columns like this:
CREATE TABLE `job_recorder` (
`id` mediumint(8) unsigned NOT NULL auto_increment,
`job_title` varchar(20) NOT NULL default '',
`client_email` varchar(20) NOT NULL default '',
`client_name` varchar(20) NOT NULL default '',
`description` varchar(20) NOT NULL default '',
`price` varchar(20) NOT NULL default '',
) ENGINE=MyISAM ; If anything in there is wrong, i would appreciate someone letting me know ;) .
The next step should be to insert the data into the database like this:
INSERT INTO `job_recorder` VALUES (1, '$job_title', '$client_email', '$client_name', '$description', '$price',
'');Correct?
And to call it up again I would do:
<?php
$query = mysql_query("SELECT * FROM `site_config`");
while ($get = mysql_fetch_array($query))
{
echo '<title>$get[job_title]</title>';
echo 'Email: $get[client_email]';
echo 'Name: $get[client_name]';
echo 'Description: $get[description]';
echo 'Price: $get[price]';
}
?> Correct?
I guess this kinda turned out to be just me needing verification on if my ideas are right or not. But i do have a few questions, if I run this more than once, will it insert a second entry so that I can call that one too? Also, how might I go about searching for a certain entry?