-
Posts
24,602 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
Your other table structure in your previous post was better, once you get round the notion that users in your tables are actually clients Now you have lost both the association of a test with a treatment and the valid duration for a test before it expires. "Expired" is a derived value (and therefore should not be in a table) based on the duration and when the test was last given. How do you now know if a test has expired without going through and manually updating those "expired" flags?
-
Something like this $tabledata = ''; while($row=mysql_fetch_array($query)) { $subtotal=$_SESSION['cart'][$row['product_id']]['quantity']*$row['price']; $totalprice+=$subtotal; $tabledata .= <<<ROW <tr> <td>{$row['name']}</td> <td><input type="text" name="quantity[{$row['product_id']}]" size="5" value="{$_SESSION['cart'][$row['product_id']]['quantity']}"/></td> <td>{$row['price']}€</td> <td>$subtotal</td> </tr> ROW; }
-
While you are constructing the table for your page, store the HTML in a variable that can be added to your email message.
-
It would appear from that quote that you want to know if the client requires the test, but you record the dates the user gave the test so how do you relate it to a particular client?. treatmentTestExpiry - is that a period in days?
-
There are some other things you need to fix. Radio buttons need different values. All yours have a value of "radio" You don't change the search depending on the button selected (not that you could with those values) You are using mysql_xxxx() functions which are about to be removed from PHP. Try something like this <html> <body> <form id="form1" name="form1" method="post" action=""> <div id="Zoekend"> <p> <label for="Zoek"></label> <input type="text" name="Zoek" id="Zoek" /> </p> <p> <label> <input type="radio" name="RadioGroup1" value="1" id="RadioGroup1_0" /> Genre</label> <br /> <label> <input type="radio" name="RadioGroup1" value="2" id="RadioGroup1_1" checked="checked"/> Naam</label> <br /> <label> <input type="radio" name="RadioGroup1" value="3" id="RadioGroup1_2" /> Jaar</label> <br /> <label> <input type="radio" name="RadioGroup1" value="4" id="RadioGroup1_3" /> Regisseur</label> <br /> <input type="submit" name="Zoeken" id="Zoeken" value="Zoeken" /> <br /> </p> </div> </form> <div id="Resultaat"> <h1> Zoekresultaten: </h1> <?php // // if no search attempt then we don't want to process the results // if (isset($_POST['Zoek']) && trim($_POST['Zoek'])!='' ) { $zoekterm = $_POST['Zoek']; $username = '1509506_dyon'; $wachtwoord = '****'; // deleted for your protection $host = 'fdb6.awardspace.net'; $database = '1509506_dyon'; $db = new mysqli($host, $username, $wachtwoord, $database); $fields = array ( 1 => 'Genre', 2 => 'Naam', 3 => 'Jaar', 4 => 'Regisseur' ); $field = $fields[$_POST['RadioGroup1']]; $sql = "SELECT * FROM Movies WHERE $field LIKE '%$zoekterm%'"; $resultaat = $db->query ($sql); if ($resultaat->num_rows > 0) { while ( $row = $resultaat->fetch_assoc() ) { echo $row['Genre'] . " - " . $row['Naam'] . " - " . $row ['Jaar'] . " - " . $row ['Regisseur'] .'<br>' ; } } else { echo "No matching results found"; } } else { echo "No search"; } ?> </div> </body> </html>
-
-
$smbc is an object. You need to pass the directory path as a string
-
$mysqli->commit() returns false , but it is working!
Barand replied to invader7's topic in PHP Coding Help
I was unable to recreate that on my own test table. You do seem to be missing the point of prepared queries though. You keep the values separate from the query, prepare the statement once then execute with different your values, several times as required $mysqli->autocommit(FALSE); $sql = "INSERT INTO users (first_name,last_name) VALUES (?,?)"; $stmt = $mysqli->prepare($sql); $stmt->bind_param('ss', $fn, $ln); $fn = 'stelios'; $ln = 'stelios2'; $stmt->execute(); $fn = 'stelios3'; $ln = 'stelios4'; $stmt->execute(); var_dump($mysqli->commit()); $mysqli->close(); -
User Generated Tables (ala filemaker), sorting/filtering/pagination
Barand replied to fivestringsurf's topic in MySQL Help
Good luck! -
submit a form and unset a session variable on other page
Barand replied to Cyjm1120's topic in PHP Coding Help
Before you can use session_unset() you need to call session_start(); All pages using $_SESSION need session_start() at the top of the script. -
If you load this page without a search term it will execute a search WHERE ... LIKE '%%', which is all records
-
Check to see if a search value has been posted. Only process the second part of your script if there is a posted value.
-
If that is real password, change it.
-
Combining two arrays into a multi-dimensional array
Barand replied to frankchester's topic in PHP Coding Help
I was thinking something like this $data = array(); foreach ($accounts_data as $adata) { $data[$adata['id']]['name'] = $adata['name']; $data[$adata['id']]['dates'] = array(); } foreach ($followers_data as $fdata) { $id = $fdata['account_id']; $data[$id]['dates'][$fdata['date_time']] = $fdata['followers']; } echo '<pre>',print_r($data, true),'</pre>'; -
Combining two arrays into a multi-dimensional array
Barand replied to frankchester's topic in PHP Coding Help
ginerjm Instead of being so ready to criticise the OP about not writing a better query, read the post and you'll see the data comes via an API Frankchester You could structure your accounts array as id => array ('name' => accountname) Then loop through the second array. Using the id as the key, append to that id's array in the first table. Your "dates" subarray structure probably just needs to be dates = array ( $date => $followers) instead of creating the extra level with dates = array ($date = array('followers' => $followers)) -
You need to store in $_SESSION insterad of creating a new array each time one is posted session_start(); var_dump( $_POST); if (!isset($_SESSION['items'])) { $_SESSION['items'] = array(); } if(isset($_POST['item']) && !empty($_POST['item'])) { $_SESSION['items'][] = $_POST['item']; } Use session_start() and this same session array in the form page to list current items Note: unless you then save to a file or db table the items will be lost when the session ends.
-
User Generated Tables (ala filemaker), sorting/filtering/pagination
Barand replied to fivestringsurf's topic in MySQL Help
I have come across this model a couple of times. My test model is attached. Basically, products belong to categories and each category would have its own set of attributes (for example a camera will have a different set of attributes from a bed). Also the attributes have a start date/end date to allow, for example, price changes over time. The technique I used was to to create a table subquery to join the required attribute values into a single row which could be sorted, filtered etc. To make life easier I created a function which took an array of the required attribute ids and generated the required subquery. See this thread reply http://forums.phpfreaks.com/topic/277085-the-eav-model-or-something-better/?do=findComment&comment=1431597 -
Have you looked at http://php.net/manual/en/function.parse-url.php
-
... or your $start contains 0 (have you misspelled $start in your code). Given your start and end, it should produce $start = 1416165131.3015; $end = 1416165131.4172; $diff = ($end - $start)*1000; echo $diff . ' ms'; // 115.70000648499 ms
-
User Generated Tables (ala filemaker), sorting/filtering/pagination
Barand replied to fivestringsurf's topic in MySQL Help
Databases were designed for filtering and sorting, it's what they do. Use the power of the query. -
Depends on how it is "broken". Could be that it defaults to US, or maybe it always returns "true"
-
retrieving specific data from mySQL using PHP
Barand replied to AhmadYousef's topic in PHP Coding Help
First thing to do is connect to your database server and set the default database http://php.net/manual/en/mysqli.construct.php Then you you need to query your database table and get the result set http://php.net/manual/en/mysqli.query.php The query you need will be "SELECT ing_title FROM content_langs WHERE ing_contID = 1" Next, get the record from the result set http://php.net/manual/en/mysqli-result.fetch-assoc.php Examples on the above page links should help you -
For the benefit of those looking for a solution, there are two ways 1. Using PHP date() function to format the date output $sql = "SELECT thedate FROM dates"; $res = $db->query($sql); list($thedate) = $res->fetch_row(); echo "| $thedate | " . date('d:m:Y', strtotime($thedate)) . " |<br>"; /* OUTPUT | 2014-11-16 | 16:11:2014 | */ 2. Using MySQL DATE_FORMAT() function mysql> SELECT -> thedate -> , DATE_FORMAT(thedate, '%d:%m:%Y') as formatted -> FROM dates; +------------+------------+ | thedate | formatted | +------------+------------+ | 2014-11-16 | 16:11:2014 | +------------+------------+
-
Select from Database Query not Filtering
Barand replied to MartynLearnsPHP's topic in PHP Coding Help
Invalid, or zero, dates show as 1970-01-01 (day 0 in unix time) -
Select from Database Query not Filtering
Barand replied to MartynLearnsPHP's topic in PHP Coding Help
SELECT c.id, c.title, c.time, c.removed1, c.removed2, ct.reps, m1.username as user1, m1.member_first_name as firstname1, m1.member_last_name as lastname1, m2.username as user2, m2.member_first_name as firstname2, m2.member_last_name as lastname2, FROM conversation as c JOIN members as m1 ON c.member1 = m1.id JOIN members as m2 ON c.member2 = m2.id JOIN ( SELECT c.title, COUNT(*) as reps FROM conversation GROUP BY title ) as ct ON c.title = ct.title WHERE ((c.member1='{$memberid}' AND c.read1='No' AND c.removed1='No' ) OR (c.member2='{$memberid}' AND c.read2='No' AND removed2='No' )) AND c.id2='1' ORDER BY c.id DESC