|
|
|
|
![]() ![]() |
Mar 7 2005, 07:27 PM
Post
#1
|
|
|
Newbie ![]() Group: Members Posts: 5 Joined: 7-March 05 Member No.: 4,236 |
I am trying to create a page on a site and I cant seem to figure it out
All it is to do is be an ad page, with an admin. to show a picture/logo with a short description of services offered, with the business name linked. I wanted an admin page for my client, who knows less than me. Then to display all info from database. Only the admin can add, or maybe submit with admin approval. If anyone can help me out that would be greatly appreciated.......either with their own code or some code out there somewhere that i canr find Kopy |
|
|
|
Mar 8 2005, 10:00 AM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 113 Joined: 14-January 05 From: Philippines Member No.: 3,271 |
i will help you make a script. please elaborate the whole client area. what data willl be included and the like. i need to know so that i can make make you a script. the script will NOT include ANY html. i will make use of a template system. you are the one who will make the design of the client area.
|
|
|
|
Mar 8 2005, 10:30 AM
Post
#3
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 119 Joined: 12-July 04 From: london Member No.: 85 |
for mysql i'd suggest strongly that you go get a mysql class, try phpclasses.org and look for mysql classes, its quite easier dealing with objects than it is dealing with functions. infact nowadays everything i code is all oop .. you should give it a try go check out the site..
|
|
|
|
Mar 8 2005, 11:34 AM
Post
#4
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 113 Joined: 14-January 05 From: Philippines Member No.: 3,271 |
i'll share my class. if ever it will be used, please do not remove the heading which shows that i made it.
here are the constants used. CODE define('BEGIN_TRANSACTION', 1); define('END_TRANSACTION', 2); the mysql class itself CODE /***************************************************************************
* MySQL Class * ------------------- * Created : Tuesday, Mar 11, 2003 * Copyright : (C) 2003 ENIGMA Designs - PHPBIT * Email : support@3nigma.com * * * * ***************************************************************************/ class db { var $db_connect_id; var $query_result; var $row = array(); var $rowset = array(); var $num_queries = 0; var $in_transaction = 0; function db ($server, $username, $password, $database, $persistence = false) { $this->server = $server; $this->username = $username; $this->password = $password; $this->database = $database; $this->persistence = $persistence; $this->db_connect_id = ($this->persistence) ? mysql_pconnect($server, $username, $password) : mysql_connect($server, $username, $password); if ($this->db_connect_id) { if ($database != "") { mysql_select_db($this->database); } else { return false; } return $this->db_connect_id; } else { return false; } } function close () { if ($this->db_connect_id) { if ($this->in_transaction) { mysql_query("COMMIT", $this->db_connect_id); } return mysql_close($this->db_connect_id); } else { return false; } } function query ($query = "", $transaction = false) { unset($this->query_result); if ($query != "") { $this->num_queries++; if ($transaction == BEGIN_TRANSACTION && !$this->in_transaction) { if (!mysql_query("BEGIN", $this->cb_connect_id)) { return false; } $this->in_transaction = true; } $this->query_result = mysql_query($query, $this->db_connect_id); } else { if ($transaction == END_TRANSACTION && $this->in_transaction) { $this->in_transaction = false; if (!mysql_query("COMMIT", $this->db_connect_id)) { mysql_query("ROLLBACK", $this->db_connect_id); return false; } } } if ($this->query_result) { unset($this->row[$this->query_result]); unset($this->rowset[$this->query_result]); if ($transaction == END_TRANSACTION && $this->in_transaction) { $this->in_transaction = false; if (!mysql_query("COMMIT", $this->db_connect_id)) { mysql_query("ROLLBACK", $this->db_connect_id); return false; } } return $this->query_result; } else { if ($this->in_transaction) { mysql_query("ROLLBACK", $this->db_connect_id); $this->in_transaction = false; } return false; } } function numrows ($query_id = 0) { if (!$query_id) { $query_id = $this->query_result; } return ($query_id) ? mysql_num_rows($query_id) : false; } function affectedrows () { return ($this->db_connect_id) ? mysql_affected_rows($this->db_connect_id) : false; } function numfields ($query_id = 0) { if (!$query_id) { $query_id = $this->query_result; } return ($query_id) ? mysql_num_fields($query_id) : false; } function fieldname ($query_id = 0, $offset) { if (!$query_id) { $query_id = $this->query_result; } return ($query_id) ? mysql_field_name($query_id, $offset) : false; } function fieldtype ($query_id = 0, $offset) { if (!$query_id) { $query_id = $this->query_result; } return ($query_id) ? mysql_field_type($query_id, $offset) : false; } function fetchrow ($query_id = 0) { if (!$query_id) { $query_id = $this->query_result; } if ($query_id) { $this->row[$query_id] = mysql_fetch_array($query_id, MYSQL_ASSOC); return $this->row[$query_id]; } else { return false; } } function fetchrowset ($query_id = 0) { if (!$query_id) { $query_id = $this->query_result; } if ($query_id) { unset($this->rowset[$query_id]); unset($this->row[$query_id]); while($this->rowset[$query_id] = mysql_fetch_array($query_id, MYSQL_ASSOC)) { $result[] = $this->rowset[$query_id]; } return $result; } else { return false; } } function fetchfield ($query_id = 0, $rownum = -1, $field) { if (!$query_id) { $query_id = $this->query_result; } if ($query_id) { if ($rownum > -1) { $result = mysql_result($query_id, $rownum, $field); } else { if (empty($this->row[$query_id]) && empty($this->rowset[$query_id])) { if ($this->fetchrow()) { $result = $this->row[$query_id][$field]; } else { if ($this->rowset[$query_id]) { $result = $this->rowset[$query_id][$field]; } else if ($this->row[$query_id]) { $result = $this->row[$query_id][$field]; } } } } return $result; } else { return false; } } function rowseek ($query_id = 0, $rownum) { if (!$query_id) { $query_id = $this->query_result; } return ($query_id) ? mysql_data_seek($query_id, $rownum) : false; } function nextid () { return ($this->db_connect_id) ? mysql_insert_id($this->db_connect_id) : false; } function freeresult ($query_id = 0) { if (!$query_id) { $query_id = $this->query_result; } if ($query_id) { unset($this->row[$query_id]); unset($this->rowset[$query_id]); mysql_free_result($query_id); return true; } else { return false; } } function error () { $result['message'] = mysql_error($this->db_connect_id); $result['code'] = mysql_errno($this->db_connect_id); return $result; } } |
|
|
|
Mar 8 2005, 07:34 PM
Post
#5
|
|
|
Newbie ![]() Group: Members Posts: 5 Joined: 7-March 05 Member No.: 4,236 |
basically this is the layout
to have a picture or logo <BR> Business name (linked to website or mailto) <BR> Brief description about services offered. <BR><HR> then the list goes on....... if it could be creatde so there is a "page of liinks" so on my template i can <? include ("filename.php") ?> As for the admin, just a simple form (no templating required) that he can enter in the data of the new link Business name: " " http/mailto " " Description " " Upload "Browse" then all the info will be extracted onto this "filename.php" page and will be called when included in my template "links.php" Thanks Kopythat |
|
|
|
Mar 8 2005, 09:22 PM
Post
#6
|
|
|
Owner of Sub-Zero ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 159 Joined: 17-November 04 Member No.: 2,325 |
Hmm..
I could probably do one but mine would include HTML... [CODE]SQL CREATE TABLE `businesses` ( `id` int(10) NOT NULL auto_increment, `business` varchar(255) NOT NULL default '', `description` text NOT NULL default '', `emailaddress` varchar(255) NOT NULL default '', PRIMARY KEY(`id`) ) TYPE=MyISAM; PHP/HTML <html> <head> <title>Businesses</title> </head> <body> <center> <table border=".01" align="center"> <tr bgcolor="#D0D0D0"> <td><b>ID</b></td> <td><b>Business</b></td> </tr> <?php $query=mysql_query("SELECT id,business FROM businesses ORDER BY id ASC"); while($row=mysql_fetch_row($query)) echo '<tr bgcolor="#E0E0E0"><td><a href="http://YOURSITELINK.com/show_business.php?business='.$row[0].'">'.$row[0].'</a></td><td>'.$row[1].'</td></tr></table>'; ?> </body> </html> --SAVE AS businesses.php-- PHP/HTML FOR show_business.php <?php $business = $_GET['business']; ?> <html> <head> <title>Show Business</title> </head> <body> <table border=".01"> <tr bgcolor="#D0D0D0"> <td><B>Business</b></td> <td><b>Description</b></td> <td><b>E-Mail Address</b></td> </tr> <?php $query=mysql_query("SELECT business,description,emailaddress FROM businesses WHERE id='$business'"); while($row=mysql_fetch_row($query)) echo '<tr bgcolor="#E0E0E0"><td>'.$row[0].'</td><td>'.$row[1].'</td><td><a href="mailto:'.$row[2].'">'.$row[2].'</a></td></tr></table>'; ?> </body> </html> --SAVE AS show_business.php-- --PHP FOR new_business.php-- <html> <head> <title>New Business</title> </head> <body> <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <table border=".01" align="center"> <tr> <td><B>Business Name:</b></td> <td><input type="text" name="business_name" /></td> </tr> <tr> <td><b>Business Description:</b></td> <td><textarea name="business_desc" rows="15" cols="20"></textarea></td> </tr> <tr> <td><b>E-Mail Address:</b></td> <td><input type="text" name="business_email" /></td> </tr> <tr> <td><input type="submit" name="add" value="Add!" /></td> <td><input type="reset" value="Reset" /></td> </tr> </table> </form> <?php if(isset($_POST['add'])) { mysql_query("INSERT INTO businesses SET business='{$_POST['business_name']}',description='{$_POST['business_desc']}',emailaddress='{$_POST['business_email']}'") or die(mysql_error()); echo '<tr bgcolor="red"><td><b>Business added.</b></td></tr>'; } else { echo ''; } ?> </body> </html> --SAVE AS new_business.php-- |
|
|
|
Mar 9 2005, 06:59 AM
Post
#7
|
|
|
Newbie ![]() Group: Members Posts: 5 Joined: 7-March 05 Member No.: 4,236 |
Thanks for the code Mike.....it works well
I have made a few changes as per formating, it does everything that i want it to do Now I need to add a picture or logo upload (mysql and php portion) but the image must be less than 400 pixels wide and 200 pixels in hieght and added to the new_business.php form........If you could help me out with that it would be greatly appreciated. Here are the modifications I have made to the code MYSQL CREATE TABLE `businesses` ( `id` int(10) NOT NULL auto_increment, `business` varchar(255) NOT NULL default '', `description` text NOT NULL default '', `emailaddress` varchar(255) NOT NULL default '', `website` varchar(255) NOT NULL default '', PRIMARY KEY(`id`) ) TYPE=MyISAM; new_business.php (added website) <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <table border=".01" align="center"> <tr> <td><B>Business Name:</b></td> <td><input type="text" name="business_name" /></td> </tr> <tr> <td><b>Business Description:</b></td> <td><textarea name="business_desc" rows="15" cols="20"></textarea></td> </tr> <tr> <td><b>E-Mail Address:</b></td> <td><input type="text" name="business_email" /></td> </tr> <tr> <td><B>Website:</b></td> <td><input name="business_website" type="text" /></td> </tr> <tr> <td><input type="submit" name="add" value="Add!" /></td> <td><input type="reset" value="Reset" /></td> </tr> </table> </form> <?php if(isset($_POST['add'])) { mysql_query("INSERT INTO businesses SET business='{$_POST['business_name']}',description='{$_POST['business_desc']}',emailaddress='{$_POST['business_email']}',website='{$_POST['business_website']}'") or die(mysql_error()); echo '<tr bgcolor="red"><td><b>Business added.</b></td></tr>'; } else { echo ''; } ?> </body> </html> show_business.php (changed table and text formating and showed all businesses on same page) <?php $query=mysql_query("SELECT business,description,emailaddress, website FROM businesses "); while($row=mysql_fetch_row($query)) echo '<table width="495"><tr><TD><div align="center"><strong>'.$row[0].'</strong></div><BR></td></TR><TR><td><div align="center">'.$row[1].'</div></td></TR><TR><td><div align="center"><a href="mailto:'.$row[2].'">'.$row[2].'</a><BR></div></td></TR><TR><TD><div align="center"><a href="http://'.$row[3].'">'.$row[3].'</div></td></tr></table><HR width="400">'; ?> business.php (no changes) Didnt need Thanks again in advance Kopythat |
|
|
|
![]() |