-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Subtract eexpense.txt from balance.txt and print result
Barand replied to mpg's topic in PHP Coding Help
So where is your problem? -
ERD for a php function that generates a invoice
Barand replied to webdeveloper123's topic in Application Design
I'd recommend using a DECIMAL type for currency rather than FLOAT e.g. price DECIMAL(10,2) so you have a fixed number of decimal places. -
ERD for a php function that generates a invoice
Barand replied to webdeveloper123's topic in Application Design
Consider it a good staring point for the final model. Models tend to evolve as development of the project progresses. -
Subtract eexpense.txt from balance.txt and print result
Barand replied to mpg's topic in PHP Coding Help
What have you tried so far? -
ERD for a php function that generates a invoice
Barand replied to webdeveloper123's topic in Application Design
-
ERD for a php function that generates a invoice
Barand replied to webdeveloper123's topic in Application Design
+--------------+ +--------------+ +----------------+ | product | | product_type | | order | +--------------+ +--------------+ +----------------+ +---| product_id | +---| pType | | orderID |--+ | | pName | | | typedescrip | | memberID | | +------------------+ | | pType |>--+ +--------------+ | orderDate | | | order_item | | | pDescription | +----------------+ | +------------------+ | +--------------+ | | order_item_id | | +---<| orderID | | | productID |>---+ | qty | +------------------+ -
ERD for a php function that generates a invoice
Barand replied to webdeveloper123's topic in Application Design
Product_type -1----------< Product ie One to Many +--------------+ +--------------+ | product | | product_type | +--------------+ +--------------+ | product_id | +--------| pType | | pName | | | typedescrip | | pType |>------+ +--------------+ | pDescription | +--------------+ While I'm here, your members table needs a memberID as its primary key otherwise you have nothing to join on. Your model allows only single product per order - it that what you want? -
No "old farts" that I am aware of.
-
Need help with building a custom serialized function
Barand replied to jcmaad's topic in PHP Coding Help
Possibly. How can I know? Syntax is OK. -
Need help with building a custom serialized function
Barand replied to jcmaad's topic in PHP Coding Help
You'll find that serializing data it not used very much these days, largely abandoned in favour of JSON data $data = [ 'count' => 1, 'total' => 5, 'average' => 5 ]; echo "Serialized: " . serialize($data); echo "JSON: " . json_encode($data);; gives Serialized: a:3:{s:5:"count";i:1;s:5:"total";i:5;s:7:"average";i:5;} JSON: {"count":1,"total":5,"average":5} -
how to get the value of each input of each data I bring from the db?
Barand replied to yami's topic in PHP Coding Help
they aready are -
So just, for example, "SELECT id,name, email FROM ..." so you only retrieve what you need. That's why you shouldn't use "SELECT * " in queries as that retrieves every column, need it or not, and slow your queries. [EDIT] PS That's one of the reasons not to use SELECT *.
-
It seems reasonable to me, given the initial caveat.
-
how to get the value of each input of each data I bring from the db?
Barand replied to yami's topic in PHP Coding Help
You say all but only select a single item. And you don't have a submit button! Where is the $iditemm value coming from? No idea - where is it supposed to come from? -
while (($p1 = strpos($str, 'S', $p2)) !== false) { // while there is a next 'S', get its position $p2 = strpos($str, 's', $p1); // find position of following 's' if ($p2===false) { // if there is no following 's' $p2 = strlen($str); // assume its position is the end of the string } echo substr($str, $p1, $p2-$p1+1) . '<br>'; // echo the characters between the S and s }
-
Store the test dates - that will tell you who got there first.
-
You'll affect performance more, and complicate the queries, by splitting your users across more than one table. It would also break a rule of DB design - don't store derived data
-
+-----------+ | user | +-----------+ | user_id |--------+ | name | | | email | | +-----------------+ | phone | | | answer | +-----------+ | +-----------------+ | | answer_id | +----0<| user_id | | question_no | | selected_choice | +-----------------+ One user table. Query to find which answered 4 questions SELECT u.user_id , u.name FROM user u JOIN answer a USING (user_id) GROUP BY u.user_id HAVING COUNT(answer_id) = 4
-
Is there any chance that you might answer that question sometime soon? (At my age an fear I am running out of the time needed to get you thinking about what your code is doing)
-
There is an absence of DB query code in anything you have posted and you have not explicitly stated the origin of all those values that you are passing in the query string ($_GET data), so here is my guess... Does $_GET['did_ivr_disable'] contain the value from the database that you need? Or have you not thought about it?
-
If you always set it to zero, what other result do expect? I did say that it should be the value from your DB.
-
I'm equally sorry that we are new to telepathic communication and so have no idea what your code is that is giving the result below. Did you implement the method I showed you?
-
That must be annoying.
-
Exactly. As I said, determine which button needs to be shown as selected if the value in the database is 0, then the 0 button needs to be "checked". if the value in the database is 1, then the 1 button needs to be "checked". Example $currentValue = 0; // from DB $chk0 = $currentValue==0 ? 'checked="checked"' : ''; $chk1 = $currentValue==1 ? 'checked="checked"' : ''; echo "<input type='radio' name='myradio' value='0' $chk0> No   <input type='radio' name='myradio' value='1' $chk1> Yes";
-
Determine which button needs to be shown as selected and set its "checked" attribute