Page 1 of 1

PHP, add record to MySQL data source

Posted: Sun Oct 30, 2005 8:59 am
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 :-)

Posted: Sun Oct 30, 2005 9:34 am
by AGISB
Sure you can as you can see with phpmyadmin that is completely written in php and javascript.

Posted: Sun Oct 30, 2005 9:49 am
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

Posted: Sun Oct 30, 2005 9:59 am
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??