PHP, add record to MySQL data source

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dragon2309
Forum Newbie
Posts: 8
Joined: Sun Oct 30, 2005 8:54 am

PHP, add record to MySQL data source

Post by dragon2309 »

Using a PHP page is it possible to create my own user freindly GUI to add records to my MYSQL database. I currently do this by logging into PHP MY ADMIN and doing lots of stuff in there. Sometimes i use MySQL Control Center.

Any help would be much appreciated...

Code:

Code: Select all

<?php include "dbinfo.php";

// Connect to MySQL DBMS
 if (!($connection = @ mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD)))
showerror();

// Use the simplytruedb database
 if (!mysql_select_db(DB_DATABASENAME, $connection)) showerror();

// Create SQL statement
$query = "SELECT *
FROM `ad_set`
WHERE StockCount > 0";

// Execute SQL statement
if (!($result = @ mysql_query ($query, $connection))) showerror();

// Display results

while ($row = @ mysql_fetch_array($result)) echo "
<tr><td>{$row["StockCode"]}</td> 
<td>{$row["Description"]}</td> 
<td>{$row["Price"]}</td>
<td><img src='{$row["IMG"]}'></img></td>
<td><center><a href='{$row["URL"]}'>$row[url]</a></center></td>
</tr>"; ?>

Thats a part of the php page that returns the records from selected query arguments. Seeing as i have the database username and password stored in

Code:

Code: Select all

include "dbinfo.php";

Thanks, dragon2309 :-)
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

Sure you can as you can see with phpmyadmin that is completely written in php and javascript.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

what exactally do you want to do? if you just wanna add a record into a table then just have a html form that posts data to a php page where you insert it into the table with a mysql query. if you want to rewrite phpmyadmin i would not recommend it. be a little more specific please
dragon2309
Forum Newbie
Posts: 8
Joined: Sun Oct 30, 2005 8:54 am

Post by dragon2309 »

Basically, i want a page whether it be written in HTML or PHP, that you can choose from drop down menus which table to put the record into, then submit it to the database table.

I dont want to re-write phpmyadmin or anything big like that.

Can anyone give an example please??
Post Reply