


PHP implementation framework of online bidding system (2)_PHP tutorial
Last time we talked about how to display the product list. Let's talk about the method of displaying product details, which is similar to the method we commonly use to display posts in forums.
************File showing detailed information******************
detail.php
<?php
include " config.inc.php";
//Display product details
//Use global variables to easily get the values of multiple fields.
//With id, name, price, introduction, current price, unit, picture, end time.
function ReadDetail(){
global $WARE_TABLE;
global $id,$name,$price,$description,$cprice,$unit,$image,$endtime;
$ SQL="select id,name,description,price,unit,endtime,reply,curprice,photo from $WARE_TABLE where id='$id'";
$result=mysql_query($SQL) or die(mysql_error() ; , this is very necessary.
$row=mysql_fetch_array($result);
$name=$row[name];
$price=$row[price];
$description=$row[description] ;
$unit=$row[unit];
$cprice=$row[curprice];
$endtime=date("Y-m-j",$row[endtime]);
if($ row[photo]==1) $image=$row[id].".jpg";
else $image="";
}
//Read the latest 10 Buyer information
function ReadBuyer(){
global $BID_TABLE;
global $id,$buyer,$buyprice,$date,$num;
$SQL="select id ,buyer,email,price from $BID_TABLE where parentid='$id' order by id desc";
$result=mysql_query($SQL) or die(mysql_error());
$k=mysql_num_rows($ result);
$num=($k>10)? 10:$k; //Judge whether there are more than 10.
for($i=0;$i<$num;$i++){
$row=mysql_fetch_array($result);
$buyer[]=$row[buyer];
$buyprice[]=$row[price];
$date[]=date("Y-m-j H:i:s",$row[id]);
}
}
//Display 10 buyer information.
function ShowBuyer(){
global $buyer,$buyprice,$date,$num;
for($i=0;$i<$num;$i++){
echo "<tr><td width=25%>".$date[$i]."</td>";
echo "<td width=40%>".$buyer[$i] ."</td>";
echo "<td width=35%>".$buyprice[$i]."</td></tr>";
}
}
ReadDetail();
ReadBuyer();
?>
After completing the above processing, you can use <? echo $name?> Or echo $price;?> and so on to get the information to be displayed, I will not go into details.
That’s it, text or pictures should be displayed depending on whether there are pictures or not.
<? if($image=="") echo "No photo"; else echo "<img src=photo/$image>"; ?>
When displaying product details, users should also be allowed to bid, so at this time, a judgment needs to be made on the new price placed by the user. I was lazy, so I directly used Deamweaver to verify the form, and only included the English words in it. The description was changed to Chinese, but because it is a bit special in judging new bids, a little change was made to the function generated by dw.
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v3.0
var p,i,x; if( !d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document ; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d .forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i
function MM_validateForm() { //v3.0
var i,p,q,nm,test,num,min,max, errors='',args=MM_validateForm.arguments;
for (i=0; iif (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1 ) { p=val.indexOf('@');
if (p} else if (test!='R') { num = parseFloat(val);
if (val!=''+num) errors+='- '+nm+' must be a numerical value.n ';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test. substring(p+1);
//************Changes*********
var k=(num-min)/max;
//The judgment must be greater than the current price, and it must be an integer multiple of the current price + price increase unit
if (num<min || k != Math.ceil(k) ) errors+='- '+nm+' must be greater than' +min+' and the price increase must be an integer multiple of '+max+'.n';
} } } //************End the changes********
else if ( test.charAt(0) == 'R') errors += '- '+nm+' Fill in the complete form.n'; }
} if (errors) alert('The following errors were found: n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
The following is simple, but also What's there? Show the items for which bidding has ended. The implementation of this function is the same as the method of displaying unfinished products, so I won’t be verbose.The only difference is that the SetCondition() condition is different and there is no user bidding form when displaying the product details of the end auction.
In addition, I will give you a method to add new products.
<?php
include "config.inc.php";
include "tview.class.php";
function AddRecord(){
global $view ;
//The following variables are obtained from the form on the previous page.
global $name,$price,$unit,$year,$month,$day,$photofile,$intro;
$t=time();
$c=nl2br($ intro);
$et=mktime(24,0,0,$month,$day,$year);
//Check whether a picture has been uploaded.
$ph=( $photofile!="none" and !empty($photofile) )? '1':'0';
//The parameters for calling member function add() are in the sql statement The string in values()
$view->Add("'$t','$name','$c','$price','$unit','$et',' 0','$price','$ph'");
//If there are pictures, copy them to the specified directory.
if($ph=='1')
copy($photofile,"photo/$t.jpg");
}
if( $Submit){
$view= new TViewPage($WARE_TABLE,20);
AddRecord();
header("Location:manager.htm");
}
?>
Okay, Luo Luo Suosuo has written two articles, I wonder if I can add a few hundred points. :)
If you have any questions, I sincerely invite you to discuss them. I have taken out the program. If you see anything inappropriate, don’t be stingy and remember to tell me.
My email: ycshowtop@21cn.com
In addition, if you want a more complete code for this program, please send me an email and I will send it to you.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP is not dead. 1) The PHP community actively solves performance and security issues, and PHP7.x improves performance. 2) PHP is suitable for modern web development and is widely used in large websites. 3) PHP is easy to learn and the server performs well, but the type system is not as strict as static languages. 4) PHP is still important in the fields of content management and e-commerce, and the ecosystem continues to evolve. 5) Optimize performance through OPcache and APC, and use OOP and design patterns to improve code quality.

PHP and Python have their own advantages and disadvantages, and the choice depends on the project requirements. 1) PHP is suitable for web development, easy to learn, rich community resources, but the syntax is not modern enough, and performance and security need to be paid attention to. 2) Python is suitable for data science and machine learning, with concise syntax and easy to learn, but there are bottlenecks in execution speed and memory management.

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!