Jump to content

My sql.


glennk

Recommended Posts

Hi,

 

Im knocking up a catch report package for my website (or having a bash at it). I have made a form for submitting the data to. Now I want to display it on a reports page. This is where I am getting confused. Infact Im clueless.

 

1. Can I just send the input data to a new page and display it ?

 

2. Things are never as easy as my question 1. I think I have to store the data using mysql ? Write or wrong ?

 

3. If I need Mysql how do I get it ? Do most servers have it installed ? if not do I download it from Mysql website then upload it to my server ? How do I do this ?

 

I think thats enough questions for now. There will definately be more questions soon.

 

Your thoughts on what Im getting into would be interesting to hear. Am I taking to much on ?

Link to comment
Share on other sites

If you have cpanel then you "should" have mysql as standard.

 

post-903-1154552673_thumb.jpg

 

You`ll need to change the way your form adds data so that it gets inserted into the database.

 

eg:

 

add.html

 

<form name="addart" enctype="multipart/form-data" action="process.php" method="post"> 
 <table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#000066" width="100%" cellpadding="5" align="center"> 
   <tr> 
     <td width="100%" colspan="3" class="maintitle"><div align="center"><strong>Articles will not show up until a member of staff has checked and edited if necessary.</strong> </div></td> 
   </tr> 
   <tr> 
     <td width="50%"><div align="left"><strong>Your Name</strong></div></td> 
     <td width="50%"><div align="left"> 
         <input name="name" type="text" size=40> 
       </div></td> 
   </tr> 
   <tr> 
     <td width="50%"><div align="left"><strong>Your email (this will remain anonymous)</strong></div></td> 
     <td width="50%"><div align="left"> 
         <input name="email" type="text" size=40> 
       </div></td> 
   </tr> 
   <tr> 
     <td width="50%"><div align="left"><strong>What is the Article Title?</strong> </div></td> 
     <td width="50%"><div align="left"> 
         <input name="title" type="text" size=40> 
       </div></td> 
   </tr> 
   <tr> 
     <td width="50%"><div align="left"><strong>Main Article content</strong></div></td> 
     <td width="50%"><div align="left">
  <textarea name="entry" cols="60" rows="4" wrap="PHYSICAL"></textarea>
  </div></td> 
   </tr> 
   <tr> 
     <td colspan="2" height="25" width="100%" align="center" class="buttonbg"><input type=submit class="button" value="Submit Form">  <input type=reset class="button" value="Reset Form"></td> 
   </tr> 
 </table> 
</form>

 

process.php

 

<?phpinclude ('db_conf.php');if ($new_string == $random){$errors=0;$error="The following errors occured while processing your form input.<ul>";pt_register('POST','name');pt_register('POST','email');pt_register('POST','title');pt_register('POST','entry');if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email))	{$error.="<li>Invalid email address entered";$errors=1;}if($errors==1) 	echo $error;else	{$message="Your Name: ".$name."Your email: ".$email."Title: ".$title."Entry: ".$entry."";$link = mysql_connect($host, $user, $pass);mysql_select_db($base,$link);$query="INSERT INTO table (name,email,title,entry) VALUES ('"$name"','".$email."','"$title"','"$entry"')";mysql_query($query);echo '<br /><strong>Thank You '.$name.' for submitting '.$title.', Pending administrator approval, it will be online shortly.</strong><br /><br />';}?>

 

db_conf.php

 

<?php$host 		= "localhost";  // Usually localhost$user		= "dbuser"; // database username$pass		= "dbpass";  // Database Password$base		= "dbname"; // Database name?>

 

The actualy SQL you`d need for the above would look like this:

 

CREATE TABLE `articles` (
 `id` int(10) unsigned NOT NULL auto_increment,
 `name` text NOT NULL,
 `email` text NOT NULL,
 `title` text NOT NULL,
 `entry` text NOT NULL,
 PRIMARY KEY  (`id`),
 KEY `id` (`id`)
) ENGINE=MyISAM;

 

To call the data you could use:

 

<?phpinclude ('db_conf.php');// Connects to database	  $link = @mysql_connect ($host, $user, $pass) or die (mysql_error());			  /* uh oh we need a database to get our info fromno point having no DB to work from as the script would throw a wobbley and spit errors out left right and center */ if (!@mysql_select_db("$base", $link)) {		 echo "<p>There has been an error. This is the error message:</p>"; 	 echo "<p><strong>" . mysql_error() . "</strong></p>"; 	 echo "Please Contact The System Administrator with the details"; } // Query the database$dbq = 'SELECT * FROM table WHERE id = X'; // where "X" is the thing you want$result = mysql_query ($dbq);while ($row = mysql_fetch_array($result))	{	extract($row);				echo '<table border="1" cellspacing="1" style="border-collapse: collapse" bordercolor="#000066" width="100%" cellpadding="5" align="center">  <tr>	<td><div align="center"><h3>'$title.' '$name.'.</h3></div></td>  </tr>  <tr>	<td>'$entry.'</td>  </tr></table>';?>

}

 

