Jump to content

learningphpisfun

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by learningphpisfun

  1. @Kicken... If I was to set it up your way and the count the columns and rows created for the setup based on your template: Database Design A: Table products - ProductID : - Name: Shirt Table colors - ColorID: - Name: Table product_colors - ProductID" - ColorID the numbers of tables and rows I would get based on 1,000 colors for a t-shirt would be: Number of Tables = 3 Number of Columns = 6 Number of Rows = 2,002 -----> 2 ( from table products), 1,000 (from table colors), and 1,000 (from table product colors) if I was to setup a table with three columns and just store all the colors together in a long string for the column colors (and explode it into a list when needed).... the amount of rows and columns I would get is: Database Design B: Table shirt_colors Product ID: Name: Colors: Number Of Tables = 1 Number Of Columns = 3 Number Of Rows = 3 Can you explain to me how Database Design Option A is more optimal (overhead and perfomance wise) than setting the colors into one long string value and then exploding it (besides the fact that it's easier to read and maintain)? Database Design Option A: would result in 3 tables, 6 columns, and 2020 rows being created. Database Design Option B : would result in 1 tables, 3 columns, and 3 rows being created. I'm having a hard time understanding how Databased Design Option A would be the more optimal choice from an overhead and performance perspective. I do realize that a column with a value of over 1,000 words can be very long, but I'm thinking it has no problem pulling up long strings since mysql is a very popular among article and forum sites. Thanks in advance
  2. I realized that it's much more easier and protocol to have multiples tables rather than one table. I'm guessing it's much more easier to have a column for different values than combining it in one column. My question is what if I am designing a page that has a fixed info and I will always need to pull those info together. For example I have a column called T-Shirt Colors under the table CLOTHES. I would then store the value "Red - Blue - Green - Yellow - Orange - Pink - Dark Red " etc. and let's say that column value will have a very long string since it will contain over 1,000 colors. I know for SURE that these are the only colors my store will sell so I don't have to worry about adding or deleting the colors... Would it be more efficient on the overhead and server speed to do it this way and then explode the colors into a list...Or is it better to create 1000 columns for each color... Also if it is more efficient to explode the values (even though it's harder to maintain) on the overhead and server speed, approximately how many more times is it it more efficient.. 1X faster, 2X faster, 3X faster, etc. or maybe too little to be even notice? Thanks in advance (keep in mind that these 1,000 colors are always going to be used together... Since they will always be pulled and used together to give the customer the color options to select from...)
  3. @phpboy07... I am also a newbie at php also...have you ever thought about youtubing php video tutorials?...there are alot of tutorials that cover the basics of php (some videos are good at putting it into words that people with no programming experience can understand) on youtube and some even have a link to the source code...so you can download and view it...I tried the book route but it was so boring having to read pages about the technical definition of functions...and sometimes also getting confused on the programming terminology that they used sometimes... It was much easier to watch somebody show how to code PHP on youtube...anyways for me books were a waste of time and money...I learned in 1-2 weeks from youtube videos and the PHP help forums than I did trying to learn from a book....but different people have different learning style...maybe test different learning styles and choose from there...good luck
  4. @insidius...thanks for the response... I tried to embed html within php and it didn't work cause I placed the </br> outside the echo quotes..... Your response made me think there was a way to embed html within php...and I did some googling and found out that I have to put the </br> inside the quote and not outside... I know it seems noobish but the php tutorial that I was following just showed how to make a basic registration form that echos "welcome $User" when you successfully log in.. It didn't cover embedding html within php or anything... The only time the tutorial used html was to create the form and that was outside <?php ?>..so i didn't have any examples of embedding html within php to use as a guide...anyways a million thanks for responding with a productive and useful solution.
  5. hi...how do i linebreak three echo variables so they are not in the same line?.. so it looks like this (instead of all on the same line): Name: $membername Age: $memberage Gender: $membergender I tried to do the following that was recommended to linebreak the variables into different lines..but it ended up being on the same line. echo: "Name: $membername\n Age:$memberage\n Gender: $membergender"; Here is the code below...Thanks in advance: =============== <?php $info = mysql_query("SELECT * FROM `info` WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error()); $info1 = mysql_fetch_assoc($info; $membername = $info1['membername']; $memberage = $info1['memberage']; $membergender = $info1['membergender']; echo "Name: $membername"; echo "Age: $memberage"; echo "Gender: $membergender"; ?>
  6. Hi I am making a code to keep track of hats in my inventory once i click the submit button on my form. I want to make it so that once the amount of hats is zero, I get redirected to outofstock.php. problem is, I get redirected even if the amount of hats is not zero. I tried using.... }elseif($hats == 0){ header("Location:outofstock.php"); ... but I get an error. If I take out the else and just use if, I get no error and the amount is correctly updated...but I also get redirected regardless if the amount of hats is zero or not...can someone please help me out...below is the code...thanks in advance: <?php session_start(); include("functions.php"); connect (); if(empty($_SESSION['uid'])) header("Location:Home.php"); ?> <?php if(isset($_POST['submit'])){ $submit = protect($_POST['submit']); if($submit== ""){ echo "error"; }elseif(strlen($submit) < 6){ echo "error"; }else{ $user_get = mysql_query("SELECT * FROM `inventory` WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error()); $user_get1 = mysql_fetch_assoc($user_get); $hats = $user_get1['hats']; $amount = "1"; $hatupdate = $hats-$amount; $update_stats = mysql_query("UPDATE `inventory` SET `hats`='".$hatupdate."' WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error()); echo $hats; echo "&nbspremaining."; if($hats == 0); header("Location:outofstock.php"); } } ?> <br /> <form action="1.php" method="POST"> <input type = "submit" name="submit" value= "submit" </form>
×
×
  • 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.