Jump to content


Photo

Row builder for inventory


  • Please log in to reply
3 replies to this topic

#1 MrRay

MrRay
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationOtis, MA

Posted 14 June 2006 - 07:21 PM

Well, most of the problems I had in the past have been overcome. Currently I have been trying to learn LAMP (linux, apache, mysql, php) based webdesign on my free time and I am going pretty slow in my progress. I am making an antique site for a friend/boss of mine and I have a question about how to do something.


We have the site:

+-------------------------------+
|the site!.............................|
+-------------------------------+
|.menu ..............................|
+-------------------------------+
|+-----------------------------+|
||content_window...............||
||-----float left row-----------||
|| +---+.+---+.+---+.+---+ ||
|| |pic |..|pic |...|pic |.| pic| ||
|| |txt |..| txt|...|txt |..|txt | ||
|| +---+.+---+.+---+.+---+ ||
||------------------------------||
|+-----------------------------+|
+-------------------------------+

so if i made it good enough to read, i have 4 boxes w/ pictures and descriptions of items in a row to prevent overflowing when i float them left, and I want my mysql database to have stuff like the item no and stuff like that that i already pretty much have a good idea of. The thing I am having a little bit of confusion with is the php. I want it to check if it there is any results, if there are---it will make a row for 4 boxes w/ descriptions and pics and then close the row make a new one and start over. I need some guidance cause I am a little new to this.

If anyone could help I can not express how much I would appreciate it. I would try it on my own, but I want to see if any of you guys could give me a push in the right direction at least so I save a little time. I am using and CSS w/ XHTML strict rules for the setup. If I HAVE TO, I might cave and use tables..but I rather not... Any help would do

THX

Ray
--------------------------------------------
BTW: I graduated--wooot woot

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 14 June 2006 - 10:39 PM

Something like
<html>
<head>
<meta name="generator" content="PhpED Version 4.5 (Build 4513)">
<title>Sample</title>
<meta name="author" content="Barand">
<link rel="shortcut icon"  href="">
<STYLE type="text/css">
div.pic {
    float: left;
    border: 1px solid silver;
    width: 150px;
    margin: 5px 0 0 5px;
    padding: 5px;
    text-align: center;
}
br {
    clear: both;
}
</STYLE>
</head>
<body>

<?php
mysql_connect('localhost', '*****', '*****');
mysql_select_db('dbname');

$sql = "SELECT imagefile, description
        FROM inventory
        ORDER BY area, locname";
$res = mysql_query($sql) or die(mysql_error());

$count = 0;
while (list ($i, $d) = mysql_fetch_row($res)) {
     echo "<div class='pic'><img src='$i'><br/>$d</div>\n";
     if (++$count % 4 == 0) {
         echo "<br/>\n";
     }
} 
echo "<br/>\n";
?>

</body>
</html>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 MrRay

MrRay
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationOtis, MA

Posted 15 June 2006 - 08:50 PM

yea thats almost what I am looking for, it definitely has the concept. I was thinking of using a while loop, but I wasn't sure how to implement it. I'll reply again w/ the site code after I clean it up a bit more for the recent revision I've been doing--the one I have now is about 4 versions old so gimme a sec to do updates to it and then we can go from there, I really have to thank you for this I was lost w/ this at first.

#4 MrRay

MrRay
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationOtis, MA

Posted 16 June 2006 - 03:49 PM

[!--quoteo(post=384365:date=Jun 15 2006, 04:50 PM:name=theCrandallSter)--][div class=\'quotetop\']QUOTE(theCrandallSter @ Jun 15 2006, 04:50 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
yea thats almost what I am looking for, it definitely has the concept. I was thinking of using a while loop, but I wasn't sure how to implement it. I'll reply again w/ the site code after I clean it up a bit more for the recent revision I've been doing--the one I have now is about 4 versions old so gimme a sec to do updates to it and then we can go from there, I really have to thank you for this I was lost w/ this at first.
[/quote]
I changed a bit and added the extra parts in and got it to work, so I'm good, but I really have to thank you on this :). I am just a newbie, but at some point I wanna get as good as you. I think I'll take PHP when I go to college in the fall.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users