Go Back   Cyber Tech Help Support Forums > Software > Web Development & Graphic Design

Notices

Reply
 
Topic Tools
  #1  
Old August 3rd, 2006, 04:04 PM
jackfusion jackfusion is offline
New Member
 
Join Date: Aug 2006
Posts: 1
help with php gui

Hello all

I thing this is going to be very complex.

I have a Some PHP and HTML files I would like to put together but, there is things that need to happen. I forgot the MySQL database set up. I will first post the script and code for the PHP and HTML.

PHP Script

PHP Code:
1 <html>
2 <head>
3 <title>Getting Data out of the Database</title>
4 </head>
5 <body bgcolor="#FFFFFF">
6 <h1>The Daily News</h1>
7 <!-- Order news by 
8 <a href="chapter7/chapter7/data_out.php3?orderby=date">Date</a>, 
9 <a href="chapter7/chapter7/data_out.php3?orderby=heading">Heading</a> or by 
10 <a href="chapter7/chapter7/data_out.php3?orderby=author">Author</a>. -->
11 <p>
12 <form action="list_out.php" method="POST">
13 Search:
14 <input type="text" name="Title"> 
15 <input type="submit" name="submit" value="Submit!">
16 </form>
17 <table border="1" cellpadding="3">
18 <?php
19 
/* This program gets news items from the database */
20 $db mysql_connect("localhost""root""c705m5p");
21 mysql_select_db("php"$db);
22 /* if ($orderby == 'date'):
23 $sql = "select * from news order by 'date'";
24 elseif ($orderby == 'author'):
25 $sql = "select * from news order by 'author_name'";
26 elseif ($orderby == 'heading'):
27 $sql = "select * from news order by 'heading'";
28 else
29 else: */
30 if (isset($submit)):
31 $sql "select * from list where Title = '$Title'";
32 endif; 
33 $sql "select * from list";
34 $result mysql_query($sql);
35 while ($row mysql_fetch_array($result)) {
36 print("<tr><td bgcolor=\"#003399\"><b>");
37 printf("<font color=\"white\">%s</font></b></td></tr>\n"
38 $row["heading"]);
39 printf("<td>By: <a href=\"mailto:%s\">%s</a>\n"
40 $row["author_email"], $row["author_name"]);
41 printf("<br>Posted: %s<hr>\n"
42 $row["date"]);
43 printf("%s</td></tr>\n"
44 $row["body"]);
45 }
46 ?>
47 </table>
48 </body>
49 </html>
HTML Code

Code:
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5 <title>Untitled Document</title>
6 	
7 	<style type="text/css">
8 
9 	body {
10 		behavior:url("csshover.htc");
11 	}
12	
13	* {
14		font-family:arial,tahoma,verdana,helvetica;
15		font-size:12px;
16	}
17
18	/* the menu */
19
20	ul,li,a {
21		display:block;
22		margin:0;
23		padding:0;
24		border:0;
25	}
26
27	ul {
28		width:250px;
29		border:1px solid #9d9da1;
30		background:white;
31		list-style:none;
32	}
33
34	li {
35		position:relative;
36		padding:1px;
37		z-index:9;
38	}		
39		li.folder ul {
40			position:absolute;
41			width: 160px;
42			left:250px; /* IE */
43			top:5px;
44		}
45		div#descrip
46		{
47			left:
48		}		
49			li.folder>ul { left:250px; } /* others */
50
51	a {
52		padding:2px;
53		border:1px solid white;
54		text-decoration:none;
55		color:gray;
56		font-weight:bold;
57		width:100%; /* IE */
58	}
59		li>a { width:auto; } /* others */
60
61	/* regular hovers */
62
63	a:hover {
64		border-color:gray;
65		background-color:#bbb7c7;
66		color:black;
67	}
68		li.folder a:hover {
69			background-color:#bbb7c7;
70		}
71	
72	/* hovers with specificity */
73	
74	li.folder:hover { z-index:10; }		
75		
76	ul ul, li:hover ul ul {
77		display:none;
78	}
79
80	li:hover ul, li:hover li:hover ul {
81		display:block;
82	}		
83
84	</style>
85
86 </head>
87
88 <body>
89	<ul id="menu">
90		<li class="folder">			
91		<a href="#" class="submenu"></a></li>
92	      <ul>
93	        <li class="folder">&nbsp;&nbsp;See: </li>
94		      <li class="folder">
95			      &nbsp;&nbsp;Paper:  <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;See Reference</li>
96		      <li class="folder">
97			      &nbsp;&nbsp;Paper: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;See Reference</li>
98		      <li class="folder">
99			      <a href="">Online catalogue</a></li>
100		      <li class="folder">		
101			      <a href="">Full text – Online - Infotrac</a></li>
102		      <li class="folder">		
103			      <a href="">Full text – Online - CBCA</a></li>
104		      <li class="folder">&nbsp;&nbsp;Absorbed:  <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;See Reference</li>
105		      <li class="folder">&nbsp;&nbsp;ISSN: </li>
106     </ul>
107   </li>
108	</ul>
109
110 </body>
111 </html>
The MySQL heading columns are Title, See, Page 1, Page 2, Page 3, Online Catalogue, Full Text - Online - Infotrax, Full Text - Online - CBCA, CBCA Dates, Absorbed, Microfilm, ISSN and Electronic.

What I would like to do is turn the HTML into PHP without changing the layout. I think I know a little about it where it says (on line 38 in the PHP script) $row["heading"]); I would change heading with Title and where I see $row [""]); I would put the right column name.

Here is going the be the hard part I would the script to search the different records and put the right formatting in place from the HTML code. EX: If the script search and finds See then it will only show that in the submenu or if the script find page2 online catalogue then it would only display page 2 format and online catalogue.
Reply With Quote
  #2  
Old August 3rd, 2006, 06:31 PM
Sirkent Sirkent is offline
New Member
 
Join Date: Aug 2006
O/S: Linux
Posts: 24
The best way to do this would be to use a template engine, such as Smarty. Smarty allows you to have one file with HTML and simple placeholders where you want your dynamic information to go. You simply write your PHP code as you normally would, then you call Smarty and tell it to map the values to your HTML file.

http://smarty.php.net/

Have a look - there's plenty of documentation and help on the Smarty website to get you started and it'll help you with any future projects.
Reply With Quote
Reply

Bookmarks

Topic Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:12 PM.

[ RSS ]