Nick_W

msg:1261310 | 4:19 pm on May 21, 2002 (gmt 0) |
Hi there! First up, the php has nothing at all to do with 'design'. Just plain old html will handle that, your script is probably returning a set of variables (containers for information) and printing them to the screen with no formatting. if one of you fields is say, 'first_name' then try this: <? print("<p>".$first_name."</p>"); ?> Some cool places are: www.php.net // the best ever www.devshed.com www.phpbuilder.com www.onlamp.com If you still have trouble, post the script and I'll use it to show you in more detail. Regards Nick
|
brotherhood of LAN

msg:1261311 | 4:30 pm on May 21, 2002 (gmt 0) |
Nick, I guess thats what I was aiming at....its hard to see in a dark place ;) Many thanks I'll look into them and see how snazzy I can get the design with PHP before it all falls apart :)
|
lorax

msg:1261312 | 5:45 pm on May 21, 2002 (gmt 0) |
Hey bhol, You may want to check out [phpbuilder.com...] This should get you closer.
|
ergophobe

msg:1261313 | 6:00 pm on May 21, 2002 (gmt 0) |
BoL, If you want a quick and dirty method, Madcat asked roughly the same question a while back. I posted an answer which killed the thread (it's currently the last post), so it must have been enough to either answer the question or drive everyone away... [webmasterworld.com...] Anyway, it's meant to get someone started. If you want to do it *right*, that's another matter and, in addition to the resources that Nick mentioned, I would suggest some specifics like: [zend.com...] Most of the articles at [zend.com...] especially [zend.com...] [zend.com...]
|
brotherhood of LAN

msg:1261314 | 11:37 pm on May 21, 2002 (gmt 0) |
Thanks for all the help folks, its much appreciated This is the current "state" for what is meant to be a future biz directory $result = mysql_query("SELECT `name`,`address`,`postcode`,`telephone`,`fax`,`url`,`info` FROM `businesses` WHERE 1 AND `townid` = 1 AND `name` LIKE 'a%' LIMIT 0, 10", $connection); // Fetch each row of the results into an array $row while ($row = mysql_fetch_array($result)) { print("<p>"$name"</p>"); print("<p>"$address"</p>"); print("<p>"$postcode"</p>"); print("<p>"$telephone"</p>"); print("<p>"$fax"</p>"); print("<p>"$url"</p>"); print("<p>"$info"</p>"); } The query is where "1" is a town and another "1" is a category (they are in another table and are used to minimise repeating data) part of my primitive design layout is a 3 column layout....2 at 40% and one at 20% for navigation. The way the PHP currently stands, all results "fall" into one cell and are displayed downwards...according to the law of gravity Perhaps I want #1 result to be in left cell, #2 in right #3 below left and so on..... Is this easily done with PHP? :) Also, is the above code "OK"?
|
lorax

msg:1261315 | 1:02 am on May 22, 2002 (gmt 0) |
Hello BOL, It is easily done. You just need to bare in mind that your results will come out in the form of a loop. You're code would be something like: <?php while ($row = mysql_fetch_array($result)) { echo "<p><table>"; echo "<tr><td>".$row[0]."</td>"; echo "<td>".$row[1]."</td></tr>"; echo "<tr><td>".$row[2]."</td>"; echo "<td>".$row[3]."</td></tr>"; echo "<tr><td>".$row[4]."</td>"; echo "<td>".$row[5]."</td></tr>"; echo "<tr><td colspan=\"2\">".$row[6]."</td></tr>"; echo "</table></p>"; } ?> This will spit out 1 table of 4 rows for each complete record and then repeat the pattern for the next record. I modified your code somewhat. I prefer to use echo over print and I use concantenation to connect strings and variables - a good habit (IMO) to get into for it will help you when you get into the hot and heavy of string manipulation. The biggest change I made is that of the variables. Note that I'm calling for the content based on it's position within the array rather than by name. The reason is you haven't defined the key (the pointer to the data) with a name so the array only knows each position by the key value [0] for first position of the current record = $name, [1] for the second position = $address, etc... HTIWYLF GB
|
brotherhood of LAN

msg:1261316 | 1:15 am on May 22, 2002 (gmt 0) |
The only bit i didnt understand was the HTIWYLF bit ;) yeah this is like my 4th day using PHP/mySQL so its a little fresh and new. next on the agenda is 1)piecing together a form to query various aspects of the index 2)finding out more about relational db's using mysql 3)creating the "next 10 results" button and such like all new to me, will get there!
|
lorax

