Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/06/2025 in all areas

  1. the attached code displays the menu, but has nothing to do with adding items to an order (cart), entering the customer information, or submitting/saving that information as an order. some points about the posted code, most of which will greatly simplify it (eliminating more than half of the typing) - use 'require' for things your code must have. don't prepare and execute a query that doesn't have any dynamic value being supplied to it. just use the ->query() method. the settings don't need elseif() logic, just if(), because the option_name can only be one value at any time. Don't Repeat Yourself (DRY.) there are only a few small things different between the corresponding if/else code blocks. the conditional logic should only setup the values for the different things in variables, then simply output them in one instance of the code. don't run queries inside of loops. use a single LEFT JOIN query to get the menu categories and menu items all at once. when you fetch the data, index/pivot it using the category id as the main array index. you can then simply loop over the data using two nested foreach(){} loops to produce the output. don't create unused variables/code. when embedding a php echo statement in html markup, use php's short-open-echo tag <?= and you can leave out the closing ; right before a closing ?> tag, for example - <?=$source?> SELECT queries that can return more than one row need an ORDER BY ... term to insure that the rows are in an expected order.
    1 point
  2. here's an example for the fields you have shown in this thread - <?php // define the fields // you would add other things to this definition, such as validation rules and processing rules $fields["it_c"] = ['label'=>'Whatever it_c is','type'=>'numeric']; $fields["it_h"] = ['label'=>'Whatever it_h is','type'=>'numeric']; $fields["ot_c"] = ['label'=>'Whatever ot_c is','type'=>'numeric']; $fields["ot_h"] = ['label'=>'Whatever ot_h is','type'=>'numeric']; // add entires for all the form fields... // examine the submitted data echo '<pre>'; print_r($_POST); echo '</pre>'; ?> <?php // produce the form ?> <form method='post'> <input type='submit'><br> <?php foreach($fields as $field=>$arr) { switch($arr['type']) { case 'numeric': echo "<label>{$arr['label']}: <input name='$field' type='text' class='numeric'></label><br>"; break; // code for other types... } } ?> <input type='submit'> </form>
    1 point
  3. Hi jtorral, I think that, based upon your posted four-point problem, responsive css is a better method than trying to use php to respond to media sizes. https://developer.mozilla.org/en-US/docs/Web/HTML/Responsive_images media queries can also help for images or overall css adjustments for "other functions on the page like resizing pop up boxes and so on" https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries when you veer away from JavaScript driven pop-up dialogs and move to css modal methods, the above methods will save you alot of hassle, such as trying to post to an included php file and expecting it to receive the post. Have a look at the css and try that method instead. The session should be used to maintain state, which includes databases by storing a user id for repeated querying. You could post CSS questions in the CSS Help forum: https://forums.phpfreaks.com/forum/17-css-help/ And have a second look at what Gizmola posted, John
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • 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.