Jump to content

Buddski

Members
  • Posts

    1,236
  • Joined

  • Last visited

Everything posted by Buddski

  1. If you need anymore help you know where to go (as bad as that sounds)
  2. Rewrite echo on this line echo '<table border="1" align="center"><tr>'; to $string = '<table border="1" align="center"><tr>'; Then with all the following echo's change them to $string .= This will append each of the strings onto $string. $logo ='QRcodovi/APPlogo.png'; $string = '<table border="1" align="center"><tr>'; $count = 1; $result = mysql_query("SELECT * FROM custom"); while($row = mysql_fetch_array($result)){ if($count == 4){ $count = 1; $string .= '</tr><tr>'; } $string .= '<td align="center"><img src="QR/'.$row['name'].'.png"/> <p style="font-family:Verdana, Geneva, sans-serif; font-size:15px"> Inv.br: <b style="font-size:40px;">'.$row['name'].'</b></p> <br><img width="90" height="29" src="'.$logo.'"/></td>'; $count++; }
  3. Form code: while ($row = mysql_fetch_assoc($result)) { // Retrieve data until no more echo '<tr valign="top"> <td>' , $row['ProdID'], '</td> <td>' , $row['ProdName'] , '<input type="hidden" name="product[' , $row['ProdID'] , '][name]" value="' , $row['ProdName'] , '" /></td> <td>' , $row['ProdDesc'] , '</td> <td><img src="images/' , $row['ProdImg'] ,'" height="100" width="100"></td> <td>' , $row['ProdPrice'] , '<input type="hidden" name="product[' , $row['ProdId'] , '][price]" value="' , $row['ProdPrice'] , '" /></td> <td class="Multi"><input type="checkbox" value="' , $row['ProdID'] , '" name="ordered" /> Order?</td> <td align="center" class="multi">How Many?<br/><input type="text" name="product[' , $row['ProdId'] , '][qty]" size="4" /></td> </tr>'; } The array is basically ordered -> Contains a list of ProdID from the "checked" checkboxes (only checked boxes are passed) products -> A multi-dimensional array which has an initial key of ProdID, inside that array is the keys of qty, price and name. So, if somebody selects, lets say ProdID 2. Ordered will contain a value of 2 Then you can look at the product array for the data relating to 2 $prod = $_POST['product'][2]; //will return an array with qty, name and price as keys, so echo $prod['name']; // may result in Pantaloons, as that is what product 2 is Once you have got this part squared away in the knowledge bank, ill show you the other part. And of course let me know if what I am saying is completely confusing
  4. We've all gotta start somewhere right What I would do in the form is to create a HTML array of the selected products with the product_id assigned to the value. Then each of the names, qtys etc will also be a HTML array (Crude example warning: A HTML array is basically assigning [] to the name, so name="something[]" can be accessed in PHP with $_POST['something'][0]) Ill post an example soon.
  5. Your form code is very messy and kind of all over the place, no offence, but at least it explains what you are trying to do (somewhat). I am assuming that the CHECK part of your order.php page is so you can display to the customer what they have selected based on the form? May I suggest a much cleaner solution (in regards to the form and the big processing script, it will require A LOT of changes)
  6. Without seeing the form, it makes it hard to understand what is happening. Can you post your form code.
  7. You could do it in PHP, a quick select SELECT `colour` FROM`table` GROUP BY `colour` HAVING COUNT(*) > 1 Will return all the colours that have a duplicate value. You could then loop through this result set and use it to execute the query I posted above, OR use PHP to keep track of the count and individually update them.
  8. Either should be fine, it really depends on what your outcome is to be.
  9. Ok, Well I have just had a play around and have come up with something that will work but its far from perfect, it may (read: will) require some changes, unless you are happy with the result. SET @count = 0; UPDATE `table` JOIN ( SELECT `colour` FROM`table` GROUP BY `colour` HAVING COUNT(*) > 1 ) AS `dupes` ON `chas`.`colour` = `dupes`.`colour` SET `table`.`colour`= CONCAT(`table`.`colour`,@count := @count + 1) The issue this code has is that "count" does not get returned to 0 when the GROUPED `colour` changes. So from your example, the output would be something like To counter this, you could add a WHERE clause and do each colour individually. (Remember, if running this from PHP: mysql_query only supports a single query per call of the function)
  10. I have many solutions, not answers. Do you want to do this in PHP or straight MySQL?
  11. TCPDF is pretty forgiving, if it doesnt like something it usually ignores it.
  12. It is possible, but before you attempt to do this have you given the colour column a unique index so this doesnt occur in the future (unless I am mistaken and you want it to allow duplicates for a time)
  13. That code is just an example of a way for your question to be achieved. Nothing is stopping you from writing it to a variable and passing it into TCPDF
  14. The simplest way is to create a counter for when you loop through the data. Here is a VERY simple example $data = array(1,2,3,4,5,6,7,8,9,10); echo '<table border="1" cellpadding="10"> <tr>'; $count = 0; // Looping the data foreach ($data as $value) { // if the count is 3, close the row, create a new one and reset $count to 0 if ($count == 3) { echo '</tr><tr>'; $count = 0; } // Output the data in a td and increase the count echo "<td>{$value}</td>"; $count++; } // check to see if the last count was 3 if it was then its all good otherwise it isnt if ($count < 3) { echo "<td colspan=\"{(3-$count)}\"> </td>"; } echo '</tr> </table>';
  15. MySQL LIMIT isnt used in a 'show record 5 upto record 10' way. It is more of a 'starting from 5 show 5 records.' Having said that, you only need to figure out what page number you are upto and find the starting record, your $high variable should be $user_message_number $messages = mysql_query("SELECT * FROM messages WHERE recipient='$user_id' ORDER BY id DESC LIMIT $low, $user_message_number") or die(mysql_error());
  16. Your original code would never work. PHP isnt that type of language. Your "temp" fix is how it has to be done (among variants). The mysql_real_escape_string function requires that a connection to a mysql server is already present. You will have to move it into your class function createDb. Also, inside your createDb function $host in the mysql_connect() will be undefined, you will have to reference it using $this $con = mysql_connect($this->host, $user, $pass); As a side note, your connection username and password really should be static, not a user input (just my opinion)
  17. You cannot use the <?= in the way you have, <?= is an ECHO shortcut. You also seem to be using a more Javascript variable style Variables are preceded with a $ and do not require the 'var' part. Try this <option value="0">Day</option> <?php for($i=0;$i<31;$i++){ ?> <option value="<?=$i?>"><?=$i?></option> <?php } ?> </select>
  18. That error, without seeing your current script, is I assume saying that $_POST['id'] does not exist. Try outputting your POST array to make sure its got everything you expect. echo '<pre>',print_r($_POST,true),'</pre>';
  19. You need to put some quotes in your SQL query so it knows you are entering a string into the field, might I also suggest adding some kind of security measure $string = mysql_real_escape_string($_POST['string']); $sql = "INSERT INTO table (some_string) VALUES ('$string')";
  20. You still have a reference to ENCRYPT $arg = "select password, 1 as auth from acl where username='$username' and password=encrypt('$password','$username')"; inside the AuthenticateUser function, this needs to be changed to reflect your new method.
  21. I could be because you arent actually hitting submit. Your form has no actual submit button in it, just a plain old boring button.
  22. Try this as your query.. $sql="INSERT INTO account (username, sha_pass_hash, email) VALUES ('$username',SHA(UPPER(\"$username:$password\")),'$email')";
  23. The $page variable should be able to be accessed by any locally included file as long as the file is included below the declared variable. // index.php $pName = 'admin'; $page = Pages::find_by_pageName($pName); include('something.php'); Then // something.php echo '$page is a ' , gettype($page); The output of above should be 'object'
  24. No difference at all.. that entered key is just a string at the end of the day.
  25. Find an alternative method of encryption I do believe the PHP variant runs on a Windows server. If you dont want to use PHP, you can use MD5 or SHA1. Have a look around. Encryption and Compression Functions
×
×
  • 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.