msg:1261317 | 1:43 am on May 22, 2002 (gmt 0) |
Hope This Is What You're Looking For. It appears to me you've got a pretty good start. Re: next 10 results - check out [phpbuilder.com...] for a good tutorial on limiting your results display but also building the navigation for "the next 10 results".
|
ergophobe

msg:1261318 | 8:44 pm on May 22, 2002 (gmt 0) |
Just a quick heads up - if you are using LIMIT (which you are) with an ORDER BY clause (which you aren't but might want to), MySQL will return the first ten rows, and *then* order them. This is important to keep in mind when working on split lists. Cheers, Tom
|
brotherhood of LAN

msg:1261319 | 8:52 pm on May 22, 2002 (gmt 0) |
Still here, plugging away. Now, basically, I dont see why everything on the site should be called from a database So im just working out a template for the "true" db results to be situated within. Sorta gonna have to look into CSS a bit deeper to make sure this code is as light as possible......while at the same time digging deeper with PHP/mySQL Now that Ive got the basics, (this thread is a good beginners guide!!) it looks like im going to have to read up and go along trial and error......on the learning curve Thanks all for the help
|
ergophobe

msg:1261320 | 11:37 pm on May 22, 2002 (gmt 0) |
I agree. If you have pages that are mostly static text/images, why not just have a static file? The key is that everything that controls macro layout should be created outside the "content" include files. That way you can completely redesign your site without changing individual files. The big disadvantage to storing the pages in the DB is that you have to worry more about having control characters and quotes and so forth in your text and it is more difficult to throw in and execute php statements. On a "content" site I think it's easier to do a combination. In order to keep everything straight, I build an "admin" page that lets you associate a file with categories etc etc etc. Basically, I put page titles, keywords and description (for meta) in the DB. The basic content goes in an include file. That seems to work pretty well. On an e-commerce site with lots of products with short descriptions, I would put pretty much everything but images in the DB. Tom
|
lorax

msg:1261321 | 2:43 am on May 23, 2002 (gmt 0) |
You don't need to put everything into a db though there are times when you may want to keep everything in PHP. For example, navigation which remains the same on every page. I know I could have done this with straight SSI but PHP made it so much more elegant AND easier to determine browser type so I could account for the differences in rendering the menus. All in all, though, I think you're on the right track. A mix of static pages is the right approach in many cases. Just because you CAN make it work with PHP & MySQL doesn't mean you should!;) Cheers!
|
sarkye

msg:1261322 | 7:00 am on Jul 15, 2002 (gmt 0) |
hello, i was looking for a way to display mysql query results in a table consisting of three rows and three columns and hit this page... i read lorax's code and it seemed to me that it would simply output a list of tables, each one containing one result and when i tried it that's exactly what I got... am I missing something? thanks in advance
|
sarkye

msg:1261323 | 7:46 am on Jul 15, 2002 (gmt 0) |
think i got it ... if it helps anyone, here it is: $numcols = 3; // how many columns to display $numcolsprinted = 0; // no of columns so far // get the results to be displayed $query = "SELECT * FROM tablename WHERE condition=value ORDER BY whatever DESC LIMIT"; $mysql_result = mysql_query($query, $mysql_link); // get each row while($row = mysql_fetch_row($mysql_result)) { //get columns $id = $row[0]; $foo = $row[1]; $bar = $row[2]; $foobar = $row[3]; if ($numcolsprinted == $numcols) { print "</tr>\n<tr>\n"; $numcolsprinted = 0; } // output row from database print "<td>".$foobar."</td>\n"; // bump up row counter $numcolsprinted++; } // end while loop // push out some cells to even the table out $colstobalance = $numcols - $numcolsprinted; for ($i=1; $i<=$colstobalance; $i++) { print "<TD> </TD>\n"; }
|
lorax

msg:1261324 | 1:15 pm on Jul 15, 2002 (gmt 0) |
Nope, you weren't missing anything. I goofed. If you take the <table> tags out of the loop then you'll get a better result - one table with 1 result per row. Thanks for pointing that out.
|
|