SitePoint Forums » PHP
161 FOLLOWERS
SitePoint is an online community for web designers and developers to discuss everything from HTML, CSS, JavaScript, PHP, to Photoshop, SEO and more.
SitePoint Forums » PHP
1w ago
Super easy tutorial to get up and running with Docker, PHP 8.3, MySQL and PSR-4 Autoloading on an Apache Server.
DEV Community Docker LAMP Stack With Composer PSR-4 Autoloading – Apache Server
I wanted to create a Docker Lampstack with Composer PSR-4 Autoloading. Here are my requirements: ...
Thanks to @SamA74 for giving me a reason to dig into Docker
Docker Again, Finding Composer Autoload Server Config
I’ve made a lot of progress and have Docker running a few dev sites now, but have now hit my latest road block: Composer. Admittedly, Composer is one of those things I have tried a few times i ..read more
SitePoint Forums » PHP
1w ago
The following code should get a query (addressed to amazon ads) to get a link with author only if author is not AA.VV. (in Italian → autori vari = several [various] authors). Otherwise it should search only for the title (in Amazon “AA.VV.” doesn’t work)
if(($trad_titolo != '') and ($autore != 'AA.VV.')) {echo ", tr.it. <i>$row[trad_titolo]</i>, $row[trad_edizione], $row[trad_luogo] $row[trad_data] (<a rel=\"external\" href=\"$myamzcode1=$amztitolotrad$myamzcode2";}
else {echo ", tr.it. <i>$row[trad_titolo]</i>, $row[trad_edizione], $row[trad_luogo] $row[trad_ ..read more
SitePoint Forums » PHP
1w ago
I have a script that lets me work with multiple shortcodes in WordPress.
function universal_shortcode_handler($atts, $content, $tag) {
// Set up an array of shortcode options
$shortcodes = array(
'ad-code' => 'Advertise with us',
'feedback-code' => 'Share your tips!',
'thanks-code' => 'Thanks for visiting!',
'flagtable' => ''.$flagtable.'',
'home-top' => ''.$home_top.'',
'home-bottom' => ''.$home_bottom.''
);
// Check if the called shortcode exists in our array, and return the appropriate message
if (array_key_exists($tag, $shortcodes)) {
return $shortcodes[$tag];
} else ..read more
SitePoint Forums » PHP
2w ago
Which of this loop works faster for large array
$data = arrray(); // 100,000
//Method one
$chunk = array_chunk($data,1000);
foreach($chunk as $ch){
foreach($ch as $row){
//send email
$email = $row['email'];
send_email($email);
}
}
//Method two
$chunk = array_chunk($data,1000);
$chunkTotal = count($chunk); // which gives 100
$i = 0;
$stopped = 0; // get number of stopped from server of session or database
$resume = $chunkTotal - $stopped;
for ($i = 0; $i <= $chunkTotal; $i++) {
$email0 = (isset($chunk[0]['email'])) ? $chunk[0]['email'] : '';
send_email($email0 ..read more
SitePoint Forums » PHP
2w ago
I have a list of subscribers in a table with a total rows of 400,000
The table structure has just four columns
id | amount | balance | date
Now the amount and balance column values are encrypted using ECB encryption.
I want to update their values of amount and balance by 2.5%
I have two options:
I can run a sql to decrypt and adjust the balance in the table but i don’t know how reliable this will always be especially for rows that much, and how long it will take to complete the update.
Fetch all data, loop through it decrypt it value. and upload back.
Option two looks very rough but i st ..read more
SitePoint Forums » PHP
2w ago
Good morning
How do I change the status of my stock so that when the quantity is 0 it indicates a red “out of stock” button?
Can you help me ?
Produit.php
<?php
require_once 'db.php';
$stmt = $pdo->query('SELECT * FROM produit');
if(isset($_REQUEST['del']))
{
$sup = intval ($_GET['del']);
$sql = "DELETE FROM produit WHERE id_produit=:id_produit";
$query = $pdo->prepare($sql);
$query->bindParam(':id_produit', $sup , PDO::PARAM_STR);
$query->execute();
echo "<script> ..read more
SitePoint Forums » PHP
2w ago
Good morning
I don’t understand why I have to click twice on the delete icon for a product to delete it? (I click the first time and it does nothing and then I click delete again and it deletes it.
Do you have an idea ?
<?php
require_once 'db.php';
$stmt = $pdo->query('SELECT * FROM produit');
if(isset($_REQUEST['del']))
{
$sup = intval ($_GET['del']);
$sql = "DELETE FROM produit WHERE id_produit=:id_produit";
$query = $pdo->prepare($sql);
$query->bindParam(':id_produit', $sup , PDO::PARAM_STR ..read more
SitePoint Forums » PHP
2w ago
Good morning,
I get this error message and I don’t see where my error is in my code.
Do you have an idea ?
my source code :
<?php
require_once 'db.php';
// ajouter un produit
if(isset($_POST['ajouter']))
{
$code_article = $_POST['code_article'];
$nom_article = $_POST['nom_article'];
$quantite = $_POST['quantite'];
$images=$_FILES['profile']['name'];
$tmp_dir=$_FILES['profile']['tmp_name'];
$imageSize=$_FILES['profile']['size'];
$upload_dir='uploads/';
$imgExt=strtolower(pathinfo($images ..read more
SitePoint Forums » PHP
2w ago
I thought I could do this but the errors tell me otherwise.
Trying to do multiple queries through a loop using reference.
for ($i = 1; $i < 7; $i++) {
$query&$i = "SELECT draw_date, picknum0&$i from ".$table_name2." order by draw_id desc limit 20;";
$result&$i = mysqli_query($link, $query&$i) or die ("Error in query: $query&$i. <br />" . mysqli_error($link) ."<br />");
$numrows&$i = mysqli_num_rows($result&$i);
$row&$i ..read more
SitePoint Forums » PHP
2w ago
I’m sorry, I’m a beginner in php. I was given a task at work to make a script in PHP. It is necessary to replace all links with numbers in the URL with letters.
For example, replace 3nsp.com with threensp.com, replace 10dna.com with tendna.com, and so on.
How to do it? Can I write a regular expression? Is there a function in php that will replace numbers with the corresponding words?
8 posts - 4 participants
Read full topic ..read more