-
Posts
24,602 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
I can't see your data so I don't know which rows match, but if you have a LEFT JOIN, and there is no match, then the used.* will be NULL, regardless of your uses of IFNULL() in the subquery. You need the IFNULL() in the top level select (instead of "SELECT * ") to fix.
-
LAN Web page worked PHP 5, not happy with PHP 7.
Barand replied to Geoff_2's topic in PHP Coding Help
The "null coalesce" operator was introduced in v7.0 +------------------------------------------------------+---------+---------+ | Code | v 5.x | v 7.0+ | +------------------------------------------------------+---------+---------+ | $onoff = isset($_POST['onoff']) ? 1 : 0 | Y | Y | +------------------------------------------------------+---------+---------+ | $onoff = $_POST['onoff1'] ?? 0; | - | Y | +------------------------------------------------------+---------+---------+ -
I'm having trouble listing the latest data.
Barand replied to maviyazilim's topic in PHP Coding Help
try this link https://www.php.net/manual/tr/mysqli.query.php -
I'm having trouble listing the latest data.
Barand replied to maviyazilim's topic in PHP Coding Help
Kılavuzu okuyun - NotionCommotion size bağlantıyı verdi. (https://www.php.net/manual/en/mysqli.query.php)( Örnekleri kodunuzla karşılaştırın. -
I'm having trouble listing the latest data.
Barand replied to maviyazilim's topic in PHP Coding Help
Read the manual - NotionCommotion gave you the link. Compare the examples with your code. -
FYI, as of php7, you could write it as usort($productions, function($a1, $a2) { return $a2['year'] <=> $a1['year']; });
-
Worked for me with a test table I created. $tsql = "select * from roombook ORDER BY FIELD(stat, 'Checked in', 'Booked', 'Deposit Confirmation', 'Email/phone', 'Checked out')"; $tre = mysqli_query($con, $tsql); echo "<table border='1' style='border-collapse: collapse;'>\n"; while ($trow = mysqli_fetch_array($tre)) { $co = $trow['stat']; if ($co != "Cancelled" ) { echo "<tr> <th>" . $trow['FName'] . " " . $trow['LName'] . "</th> <th>" . $trow['Email'] . "</th> <th>" . $trow['TRoom'] . "</th> <th>" . $trow['cin'] . "</th> <th>" . $trow['cout'] . "</th> <th>" . $trow['stat'] . "</th> <th><a href='roombook.php?rid=" . $trow['id'] . " ' class='btn btn-primary'>Action</a></th> </tr>"; } } echo "</table>\n"; I suggest you check your mysqli connection. Change your <th> to <td> for data rows Add "WHERE stat <> 'Cancelled'" to your query since you don't want to list them
-
Show the rest of that query's processing code.
-
LAN Web page worked PHP 5, not happy with PHP 7.
Barand replied to Geoff_2's topic in PHP Coding Help
This reply to an earlier post may be relevant to your problem -
Your select element does not have a name. Your checkbox doesn't have a value. ( I suggest "1") Only checked checkboxes are posted. You can use $checkbox = $_POST['checkbox'] ?? 0; Then $checkbox will contain 1 if checked and 0 if not.
-
or make use of the defined() function
-
Define "it's not working". Are you getting a PHP error, or a MySQL error message? Why are you ordering by stat twice? As an aside, your case statement looks weird in that you give numeric vlue to all statuses to sort on but as a default you have the string value "Cancelled". Have you considered making the stat column type ENUM? Or, perhaps ORDER BY FIELD(stat, 'Checked in', 'Booked', 'Deposit Confirmation', 'Email/phone', 'Checked Out', 'Cancelled')
-
Here's one way. When you send a payment confirmation write a record (forename, surname, email) to "confirmation" table CREATE TABLE `confirmation` ( `confirm_id` int(11) NOT NULL AUTO_INCREMENT, `forename` varchar(45) DEFAULT NULL, `surname` varchar(45) DEFAULT NULL, `email` varchar(45) DEFAULT NULL, `time_confirmed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `tips_sent` datetime DEFAULT NULL, PRIMARY KEY (`confirm_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; Set up a cron job to run every 5 minutes. This would SELECT confirm_id, forename, surname, email FROM confirmation WHERE tips_sent IS NULL AND NOW() - INTERVAL 10 MINUTE > time_confirmed; foreach record returned Send welcome tips email UPDATE confirmation SET tips_sent = NOW() WHERE confirm_id = ?
-
Use square brackets for arrays, parentheses for for functions IE $person_id = $_SESSION['person_id'];
-
Perhaps <?php $res = $pdo->prepare("SELECT Sold FROM Products WHERE idProducts = ?"); $res->execute([ $_GET["id"] ]); $sqlSold = $res->fetchColumn(); function productOptions($current) { $products = [ 'True' => 1, 'False' => 0 ]; $opts .= ''; foreach ($products as $txt => $val) { $sel = $val==$current ? 'selected' : ''; $opts .= "<option value='$val' $sel>$txt</option>"; } return $opts; } ?> <html> <body> <select name="Sold"> <option selected="selected">Choose one</option> <?= productOptions($sqlSold)?> </select> </body> </html>
-
I prefer to keep WordPress at least a barge-pole's length away. There is is a "Job Offerings" section these forums. You should post your requirements there, along with contact details so prospective developers can reply direct to you.
-
I mentioned next year beacause the VBSA site lists events for 2022 Your posted form is only capable of entering events for the current year. It also doesn't contain any dates information (ie start, finish, closing date). If it had, the tourn_year column would be redundant as the year component of the start date would dictate the tournament year. This raises the question of "How did the above fixtures get into the system?"
-
Or you could use HTML "required" attribute E.G. <!DOCTYPE html> <html> <head> <meta http-equiv="content-language" content="en"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> </head> <body> <form> Username*:<br> <input type="text" name="username" required autofocus><br> Email*:<br> <input type="email" name="email" required><br> <br> <input type="submit" value="Submit"> </form> </body> </html> You still need to validate in your PHP code as there is no guarantee that the input came came from your form.
-
I'm surprised it's even displaying the id. You are setting $location = $row['location'] before you have retrieved any rows from the query. Inside the while loop you don't do anything, just putting a string inside some quotes.
-
Because your form shows the fixed current year (2021) and the sql inserts the currrent year. How will you enter fixtures planned for 2022 (without waiting until next January)?
-
Out of curiosity, how are you planning to insert events for next years schedule? * * * * * That's one, but I was referring to things like this (line 396) align="left"><?php $newDate = date("Y", strtotime($row_tourn2['tourn_year'])); * * * * * It is an alternative code library to mysqli. Much easier and more streamlined. * * * * * Prepared statements remove the user-provided values from the query. Instead placeholders are placed in the query and the values passed as parameters. Here's a PDO example of the code I posted earlier. (The tournament name is passed as a parameter) $stmt = $pdo->prepare("INSERT INTO tournament (tournament_name, tourn_year) VALUES ( ? , CURDATE() )"); $stmt->execute( [ $_POST['tourn_name'] ] ); or you can have named placeholders $stmt = $pdo->prepare("INSERT INTO tournament (tournament_name, tourn_year) VALUES ( :name , CURDATE() )"); $stmt->execute( [ 'name' => $_POST['tourn_name'] ] );
-
It appears you have a hidden input field called tourn_year. Your php code is also trying to reformat the tourn_year field as though it were still a datatime type field. You also have an update query which requires change. Do yourself a favour and drop all the "GetSQLValueString()" stuff and use prepared query statements. While you're at it, seitch to PDO - much better.
-
"site_visible" clearly contains "Yes" and not null, so don't know why it objects. "tourn_year" is empty because there is no input field on the form for it (and there shouldn't be if you always insert the current year)
-
Or, conversely, a none-required closing bracket.