Jump to content

bsmither

Members
  • Posts

    213
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by bsmither

  1. In my experience with some versions of the MySQL database engine, status is a reserved word. Please try your query using backticks to delineate table and column names: AND `status` = 'pending' (The backtick character is on the key just above the TAB key on the keyboard.)
  2. Please give some consideration to this: //begin while loop while ( $new_array ) { $a = $new_array['some_value']; $b = $new_array['another_value']; } //end while loop Within each iteration of the loop, $a and $b is being assigned values. Yet, nothing is being done with $a and $b. $a and $b is constantly being assigned new values with nothing having been done with the values they had in the prior iteration.
  3. Please be very careful and note where the quote marks are located: <option value="<?php echo $line['serviceid']; if ($line['serviceid'] == $service) {echo 'selected="selected"'} echo $line['serviceid']; ?>"> The above line, when completed, will look like: <option value="3selected="selected"3"> Your statement should read: <option value="<?php echo $line['serviceid']; ?>" <?php if ($line['serviceid'] == $service) {echo 'selected="selected"'} ?>> The above line gives, when completed: <option value="3" selected="selected">
  4. Ok, so we have this at some point: $service = $_POST['service']; Then we have this inside the loop -- looking for something that changes in each iteration of the loop: if ($_POST['service'] == $service) { Consider that $_POST['service'] and $service never change at any point in the loop, there is nothing different that is being checked. The code needs to test on that thing which changes for every iteration of the loop: $line['serviceid'] if ($line['serviceid'] == $service) {
  5. I am not liking this: <option value="<?php echo $line['serviceid']; if ($_POST['service'] == $service) { // What value does $service currently hold? echo 'selected="selected"'; } echo $line['serviceid']; ?>"> <?php echo $line['service']; ?> </option> In the code above, the variable $service will need to equal the value being held in $_POST['service'] for a true result. Let us know if it is defined anywhere. The code is iterating through the $resultservice array on a $line by $line basis. So, $_POST[service'] will actually need to equal the current iteration's $line['serviceid'] for a true result.
  6. "I am parsing an XML file to create the variable to get the values for the array." Would you give us an abridged XML string that represents the source of your parsing? For example: <notice><time></time><type></type><event>Flash Flood Watch</event></notice> You have parsed this string and the result from having found the <event> node, and assigning its value to a variable, would be as: $searchValue = "Flash Flood Watch"; $searchValue is considered the 'needle', and an array of possible values is considered the 'haystack'. So, the task is to determine whether this 'needle' is in the 'haystack'. in_array('needle', 'haystack')
  7. I do not like the mysql_connect and mysql_select_db statements. If you found that in a book, please review the language being used. Let us know how this statemnent is supposed to work. PHP should report the line number on which the error occured. May I ask what environment you are programming in where PHP does not indicate the line number where an error occured? mysql_connect should return with a connection handle, true, or false. We need to test for that and deal with the failure: if (($db = mysql_connect ("localhost", "USERNAME", "PASSWORD")) === false) { die ('I cannot connect to the database because: ' . mysql_error()); } I also see: while ($number > $gable_max_colo){ does not have a closing brace after: $number = $number + 1;
  8. Here's what I do to solve my problems: I use other people's complete applications. For example, if I need an online store to sell computer parts, I get a copy of a free eCommerce solution (osCommerce, OpenCart, CubeCart Lite, etc). "I am making a webshop as a task for school." You need to ask yourself: Must I do all the coding? Am I not allowed to use something that is already built and ready to use? How much money is my time worth? How soon does the school want the store?
  9. The statements above illustrate the concept of iterating through a recordset and building an HTML string from that recordset. What is shown above is not complete. Assuming you have all the code needed to capture the data sent from the database, I suggested a variable named $results. Your code probably uses a different variable to hold the database query results.
  10. Allow me to jump in on this: I, too, need to compile PHP (on Server 2008) because to the best of my ability, I cannot find a pre-compiled binary with FPM enabled. So, I'm going through the motions, reading what little current info there is -- and I am stuck. The display of configure --help does not show the fpm configure switch. The source folder for fpm is in the sapi folder. How do I get the compiler's configure doohicky to see the fpm source? And if I can compile FPM as a shared DLL (loaded via the [extensions] in php.ini), how does that happen?
  11. "Could I use radiobuttons for every different piece of the computer?" Yes. Using radiobuttons for mutually exclusive options is one solution. Another is a drop-down selector for each option type. The choice depends on how much web page display area you have available. That is, a stack of ten radiobuttons takes up more space than a drop-down selector with ten options. // Assume $results is the recordset from the query. $radiobutton_list = ""; foreach($results as $record) { // ['item_type'] is 'processor', 'memory', 'harddrive', etc. ['item_name'] is '-i7', '4GB', '1TB', etc. $radiobutton_list .= '<input type="radio" name="'.$record['item_type'].'" value="'.$record['id'].'" />'.$record['item_name'].'<br />'; } "Is there a way that I can add SQL commands in my value of the radiobutton?" Yes, but I think what it is that you want to do will not work doing it that way.
  12. I would like to suggest: Was: }) }); </script> Now: }) } return false; ); </script>
  13. "I have a database with a lot of items in it" My experience shows that the results of a database query is an indexed array of associative arrays. Thus, to iterate through the first dimension of the result, a foreach() loop can be used. "I want to use radiobuttons connected to the items" Within the loop, the necessary HTML can be built up to form the input element. "Is there a way to do that, or do I have to do it in a different manner?" There are many ways to solve this. You may need to provide a bit more detail in your desired approach. // Assume $results is the recordset from the query. $radiobutton_list = ""; foreach($results as $record) { $radiobutton_list .= '<input type="radio" name="some_name" value="'.$record['id'].'" />'.$record['item_name'].'<br />'; }
×
×
  • 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.