mysql_free_result($result);

mysql_close ($link);

 

?>

 

If you`re still not sure then gimme a shout on msn

 

post-903-1154553767_thumb.jpg

Link to comment
Share on other sites

:o:cry::cry:

 

Its not gonna be easy is it.

 

I am at the very beginning Si.

 

From your answer I guess I need to use mysql but it should already be on the server.

 

This is what I have - Could we start from there. I know no more than this.

 

 

<form action="whitby-fishing-reports.php" method=post>

 

 

 

<p> Name

<br> <input type="text" name="Name">

<p>

 

<p> Venue

(Optional)<br> <input type="text" name="Venue">

<p>

 

<p> Catch

Report<br> <textarea cols="50" rows="4" name="comment"></textarea>

<p>

 

<p> Catch Date

<br> <input type="text" name="Date">

<p>

 

 

 

 

<input type="submit" name="submit" value="Enter My Data!">

</form>

Link to comment
Share on other sites

Whoa. In the style of Keanu Reeves.

 

Long way to go.

 

Have you got your head round exactly how this needs to work? You'll need an input form, true, but you'll also need somewhere to keep your data (MySQL), structures in the database to arrange your data (table(s)), a way of presenting your data, some commands (SQL) to communicate with the database and some glue (php script) to stick it all together. You aren't looking at knocking up a webpage, you're looking at writing a simple database driven application.

 

I think the best thing to do is to step away from your immediate problem and look at a tutorial like this one:

 

http://webmonkey.wired.com/webmonkey/99/21/index2a_page4

 

Get your head round the principles, get a simple app working which will write to and read from a database and then look at designing your system. Basically, you need a very basic working knowledge of:

 

Relational database theory

SQL language

Scripting database access in php

Link to comment
Share on other sites

Thanks for that.

 

I realised how far off I was when si knocked up what he did in a couple of mins and posted it up - I wish I could do that. I guess si works as a programmer ?.

 

Im currently reading this:

 

http://www.w3schools.com/php/php_mysql_intro.asp

 

If it doesnt kill me Ill come back with bits I dont understand.

 

THanks to both of you for your help so far.

Link to comment
Share on other sites

I use dozens of mySQL databases.....and no jack about how it works.

 

I suggest you look for a ready-made package, many of which are free from places like Hotscripts, and use that. That's what I usually do :)

Anglers' Net Shopping Partners - Please Support Your Forum

CLICK HERE for all your Amazon purchases - books, photography equipment, DVD's and more!

CLICK HERE for Go Outdoors. HUGE discounts!

 

FOLLOW ANGLERS' NET ON TWITTER- CLICK HERE - @anglersnet

PLEASE 'LIKE' US ON FACEBOOK - CLICK HERE

Link to comment
Share on other sites

Hi Elton,

 

How easy is it to understand these scripts and alter them for your own usage ?

 

I used a script for a guestbook that Nick kindly gave me. However When I wanted to ammend it and upload it to other sites I came unstuck. I just couldnt figure out how to set it up on the server. I therefore decided it would probably do me good to understand the full process.

 

However I hadn't bargained on it being so damn difficult. My Brain doesn't seem to want to understand. Im reallt annoyed with myself. 20 years ago now I did a 2 year diploma in computing. I learnt quite a bit of programming and used to pick it up with ease. Now it just wont go in. I wish I hadnt let it lapse but I just wasnt interested in computers for 18 of those years, now Ive got the bug again but not the ability it appears.

Link to comment
Share on other sites

Thanks for that.

 

I realised how far off I was when si knocked up what he did in a couple of mins and posted it up - I wish I could do that. I guess si works as a programmer ?.

 

Yes I do a lot of web programming, my whole site is coded from scratch, which is about 300 pages and 5 seperate MySQL databases, I`m also in the middle of writing a few applications which i`m hoping to sell.

 

My msn is above if u need any help Glenn

Link to comment
Share on other sites

  • 2 weeks later...

Hi Just an update.

 

I tried but failed really. Perhaps just too complicated for me. Allthough ill try again in the future. For now I have doctered the guestbook nick gave me and sort of got it working.

 

http://www.whitbyseaanglers.co.uk/guestbook/

 

http://www.whitbyseaanglers.co.uk/catch-reports/

 

However I still have a couple of small problems if anyone can offer some advice.

 

1. the header image only shows in firefox and not IE

 

2. The date in the guestbook doesnt seem to work properly.

 

3. I have put most of the guestbook and catch report in a 740 table. However I cant seem to get the actual posted entries to go into a table. The page wouldnt show when I boxed them in

 

Whilst Im on has anyone heared anything from Nick ? He seems to have dissapeared.

Edited by glennk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We and our partners use cookies on our website to give you the most relevant experience by remembering your preferences, repeat visits and to show you personalised advertisements. By clicking “I Agree”, you consent to the use of ALL the cookies. However, you may visit Cookie Settings to provide a controlled consent.