Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1081 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

displaying data from a database

Thread title: displaying data from a database
Closed Thread    
    Thread tools Search this thread Display Modes  
03-24-2007, 11:43 AM
#1
ali.black is offline ali.black
Status: I'm new around here
Join date: Feb 2007
Location:
Expertise:
Software:
 
Posts: 13
iTrader: 0 / 0%
 

ali.black is on a distinguished road

  Old  displaying data from a database

hello,

i have a website that will list certain shops in my area. i want these shops to be displayed in a table with 4 columns on my website, the first being the name of the shop and when you click on the shop it links you to there website. the rest of the columns will be different images depending on what service they provide. i thought i could create a form that allows me to input the name of the shop etc, but each time i submit the form it adds the information to my database and creates a new row each time i submit a new shop on the table on my website page.

im very new to php and sql so it would be helpful if you could link me to a tutorial that sort of tells you how to do this.

cheers in advance

Ali

04-29-2007, 10:03 PM
#2
duskan is offline duskan
Status: I'm new around here
Join date: Nov 2006
Location:
Expertise:
Software:
 
Posts: 9
iTrader: 0 / 0%
 

duskan is on a distinguished road

  Old

Originally Posted by ali.black View Post
hello,

i have a website that will list certain shops in my area. i want these shops to be displayed in a table with 4 columns on my website, the first being the name of the shop and when you click on the shop it links you to there website. the rest of the columns will be different images depending on what service they provide. i thought i could create a form that allows me to input the name of the shop etc, but each time i submit the form it adds the information to my database and creates a new row each time i submit a new shop on the table on my website page.

im very new to php and sql so it would be helpful if you could link me to a tutorial that sort of tells you how to do this.

cheers in advance

Ali
Could you provide an example.. or link to one?

05-01-2007, 08:58 PM
#3
Dark_Prince11 is offline Dark_Prince11
Status: Member
Join date: Apr 2007
Location: Deer Park, NY
Expertise:
Software:
 
Posts: 123
iTrader: 0 / 0%
 

Dark_Prince11 is on a distinguished road

Send a message via AIM to Dark_Prince11 Send a message via MSN to Dark_Prince11

  Old

This is an entire script basically. I will give a quick rundown.

Code:
<?php
//MySQL Connection
mysql_connect("your host","username","password") or die ('Connect to DB Failed');
mysql_select_db("database name");

//Add A New Row
if($_POST) {
$shopname = $_POST['name'];
$query = mysql_query("INSERT INTO tablename (table_columns)  VALUES ('$shopname',othercolumns)") or die ('Query Failed');
echo 'Added';
}
//Get The Shops
$get = mysql_query("SELECT * FROM tablename ORDER BY id DESC") or die ('Retrieval failed');
?>
<table>
<?php
while ($array = mysql_fetch_array($get)) {?>
<tr>
<td><?=$array['shopname'];?></td>
<?php }?>
</tr>
</table>
<br/>
Add A Shop
<form action="" method="post">
<input type="text">
<input type="submit" value="Add">
</form>
Now that code itself won't work without you replacing the data and is also not that functional since it is only a quick rundown but it gets what you want done...Don't necessarily use this but use it as a base to make your own.... Also, there might be a bug or to since I just typed it up here didn't really test it out but it should work as long as you input everything correctly and fix the HTML tags...

05-01-2007, 10:05 PM
#4
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

I used this incredibly secret tool to find this good tutorial on php and mysql

http://www.freewebmasterhelp.com/tutorials/phpmysql

05-02-2007, 03:01 AM
#5
Dark_Prince11 is offline Dark_Prince11
Status: Member
Join date: Apr 2007
Location: Deer Park, NY
Expertise:
Software:
 
Posts: 123
iTrader: 0 / 0%
 

Dark_Prince11 is on a distinguished road

Send a message via AIM to Dark_Prince11 Send a message via MSN to Dark_Prince11

  Old

Originally Posted by Village Idiot View Post
I used this incredibly secret tool to find this good tutorial on php and mysql

http://www.freewebmasterhelp.com/tutorials/phpmysql
What is this "Google" that you link us to?

05-13-2007, 11:27 AM
#6
allstar is offline allstar
Status: Junior Member
Join date: Apr 2007
Location:
Expertise:
Software:
 
Posts: 30
iTrader: 0 / 0%
 

allstar is on a distinguished road

  Old

mysql INSERT vs Update

Do some research one each of these. Are you trying to add a new row to the sql or are you trying to update each of the listings?

Maybe no insert is needed and just the select the database and show the information on a webpage.

http://www.w3schools.com/sql/sql_intro.asp

Great stuff. I am glad you want to learn.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed