Jump to content

Much needed help


crazy8

Recommended Posts

Ok I have a new job which Im at currently and I need to develop a new page for the corporate website. My boss has me doing PHP and working with the database. I think Im starting to grasp it I just can figure out how to peice it all together so here is what Im trying to do.

Im creating a page for our customers where all they have to do is type in a model number and a quantity and it will be added to a list. to see how it actually works go HERE
and you will get a better idea how it works now. Go ahead and typ in amounts for a few items and hit the "update quote" button on the bottom of the page.

So now here is where im having problems. All of the products and operations how it currently works uses groupIDs, Product families, group look up and stuff which I dont feel I need to deel with.

To make my goal more understandable on what I need is this.
A page (which I have complete graphicly just need to edit once I figure out the database stuff) where a customer can type in a model number and a quantity and once "update quote" is hit for each item entered will then goto db and retreive a model number which turns into a link (is set up already to link for an image) that can be clicked to view an image, and will also retreive the "little description" for the item to also be displayed.

If you need any code or anything at all to better assist me please let me know and I will post it. Thank you all so much for the help.
Link to comment
Share on other sites

Ok this time it will. Sorry about that, that was the link to the local server. Can you tell I have been doing to much of this.lol...I have been working on this for 3 days or so trying to figure out anything. so here is the link

http://www.winsted.com/winstedSQL/family_sess.php?name=lcd3
Link to comment
Share on other sites

Assuming you know how to make the form, I'll post some PHP.

[code]
<?php
$sql = mysql_query("SELECT * FROM table_name WHERE product_num='{$_POST['product_num']}' LIMIT 1");
$row = mysql_fetch_array($sql);

echo '<a href="product_detail.php?number='.$row['product_num'].'">'.$row['product_num'].'</a> - '.$row['product_decription'];
?>
[/code]
Link to comment
Share on other sites

Now I think I have an idea but what exactly would this code do. and Im assuming I do need to edit it to fit the names of fields in the db correct? I dont know if I need to do anything more but ill brake down the hiarchy or the db.

db is called winsted then there is a list of tables on of them is called "product".
With in the "product" table there are 10 fields but I only need to retrieve data from "model" and "little_desc". If i click on either of those they display the same info. the columns inside read, id, model, little_desc, big_desc..etc and all I need is model and little_desc To be displayed on the form.

1) Did you notice on the link that when you add an item and hit the button it gets added tot he list and you can keep adding and the list will keep building? Is there anything special I need to do for the list to behave like that when im coding the form or anything I should know as far as what I need to do it?

2)Another question reguarding the list is that Im wondering when the list is empty like you see when you start out,...again...is there anything I need to do special to have the list able to keep getting items added to it and just "refrshing" itself so to speak on the same page when the customer keeps adding items to the list?

thank you for the prompt help I realy appreciate it
Link to comment
Share on other sites

This code will perform your search, and display the result. The comments may help.
[code]<?php
//database Information
$dbHost = "localhost";                //Location Of Database usually its localhost
$dbUser = "database_user_name";      //Database User Name
$dbPass = "database_password";        //Database Password
$dbDatabase = "database_name";    //Database Name
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die (mysql_error());
mysql_select_db("$dbDatabase", $db) or die (mysql_error());

//search for the product
$sql = mysql_query("SELECT * FROM product WHERE model='{$_POST['model_number']}' LIMIT 1");
//get results
$row = mysql_fetch_array($sql);
//display the product
if(!$row){
echo'No Product Found'; //Nothing in the database
}else{
echo '<a href="product_detail.php?number='.$row['model_number'].'">'.$row['model_number'].'</a> - '.$row['little_desc']; //Display item, and a little description
}
?>[/code]

1. Depending on how you want the list to work, you can either use sessions, which will then be distroyed as soon as the browser window is closed or you when you tell your code to distroy them, or you can save them in a database and allow someone to access them at any time.

2. If you are going to use sessions, you would want to do an array_push() function on the session. This will add all the items to the end of the array, allowing you to display the content in the session variable. If you are going to save it in a database, you need to have something that will identify the user, such as a login, then it will get all the information from the database with there info, and add or subtract from it.
Link to comment
Share on other sites

Thats almsot EXACTLY what I have writen so far..lol one question I do have pertains to this line "product_detail.php" is this in essance the name of this script. I know I can name my script anything but if I name my script db.php then would I edit this line to say "db.php" is that what its refering to?

I think for the sake that sessions is being used with the original form now that maybe Ill stick with that but again thats another area I lack very much in experiance. Tomorrow when I get to work I can post my form code and maybe you can take a look at it and give me some ideas?

One thing I did notice that I need to resolve. Is today when I ran my script with my form, I typed in a "quantity" in a box and a "model number" in the other box. Good news is that the model number was returned in link form (which its supposed to do only that when you click on it the picture doesnt pop up so I need to fix that some how) and the little_desc was also displayed which is also great news. Only that im having realy big troubles trying to figure out how to have the items get added in list form as part of my original form and exactly like the behavior of the form thats on the site now. Any ideas on that?

Thank you very much for your help again I realy do greatly appreciate it. I am learning alot to just so you know your not like doing the work for me ;D
Link to comment
Share on other sites

well here it is. You wont be able to see all the graphics but if you could help me getting the form set up correctly and to behave like the original one does it would be much appreciated. Thank you again for all your help. Im also going to post up the code for the PHP file that calls the DB and all that.

[b]Here is the code for the form[/b]
[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>noprod Form</title>
< script type="text/javascript" language="JavaScript">
<!-- Hide script from some browsers
function op(link) { var newWindow = window.open(link, 'prod_page','width=480,height=540,resizable,scrollbars,top=0,left=0,screenY=0,screenX=0'); newWindow.focus( ); }
// end script hiding from some browsers -->
< /script >< script type="text/javascript" src="/winstedSQL/js/startlist.js">< /script >
<link rel="stylesheet" href="/winstedSQL/styleNN.css" type="text/css">
<style type="text/css" title="currentStyle" media="all">
@import "/css/global.css";
@import "/css/secondary.css";
@import "/css/resources.css";
@import url(/winstedSQL/style.css); /*IE and NN6x styles*/a#logo{background-image:url(/winstedSQL/img/quote/winsted_logo.gif);}
</style>
<link rel="Shortcut Icon" type="image/x-icon" href="/favicon.ico">
</head>
<body id="winsted-body">
<div id="container">
<div id="headerSection"><a id="logo" href="/index.htm"><span>Winsted</span></a>

<div id="tagLine">
<p>Setting the Standard in Technical Furniture Systems</p>
</div>
<div id="search">
<a href="quote.php" class="goButton">quote generator </a><a href="catalog.htm" class="goButton">catalog request </a>
</div>
<ul id="nav">

<li class="firstChild"><a href="/product.htm">PRODUCTS</a>
<ul>
<li><a href="/cmd2.htm">Command Consoles</a></li>
<li><a href="http://www.techinteriors.com/">Custom Manufacturing</a></li>
<li><a href="/lcd3.htm">LCD/3 Consoles</a></li>
<li><a href="/video.htm">Video Consoles</a></li>

<li><a href="/security.htm">Security Consoles</a></li>
<li><a href="/secprod.htm">Compact Security Products</a></li>
<li><a href="/vracks.htm">Equipment Racks</a></li>
<li><a href="/multi.htm">Multimedia Desks</a></li>
<li><a href="/cart.htm">Audio/Visual Carts</a></li>
<li><a href="/tape.htm">Tape Storage</a></li>

<li><a href="static/winstedcustom.htm">Winsted Custom</a></li>
</ul>
</li>
<li><a href="/sites.htm">MARKETS</a>
<ul>
<li><a href="/airport.htm">Airports</a></li>
<li><a href="/casino.htm">Casinos</a></li>

<li><a href="/control.htm">Control Rooms</a></li>
<li><a href="/corpsec.htm">Surveillance</a></li>
<li><a href="/NOC.htm">Network Operations Centers</a></li>
<li><a href="/power.htm">Power Plants</a></li>
<li><a href="/prison.htm">Prisons</a></li>
<li><a href="/production.htm">Production</a></li>

<li><a href="/school.htm">Schools</a></li>
<li><a href="/tape-install.htm">Tape Storage</a></li>
<li><a href="/transport.htm">Transportation</a></li>
</ul>
</li>
<li><a href="/resources.htm">RESOURCES</a>
<ul>

<li><a href="/onlinecat/t1.html">Online Catalog</a></li>
<li><a href="/quote.php">Quote Generator</a></li>
<li><a href="/catalog.htm">Request a Free Catalog</a></li>
<li><a href="/ae/index.htm">A &amp; E Specs</a></li>
<li><a href="/literature.htm">Literature</a></li>

<li><a href="/tradeshows.htm">Trade Shows</a></li>
<li><a href="/news.htm">News / Press</a></li>
<!-- <li><a href="/signup.htm">Newsletters</a></li>  -->
<li><a href="/sitemap.htm">Sitemap</a></li>
</ul>
</li>
<li><a href="/soft.htm">DESIGN SOFTWARE</a>

<ul>
<li><a href="/soft.htm">WELS Design Software</a></li>
<li><a href="/wels.php">Request a Free Copy</a></li>
</ul>
</li>
<li><a href="/contact.htm">CONTACT US</a>
<ul>

<li><a href="/contact.htm">Contacts</a></li>
<li><a href="/profile.htm">Company Profile</a></li>
<li><a href="/testimonials.htm">Testimonials</a></li>
<li><a href="/privacy.htm">Privacy Disclosure</a></li>
<li><a href="/dealer.htm">Dealers Corner</a></li>
</ul>

</li>
</ul></div>

<div>
<div id="quote_outer">
<div id="quote_inner">
<form action="dbtest.php?name=quote&amp;action=update_product#quote" method="post" style="display:inline; margin:0px;" autocomplete = "off">
<div class="bttns"><input type="image" src="i/update_quote.gif" border="0" alt="Update Totals"></div>

<a name="quote"></a><div class="h2brdr"><h2>Current Quote</h2></div>
<table width="600" height="20" border="0" align="center" cellspacing="0">
  <tr><td align="center" width="107" class="plinky"><strong>Quantity:</strong></td>
<td class="plinky" align="center" width="85"><input name="quantity" value="0" size="2" maxlength="4" class="quanw" type="text">
</td>
  <td width="402" align="left" class="plinky"><strong>Enter Model Number:</strong>
  <input name="model" style="width: 50px;" size="20" maxlength="20" value="" type="text"></td>
</tr></table>
</form></div></div>
<div id="divider"></div>
<div id="footerSection">
<p>
<a href="/product.htm">products</a> :
<a href="/sites.htm">markets</a> :
<a href="/resources.htm">resources</a> :
<a href="/soft.htm">design software</a> :
<a href="/contact.htm">contact us</a> :
<a href="/sitemap.htm">sitemap</a> :
<a href="/catalog.htm">catalog request</a> :
<a href="/dealer.htm">dealers' corner</a>

</p>
<p>
&copy; 2005 Winsted Corporation
</p></div>
</div><!-- /contentSection -->
</div><!-- /container -->
</body>
</html>[/code]

[b]And the php script (currently named dbtest.php)[/b]
[code]<?
//This sets the database access information as constants
define ('DB_USER', 'winsted');
define ('DB_PASSWORD', 'abt3bo');
define ('DB_NAME','winsted');
define ('DB_HOST', 'localhost');

//Establish connection to the databse and some error handeling
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)
or die ('Could not connect to MySQL: ' .
mysql_error());
mysql_select_db(DB_NAME) OR die
('Could not select the database: ' .
mysql_error() );


$sql = mysql_query("SELECT * FROM product WHERE model='{$_POST['model']}' LIMIT 1");
$row = mysql_fetch_array($sql);

echo '<a href="dbtest.php?number='.$row['model'].'">'.$row['model'].'</a> - '.$row['little_desc'];


mysql_close()
?>[/code]

[b]EDITED BY WILDTEEN88: Please use the code/php ([nobbc][code][/code] or [php][/php][/nobbc]) tags when posting code within posts. Thank you.[/b]
Link to comment
Share on other sites

Ok I seem to have accomplished a few things. I do have one last question. I need to do some stuff with sessions and I have NEVER worked with them before. Now I have done a little bit of reading but still having some problems understanding it. So here is the deal on what I need to do. I have my form that the customer will fill out by giving a model(product) number and a quantity then they can hit enter or the button. When they do that a script will be exicuted to retreive what I need off the database and to be displayed in a "list" form above the actual form. Now how would I go about doing this? Or where can I learn how to do this that would be "easy reading" considering im still learning.

Here is a link. Now this is just a graphical representation of what Im trying to figure out how to do.[url=http://www.millermachinecompany.com/winsted/html/test.htm]http://www.millermachinecompany.com/winsted/html/test.htm[/url]

Thank you all much for the help
Link to comment
Share on other sites

Am I able to get any help on this at all?? I do have one last set of questions.

1) How do I set my form up for 3 buttons to appear on the form after the "update quote" button is hit the first time (and to stay on the form from there on)?

2) Dose anyone here have a basic working outline to get me started in sessions? Im trying to do a cart and every time a customer adds a product and a quantity and hits enter the product number will be mached with whats on the database and then be displayed. Take a look at the code above. Im not looking for someone to  do everything but give me something I can see and use and get started on building a sessions script that will do what I need it to. Or even send me a link to a site that may have something usefull.

Out of all the help I have asked for number 2 would be the biggest favor I could ask if I didnt get help on anything else. I have looked up and down and have read a number of things. I learn more by playing with the code and I havent been able to find anything usefull yet to start.


Thank you all again for any help you may be able to lend me.
Link to comment
Share on other sites

Not to be mean or anything (I'm just inquiring), but why is your boss having you do this when it looks like you really don't know what to do? I would think that if your boss knew that you needed help he/she would get someone to help you out. But then again, some supervisors can be be true @$$es...

Might want to check out [url=http://us2.php.net/session]http://us2.php.net/session[/url] for a primer on sessions. I would think that sessions are your answer until the form is submitted for good.
What 3 buttons are you talking about? What are they supposed to do? Styles will hide/display them.

Other than that, aside from completing the project for you, not sure what other help you need. It's generally better (for getting more responses) if you have more specific errors or specific code/design questions.
Link to comment
Share on other sites

Thank you for your reply. Well my boss knows that I know PHP though when I got the job I told him some of my skill is limited. Anyway yea hes kind of laying on the preasure just a bit...not like hard but always asking if its done. There also isnt anyone to help me so im kind of on my own and what ever I can do on the forums for help. I will check out that link and as far as the 3 buttons go, if you click the first link I provided and type in an amount for a couple items and hit "update quote" the cart will be updated on the bottom of the page and you will notice them. It is possable this is being handeled by a css script but ill look into that. i will also check out that link you gave me. Again thank you for your reply.
Link to comment
Share on other sites

Well it has been a little while since I last stopped by here. I have searched google up and down and every crevis it has. I have come across a few things but not sure if they will work or not considering they arnt realy full sessions scripts and deal with more of storing the cart stuff in the db. I dont know if one way or the other is better or not maybe one of you would have an answer to that. Also if anyone has a simple understandable easy to edit sessions script I could use it would be greatly appreciated. Ill be honest with all the stuff I have done and all the sites I have visited, I just wana throw my hands up in the air and yell a large number of profanities.lol. im just getting frustrated with this project an not finding anything usefull or as far as I know anyway.

Any help or push in the right direction to get me started on this and on the right foot would be a huge help. Thank you all so much thus far.
Link to comment
Share on other sites

Well if this helps at all here is some psueado code code I put together. There might be a few errors but I think it will give you guys an idea of what im looking for as far as a sessions script goes. This is my first attempt at psueado code.To bad sesssions cant be this easy. Anyway take a look and see if any of you pros are able to help with translating any of it to code.

Thank you all for any help that can be given on this
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.