-
Posts
1,216 -
Joined
-
Last visited
Everything posted by WebStyles
-
what good is the old code to us? post the new one, maybe you changed something else and don't remember?
-
well, here's a handout... not the only way to do it, not even the best, but probably the easiest for you to understand. I left the easy part for you to solve (adding the actual images and creating the link) <?php // read file $file = file_get_contents('YOUR_FILE_NAME_HERE.txt'); // break file into lines $lines = explode("\n",$file); // create empty array to hold values $myArray = array(); // loop through each line foreach($lines as $line){ // separate fields $fields = explode(",",$line); // remove date from array and use as key $date = array_pop($fields); $myArray[$date] = $fields; } // sort array by keys (date) ksort($myArray); // initialize counter $count = 0; // loop through result and display foreach($myArray as $date => $values){ // limit to 20 if($count >= 20) break; // show data echo "<br>LANGUAGE: ".$values[0]; echo "<br>IMAGE: ".$values[1]; echo "<br>LINK: ".$values[2]; echo "<br>DATE: ".$date; echo "<hr>"; // increment counter $count++; } ?>
-
Help adding variable to URL and then processing it into my db
WebStyles replied to jacko_162's topic in PHP Coding Help
you need to pay more attention. you said you tried: $pid = $_GET['ID']; but that's NOT what you have. (see why I wanted you to post your code again?) this: $pid = $_get['ID']; should be: $pid = $_GET['ID']; (UPPERCASE) -
Help adding variable to URL and then processing it into my db
WebStyles replied to jacko_162's topic in PHP Coding Help
can also post the following: 1. how you called the url. (the complete string please) 2. what's the name of the file where you have that code 3. the part where you actually echo that variable. thank you -
Help adding variable to URL and then processing it into my db
WebStyles replied to jacko_162's topic in PHP Coding Help
Just gave you that solution. Use $_REQUEST or $_GET -
where is the code you're working on and what errors are you getting ?
-
Help adding variable to URL and then processing it into my db
WebStyles replied to jacko_162's topic in PHP Coding Help
if you're adding &id=xx, then echo $_REQUEST['id']; will work. if you're adding &ID=xx then you need to use uppercase: echo $_REQUEST['ID']; -
man, I have no answer for that. Weather or not you should 'bother' is your choice. If you seriously want to code a shopping cart (even just a simple one) you will have to read up a bit more on php. understand how the basics work, the differences between double and single quotes, how to escape characters (and when/why), how variables work, how arrays work, how sessions work, how loops work, how conditions work, and how to send emails. (off the top of my head, the above mentioned should be enough skills for this simple project)
-
I can tell you know absolutely nothing about php... How do you expect to accomplish this shopping task? echo "<tr align='center' valign='top' bgcolor='#f0f0f0'><td>" . $row['productcode'] . "</td><td><a href='images/" . $row['picturelg'] . "'><img src='images/" . $row['picture'] . "' alt='image' /></a> </td><td>" . $row['description'] . "</td><td>£" . $row['salesprice'] . "</td><td><a href="../addToCart.php">Add</a>" . "</td></tr>"; should be echo "<tr align='center' valign='top' bgcolor='#f0f0f0'><td>" . $row['productcode'] . "</td><td><a href='images/" . $row['picturelg'] . "'><img src='images/" . $row['picture'] . "' alt='image' /></a> </td><td>" . $row['description'] . "</td><td>£" . $row['salesprice'] . "</td><td><a href='../addToCart.php'>Add</a>" . "</td></tr>";
-
add the buttons, add the link (for now point it to a page called addToCart.php) and add a productID to the generated url with the value of $row['productcode']. in addToCart.php just do this for now: <?php session_start(); if(!isset($_SESSION['shoppingCart']){ $_SESSION['shoppingCart'] = array(); } $_SESSION['shoppingCart'][] = $_GET['productID']; // add a redirect script back to the page you were here --- ?> (I'm showing you a simple way of doing things, just to get you on the right track. Later you will need to implement a few more things, checks, security checks, etc... Also, you'll need to add quantities. But since you seem to know very little about php, I though it would be best to start really simple.) at any time, sizeof($_SESSION['shoppingCart']) will tell you the amount of items in there.
-
oh dear... Well, you've got to start somewhere... post item details (unique product id and quantity) to a script that will just add them to a $_SESSION array. You can call it something like $_SESSION['shoppingCart']. then create a standalone page that just prints out the values, so you can check if everything is being added correctly. something like: <?php session_start() echo '<pre>'; print_r($_SESSION['shoppingCart']); ?>
-
ok, cool. start coding, then post your code here and we'll help fix problems.
-
will depend on what you want to do on checkout. You can just make the checkout button send you an email with the order, you can make it store the order in a database and then send you an email just saying there's a new order, whatever you want. Think simple: It's just a button that can point to any script you want.
-
???? you only display the products the client actually wants to buy, not ALL of them. Unless you have clients buying 2000 different products at a time, this shouldn't be a problem.
-
you mean NO. there is no id variable in there. you called it proc. change your script to grab proc instead of id.
-
why not just store product id's and quantities in a $_SESSION variable, and display them on a 'shopping cart' page? Then on checkout, they get emailed (or placed in a database) for later processing.
-
and you're calling the file with something like this: http://URL/FILE.php?id=1001 ?
-
I don't see your form in the code, so I don't know what name you gave to the field. Assuming it's name="telephone", change this: "Telephone: " . $telephone . "\n" . to this: "Telephone: " . $_POST['telephone'] . "\n" .
-
and you're sure that id value exists in the database?
-
doesn't sound like a php question. Maybe you'll have better luck in the javascript or ajax forum. Anyway, you should post your code so we can have a look. thanks
-
... also, you did not type the query as I showed you. I never used single quotes on the field name, I used backticks. (you can leave them out)
-
that will work if the variable id exists in the url
-
`id` = '$id' was an example of how to implement. You need to make sure the variable $id exists and has the value you want. (or use another field)
-
Because you seem to only be grabing 'searchquery' echo '<br />'.$_POST['searchquery']; echo '<br />'.$_POST['category'] echo '<br />'.$_POST['state'];
-
if you're using LIMIT 1 in your query, you do not need a while loop to pull out data... The while loop basically repeats the code per each row retrieved from the database. Since you're only retrieving one row, you don't need to loop through them. you can change this: while($row = mysql_fetch_assoc($result)) { echo $row['meta_keywords']; } for this: $row = mysql_fetch_assoc($result); echo $row['meta_keywords']; also, SELECT meta_keywords FROM auto LIMIT 1 is always pulling out the same row, since you do not have any conditions in there. you'll need to add a WHERE clause: (...) where `id` = '$id' limit 1