$dbc=mysqli_connect('localhost','root','root','jyx')or die('数据库连接失败');
$query="SELECT * FROM `xinwen` WHERE `leibie` = '站内新闻'";
$result=mysqli_query($dbc,$query) or die('数据库查询失败');

echo "<table>
    <tr><td align='center'>序号</td><td align='center'>标题</td><td align='center'>时间</td></tr>";
    while($row = mysqli_fetch_array($result)){
        echo "<tr><td align='center'>".$row[0]."</td><td><a href='xxnr.php' id='title'>".mb_strimwidth($row[1],0,55,'...','utf-8')."</a></td><td align='center'>".$row[4]."</td></tr>";
echo "</table>";

数据库字段是 id,title, leibie, content, addtime


Csdn user default icon

<div class="post-text" itemprop="text"> <p>I'm working on creating a system to allow users to upload items and add 'tags' to them to help them be visible in searches. Currently, I have a database that works like this:</p> <pre><code>id|title|tags </code></pre> <p>Where <code>tags</code> is a comma-separated list of tags the user has entered themself. I've read that this is a terrible way to do it, <s>but having a tags table and storing each ID along with the item record is basically the same thing.</s></p> <p>How could I run a search to return the most relevant results first? I'm using this at the moment, which works, but doesn't sort by relevancy: <code>SELECT * FROM items WHERE tags LIKE '%$tag%' LIMIT 0,20";</code> where <code>$tag</code> is just a tag, no commas (it's inside a loop).</p> </div>



PHP MySQL没有从数据库中获取任何东西

<div class="post-text" itemprop="text"> <p>Trying to get all the users from my database, yet when I do so, the query fails.</p> <p>Attempting to do so with</p> <pre><code> $userNames = mysqli_query($con, "SELECT * FROM Login"); </code></pre> <p>Where in PHPMyAdmin the database has a few records in the table login. I checked if the connection is connected, its connected.</p> <p>Is there any reason this wouldn't work?</p> <p>Here is a <a href="" rel="nofollow noreferrer">examplepage</a>, you can try logging in with Username and Password.</p> <p>EDIT: From the example page, here is the code used to test:</p> <pre><code>if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error() . "&lt;br /&gt;"; } else { echo "Connected to MySQL!&lt;br /&gt;"; } if(mysqli_query($con, "SELECT * FROM Login")){ echo "Query good!&lt;br /&gt;"; } else { echo "Query bad!&lt;br /&gt;"; } </code></pre> <p>EDIT 2: Here is a screenshot of the table existing, and the data existing: <img src="" alt="Something"></p> </div>

在PHP中使用HTML添加下拉菜单 - 从mysql数据库填充

<div class="post-text" itemprop="text"> <p>I'm trying to add a drop down menu populated from mysql database. Here is my code:</p> <pre><code>$sql= "SELECT id, course_period_id from schedule WHERE STUDENT_ID='$_SESSION[student_id]'"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $course_period_id=$row["course_period_id"]; $options.="&lt;OPTION VALUE=\"$course_period_id\"&gt;".$course_period_id.'&lt;/option&gt;'; } echo '&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;'; echo '&lt;SELECT&gt; &lt;OPTION VALUE=0&gt;Choose &lt;?=$options?&gt; &lt;/SELECT&gt; '; </code></pre> <p>The problem is that it gives me a drop down menu with zero options. So what should I change in my code? </p> <p>Thanks</p> </div>


$sql="select * from kabu where name='$_POST[name]'"; $result=mysql_query($sql,$conn); mysql_close($conn); $row=mysql_fetch_array($result); if($row) $state="激活成功"; else $state="激活码无效或者已经使用"; $array=array('state'=>$state); echo json_encode($array); 这个是判断是否存在,我想判断以后然后删除那条信息, 怎么做?


<div class="post-text" itemprop="text"> <p>I have a exam form. But I want to show that form within given date and time. Means if start date time is 2016-06-24 11:34:04 and end date time is 2016-06-27 00:00:00 If any merson open form between given date and time the form should be open otherwise it will go on another message page. I have a code .But it is not working. Please help.</p> <pre><code> &lt;?php include("connection.php"); date_default_timezone_set('Asia/Kolkata'); $timestamp = time(); $date_time = date("Y-m-d H:i:s", $timestamp); $result=mysql_query("select * from activeform"); while($row=mysql_fetch_array($result)) { extract($row); if($date_time &gt; '$startdate' and $date_time &lt; '$enddate') { header("Location: myaccount.php"); } else{ echo"date has been exceeds"; } } ?&gt; </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I am having JSON POST like this.</p> <pre><code>{"item_sku":["016","APL","017"],"item_quantity":[2,4,1]} </code></pre> <p>I want to insert it into mysql database table and in column named 'item_sku' and 'item_quantity'. I guess this will insert three rows.</p> <p>HTML Page:</p> <pre><code> &lt;form id="form1" class="p-md col-md-6" ng-submit="addOrder()"&gt; &lt;ul class="list-group m-b-sm md-whiteframe-z0" ng-repeat="item in cart.items"&gt; &lt;li class="list-group-item"&gt; &lt;a ui-sref="app.product({productSku: item.sku})" class="pull-right w-56"&gt;&lt;img ng-src="{{ item.image || 'img/default_product.jpg' }}" alt="{{item.sku}}" class="img-responsive"&gt;&lt;/a&gt; &lt;div class="clear"&gt; &lt;b&gt;{{}}&lt;/b&gt;&lt;br&gt; &lt;span style="color:#666;font-size:12px;"&gt;{{item.description}}&lt;/span&gt;&lt;br&gt; &lt;span style="color:#666;font-size:12px;"&gt;SKU# {{item.sku}}&lt;/span&gt; &lt;input type="text" ng-model="sku[$index]" ng-init="sku[$index]=item.sku"&gt; &lt;br&gt;&lt;br&gt; &lt;/div&gt; &lt;div&gt; &lt;!-- use type=tel instead of to prevent spinners --&gt; &lt;button class="form-control btn btn-grey" type="button" style="width:34px;background-color:#ddd;" ng-disabled="item.quantity &lt;= 1" ng-click="cart.addItem(item.sku,, item.price, -1)"&gt;-&lt;/button&gt; &lt;input class="form-control btn btn-grey" size="2" style="width:44px" type="tel" ng-model="item.quantity" ng-change="cart.saveItems()" /&gt; &lt;button class="form-control btn btn-grey" type="button" style="width:34px;background-color:#ddd;" ng-disabled="item.quantity &gt;= 100" ng-click="cart.addItem(item.sku,, item.price, +1, $index)" &gt;+&lt;/button&gt; &lt;input type="text" ng-model="quantity[$index]" ng-init="quantity[$index]=item.quantity"&gt; &lt;/div&gt; &lt;/li&gt; &lt;div class="p b-t b-t-2x"&gt; &lt;a style="color:#666;" ng-click="cart.addItem(item.sku,, item.price, -10000000)" &gt; &lt;i class="icon mdi-action-delete i-20" style="color:#666;"&gt;&lt;/i&gt;Remove&lt;/a&gt; &lt;span class="pull-right"&gt;{{item.price * item.quantity | currency:' &amp;#8377; ':2}}&lt;/span&gt; &lt;/div&gt; &lt;/ul&gt; &lt;button type="submit" class="btn btn-info m-t" &gt;Submit&lt;/button&gt; &lt;/form&gt; </code></pre> <p>Controller:</p> <pre><code>app.controller('OrderCtrl', function($scope, $location, $http ) { $scope.sku = []; $scope.quantity = []; $scope.addOrder = function(){ $'submit_order.php', { 'item_sku':$scope.sku, 'item_quantity':$scope.quantity }) .success(function(data,status,headers,config){ $location.path('app/feedbackthankyou'); }); }; }); </code></pre> <p>PHP Code:</p> <pre><code>&lt;?php header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: Content-Type"); include "db.php"; // Using Static Data from POST -- Just for testing $a='{"item_sku":["016","APL","017"],"item_quantity":[2,4,1]}'; $data = json_decode($a); var_dump($data); foreach ($data as $value) { echo $value-&gt;item_sku; echo $value-&gt;item_quantity; } ?&gt; </code></pre> <p>I guess details are enough now. BTW I am using AngularJS to create CART. Please help.</p> </div>


<div class="post-text" itemprop="text"> <p>I have the following table set in my mysql database</p> <pre><code>mem_id | pid | content 0 | 1 | All the content is here 0 | 2 | All the content is here 0 | 3 | All the content is here </code></pre> <p>Now the problem is to get all matching <code>mem_id</code> values and store it in a array in php.</p> <p>Example: A variable called <code>$id</code> has value <code>0</code></p> <p>So now I have to get all values under the column content but only those which matches the <code>mem_id</code> of the user.</p> <p>Could anyone help me with this, I need it in php and using mysql query to get all the values.</p> <p>My current code:</p> <pre><code>$con=mysqli_connect("localhost","*****","******","*****"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM user_friends WHERE mem_id = '$_SESSION[SESS_MEMBER_ID]' LIMIT 1"); while($row = mysqli_fetch_array($result)) { $friends = $row['fid']; } </code></pre> </div>


跪求大神来回答! 我的PHP脚本已经实现了MySQL数据库的链接。但是发现在HTML页面上输入中文查询,显示的是数据库中没有这个信息。 但其实我的MySQL里面有这条中文数据的。网上说的设置utf8,gbk,gb2312我都试过了,也没有用。 我的并不是说页面显示中文乱码,而是数据库中无法执行查询中文这一操作。 希望大神能帮个忙!

如何从两个表中获取数据 - PHP和MySQL

<div class="post-text" itemprop="text"> <p>I have two tables in MySQL as below:</p> <p>Table1 as below:</p> <pre><code>ID (Primary Key Auto Increment) | Student Name | Age </code></pre> <p>Table2 as below:</p> <pre><code>Teacher Name | Student ID (This is the Student ID from table1) | Email | Education </code></pre> <p>Now I want to get data from both the tables table1 and table2 in a single query.</p> <p>I want to retrieve the values from both tables where Student ID is equals to something.</p> <p>Student Name | Age | Teacher Name</p> <p>Can you please let me know how can I query values from two tables as mentioned above. I have read many tutorials but I can not retrieve it properly. I am new to MySQL so please explain clearly. What should I use table join, union, inner or outer join?</p> </div>

java web写的jsp登陆页面中如何匹配数据库



<div class="post-text" itemprop="text"> <p>I am building a visitor tracking system and I want it to be as much as abstract as possible, without having to put static variables inside the code. The campaign table is structure this way:</p> <pre><code>ID - NAME - URL - REDIRECT URL </code></pre> <p>Where ID is the <code>ID</code> of the campaign ( auto-incremented ), <code>NAME</code> is the name of the campaign, <code>URL</code> is the url of the campaign. The fact is that I should get the ID of the campaign based on the campaign we actually are and I am doing it by comparing the current URL with the URL in the DB. By doing this i get the campaign ID and do the rest of the work. The problem is that with my function I correctly get the URL of the campaign but when comparing it with the URLs in the DB not always it returns what expected. I tried to get the URL with all the possible variates but sometimes the URL does not return in the right way and the ID is not recognized in the DB. How may I solve this issue? Is there another logic I may use instead of comparing the URL?</p> <pre><code>$campaign = getCampaignDetails("url", cleanUrl($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])); function cleanUrl($url) { $url = str_ireplace("http://www.", "", $url); $url = str_ireplace("http://", "", $url); $url = str_ireplace("www.", "", $url); $url = str_ireplace(".php", "", $url); $url = str_ireplace("https://www.", "", $url); $url = str_ireplace("https://", "", $url); return $url; } function getCampaignDetails($table, $var) { $query = "SELECT * FROM _campains WHERE ".$table." = '$var'"; $result = mysql_query($query) or die("Getting campaign details via url failed: " . mysql_error()); while ($row = mysql_fetch_assoc($result)) { return $row; } } </code></pre> <p>Example of values of a campaign in the DB:</p> <pre><code>ID = 1, Name = tgcampaign, URL = </code></pre> <p>For now to avoid unexpected errors I am just passing the ID directly in the file, but this is something I would like to avoid, like below:</p> <pre><code>$campaignId = "1"; $campaign = getCampaignDetails("id", $campaignId); </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I'm making a login system with php but I'm getting this error: </p> <blockquote> <p>Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/a9356103/public_html/login.php on line 13</p> </blockquote> <p>and the code is:</p> <pre><code>&lt;?php $mysql_host = 'localhost'; $mysql_database = 'a9356103_web'; $mysql_user = 'a9356103_web'; $mysql_password = 'password'; if (isset($_REQUEST['attempt'])) { $user = $_POST['user']; $pass = $_POST['pass']; $con=mysqli_connect($mysql_host, $mysql_user, $mysql_password); mysql_select_db($mysql_database, $con); } ?&gt; </code></pre> <p>I'm new to php and the forms so any help would be very helpful.</p> </div>


<div class="post-text" itemprop="text"> <div class="question-status question-originals-of-duplicate"> <p>This question already has an answer here:</p> <ul> <li> <a href="/questions/401656/secure-hash-and-salt-for-php-passwords" dir="ltr">Secure hash and salt for PHP passwords</a> <span class="question-originals-answer-count"> 14 answers </span> </li> </ul> </div> <p>My code checks whether the username exists in the database, however if the password is incorrect or empty the user can still log in (redirected to welcome.php). How can i implement it so that the password has to be correct as well as the username?</p> <pre><code>&lt;?php if($_SERVER['REQUEST_METHOD'] === 'POST'){ $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "logreg"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } $user = $conn-&gt;real_escape_string(htmlspecialchars(trim($_POST['username']))); $query = "SELECT `username` FROM `users` WHERE `username` = '$user'"; $result = $conn-&gt;query($query); if($result-&gt;num_rows &gt; 0) { header('Location:welcome.php'); die(); } else $message = 'user does not exist'; } ?&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Log In&lt;/title&gt; &lt;link type="text/css" rel="stylesheet" href="css/bootstrap.css"/&gt; &lt;link type="text/css" rel="stylesheet" href="css/bootstrap.min.css"/&gt; &lt;link type="text/css" rel="stylesheet" href="css/bootstrap-theme.css"/&gt; &lt;link type="text/css" rel="stylesheet" href="css/bootstrap-theme.min.css"/&gt; &lt;link type="text/css" rel="stylesheet" href="css/styles.css"/&gt; &lt;link href='' rel='stylesheet' type='text/css'&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="header"&gt; &lt;div class="body"&gt; &lt;div id="loginbox" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2"&gt; &lt;div class="panel"&gt; &lt;div class="panel-heading"&gt; &lt;div class="panel-title"&gt;&lt;h1&gt;Sign In&lt;/h1&gt;&lt;/div&gt; &lt;div style="float:right; font-size: 80%; position: relative; top:-10px"&gt;&lt;a href="passreset.html"&gt;Forgot password?&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;div style="padding-top:30px" class="panel-body" &gt; &lt;div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"&gt;&lt;/div&gt; &lt;form id="loginform" class="form-horizontal" role="form" action = "index.php" method = "post" enctype="multipart/form-data"&gt; &lt;h4&gt;&lt;?php if(isset($message)) : ?&gt; &lt;div class="error"&gt;&lt;?php echo $message; ?&gt;&lt;/div&gt; &lt;?php endif; ?&gt;&lt;/h4&gt; &lt;div style="margin-bottom: 25px" class="input-group"&gt; &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-user"&gt;&lt;/i&gt;&lt;/span&gt; &lt;input id="username" type="text" class="form-control" name="username" value="" placeholder="username"&gt; &lt;/div&gt; &lt;div style="margin-bottom: 25px" class="input-group"&gt; &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-lock"&gt;&lt;/i&gt;&lt;/span&gt; &lt;input id="login-password" type="password" class="form-control" name="password" placeholder="password"&gt; &lt;/div&gt; &lt;div class="input-group"&gt; &lt;div class="checkbox"&gt; &lt;label&gt; &lt;input id="login-remember" type="checkbox" name="remember" value="1"&gt; Remember me &lt;/label&gt; &lt;/div&gt; &lt;div style="margin-top:10px" class="form-group"&gt; &lt;!-- Button --&gt; &lt;div class="col-sm-12 controls"&gt; &lt;input type = "submit" value = "Log In"&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;div class="col-md-12 control"&gt; &lt;div style="border-top: 1px solid#888; padding-top:15px; font-size:85%"&gt; Don't have an account! &lt;a href="register.html" onClick="$('#loginbox').hide(); $('#signupbox').show()"&gt; Sign Up Here &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="border-top: 1px solid #999; padding-top:20px" class="form-group"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I have this e-commerce site I am working on. Now I keep getting that error every time I try to insert data to the db. I am trying to insert details on table buyer and message but I don't know where the error is.</p> <p>I don't know where the error is please help me out:</p> <p>My code:</p> <pre><code>$buyer_name = $_POST['name']; $address = $_POST['address']; $email = $_POST['email']; $mobile_no = $_POST['mobile_no']; $id_no = $_POST['id_no']; $total = $_POST['total']; echo '&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;br&gt;'; echo 'Thank you for shopping at our Thread online store. And the following is the data you enter.'; echo '&lt;p&gt;The total cost for the purchase of products is:Tsh '.$total. '/=, and the cost can be send through the M-Pesa mobile number +255 757 393 937, Airtel Money: # and Tigo-Pesa: #.&lt;/p&gt;'; echo '&lt;p&gt;And the goods will be sent to the address below:&lt;/p&gt;'; echo '&lt;p&gt;Name : '.$buyer_name. '&lt;br&gt;'; echo '&lt;p&gt;Address and Location : '.$address. '&lt;/p&gt;'; echo '&lt;p&gt;Total Price : '.$total. '&lt;/p&gt;'; echo '&lt;p&gt;With Details : &lt;/p&gt;'; $p = mysql_query("SELECT * FROM buyer"); $cek = mysql_fetch_array($p); $c1 = $cek['name']; $c2 = $cek['address']; $c3 = $cek['email']; $c4 = $cek['mobile_no']; $c5 = $cek['id_no']; if ($c1 == $buyer_name &amp;&amp; $c2 == $address &amp;&amp; $c3 == $email &amp;&amp; $c4 == $mobile_no &amp;&amp; $c5 == $id_no) { $i = 1; foreach($_SESSION as $name =&gt; $value) { if ($value &gt; 0) { if (substr($name, 0, 5) == 'cart_') { $id = substr($name, 5, (strlen($name) - 5)); $get = mysql_query("SELECT * FROM products WHERE product_id='$id'"); while ($get_row = mysql_fetch_assoc($get)) { $sub = $get_row['product_price'] * $value; echo ' &lt; table class = "table table-striped" &gt; &lt; thead &gt; &lt; tr &gt; &lt; th &gt; # &lt; /th&gt; &lt; th &gt; Product ID &lt; /th&gt; &lt; th &gt; Product Name &lt; /th&gt; &lt; th &gt; Quantity &lt; /th&gt; &lt; /tr&gt; &lt; /thead&gt; &lt; tbody &gt; &lt; tr &gt; &lt; td &gt; '.$i.' &lt; /td&gt; &lt; td &gt; '.$get_row[' product_id '].' &lt; /td&gt; &lt; td &gt; '.$get_row[' product_title '].' &lt; /td&gt; &lt; td &gt; '.$value.' &lt; /td&gt; &lt; /tr&gt; &lt; /tbody &lt; /table&gt;'; //&lt;p&gt;'.$i.' '.$get_row['product_id'].' '.$get_row['product_title'].' '.$value.' SubTotal : Tsh '.$sub.' /=&lt;/p&gt; $getBuyer = mysql_query("SELECT,, buyer.address, products.product_id, products.product_title FROM buyer, products WHERE name='$buyer_name' AND address='$address'") or die(mysql_error()); $data = mysql_fetch_array($getBuyer); $pemb = $data['id']; $na = $data['name']; $al = $data['address']; $ib = $get_row['product_id']; $nb = $get_row['product_title']; //echo $total; $i++; } } //@$total += $sub; mysql_query("INSERT INTO message VALUES('', '$pemb', '$na', '$al', '$ib', '$nb', '$value', '$sub', now()) ") or die(mysql_error()); } } } else { //Insert Data of the buyer to the db $query = mysql_query("INSERT INTO buyer VALUES( '$buyer_name', '$email', '$address', '$mobile_no', '$id_no')") or die(mysql_error()); $i = 1; foreach($_SESSION as $name =&gt; $value) { if ($value &gt; 0) { if (substr($name, 0, 5) == 'cart_') { $id = substr($name, 5, (strlen($name) - 5)); $get = mysql_query("SELECT * FROM products WHERE product_id='$id'"); while ($get_row = mysql_fetch_assoc($get)) { $sub = $get_row['product_price'] * $value; echo ' &lt; table class = "table table-striped" &gt; &lt; thead &gt; &lt; tr &gt; &lt; th &gt; # &lt; /th&gt; &lt; th &gt; Product ID &lt; /th&gt; &lt; th &gt; Product Name &lt; /th&gt; &lt; th &gt; Quantity &lt; /th&gt; &lt; /tr&gt; &lt; /thead&gt; &lt; tbody &gt; &lt; tr &gt; &lt; td &gt; '.$i.' &lt; /td&gt; &lt; td &gt; '.$get_row[' product_id '].' &lt; /td&gt; &lt; td &gt; '.$get_row[' product_title '].' &lt; /td&gt; &lt; td &gt; '.$value.' &lt; /td&gt; &lt; /tr&gt; &lt; /tbody &lt; /table&gt;'; $getBuyer = mysql_query(" SELECT,, buyer.address, products.product_id, products.product_title FROM buyer, products WHERE name='$buyer_name' AND address='$address'") or die(mysql_error()); $data = mysql_fetch_array($getBuyer); $pemb = $data['id']; $na = $data['name']; $al = $data['address']; $ib = $get_row['product_id']; $nb = $get_row['product_title']; //echo $total; $i++; } } //@$total += $sub; mysql_query("INSERT INTO message VALUES('', '$pemb', '$na', '$al', '$ib', '$nb', '$value', '$sub', now()) ") or die(mysql_error()); } } } /*if ($query) { header('location:index.php'); }*/ session_destroy(); </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I am trying to create an input that queries the database and returns whether or not a result exists in the database. I have it partially working, but my box is glowing green whenever I only type in one letter. It would be better if it stayed red until it actually found a exact match and then turned green. Edit: I just realized there is also something wrong with my query. It is correctly querying the database now. The original issue is my main problem.</p> <pre><code>$(document).ready(function(){ $("#load").keyup(function (e){ e.preventDefault(); ; searchRequest = $.ajax({ url: 'check_load_no.php', data: $('#load').serialize(), type: 'POST', success: function (data) { $(".verify").css('box-shadow', '0px 0px 9px 2px #84f850'); $(".error").css('display', 'none'); $(".success").css('display', 'block'); }, error: function (data) { $(".verify").css('box-shadow', '0px 0px 9px 2px #ad0037'); $(".success").css('display', 'none'); $(".error").css('display', 'block'); } }); }); }); </code></pre> <p>Below is my php</p> <pre><code>&lt;?php include('../model/conn.php'); ?&gt; &lt;?php include('../model/conn2.php') ?&gt; &lt;?php $sql = "SELECT cmt_2 FROM oeordhdr_sql WHERE cmt_2 = '{$_POST['load']}'"; $query = (odbc_exec($conn,$sql)); $row = (odbc_fetch_row($query)); if($row['cmt_2']){ echo 'yeah'; } </code></pre> <p>HTML</p> <pre><code> &lt;h1&gt;Please add the info based on your load number&lt;/h1&gt; &lt;form action="" method="post"&gt; &lt;div class="card" &gt; &lt;input class="verify" id="load" type="text" name="load" placeholder="Load Number" required/&gt; &lt;span class="error" style="display: none;"&gt;&lt;i class="fa fa-exclamation-triangle fa-lg" aria-hidden="true"&gt; &lt;/i&gt;I'm not finding anything&lt;/span&gt; &lt;span class="success" style="display: none;"&gt; &lt;i class="fa fa-check-cube fa-lg" aria-hidden="true"&gt; &lt;/i&gt; Congratulations, that record exists!&lt;/span&gt;&lt;br&gt; &lt;button class="update_button" type="submit" name="add" value="update"&gt;Update&lt;/button&gt;&lt;/div&gt;&lt;/form&gt; </code></pre> </div>

MYSQL PHP查询将数据从一个表获取到另一个表

<div class="post-text" itemprop="text"> <p>I need to filter data based on one table, but i dont know the correct usage for the select from function in php mysql. The below code shows what i am trying to do, but I think you can use multiple SELECT.</p> <pre><code>$query_Student = "SELECT Project_Title, Project_Lecturer FROM projects WHERE Project_id = (SELECT Proj_id FROM project_course WHERE Cour_id = (SELECT Course_id from courses WHERE Code = (SELECT Course FROM users WHERE Username = ".$_SESSION['MM_Username']."))" </code></pre> <p>Can anyone offer any assistance to what I need to write instead?</p> </div>


<div class="post-text" itemprop="text"> <p>I need to match the multiple same column value of MySQL table using PHP and MySQL. I am explaining my table below.</p> <p><strong>db_user:</strong></p> <pre><code>id status book_id 1 0 22 2 0 22 3 1 22 4 0 23 </code></pre> <p>Here I need the <code>select query</code> and condition is if <code>status=0</code> for same <code>book_id</code> means if table has lets say <code>book_id=22 and all status=0</code> then only it will return value true otherwise false. I am writing one example below.</p> <pre><code>$sql=mysqli_query($connect,"select * from db_user where status=0 and...."); if(mysqli_num_rows($sql) &gt; 0){ $row=mysqli_fetch_array($sql); $data=$row['book_id']; }else{ return 0; } </code></pre> <p>Here as per the example table only last row will fetch because for <code>book_id=22</code> there is <code>status=1</code> present. The data will only fetch when for one <code>book_id</code> all status=0.</p> </div>

将MySQL数据库中两个表的数据与PHP PDO进行匹配并提取

<div class="post-text" itemprop="text"> <p>How to extract data based on matched values from two tables on MySQL database with PHP loop?</p> <p>On table_x I have the column ZIPCODE and on table_y I have ZIPCODE and STREETCODE like this:</p> <pre><code>+-----+---------+ +---------+------------+ | id | zipcode | | zipcode | streetcode | +---------------+ +---------+------------+ | 01 | 1234001 | | 1111001 | 123 | +---------------+ +---------+------------+ | 02 | 1234002 | | 1234001 | 456 | +---------------+ +---------+------------+ table_x table_y </code></pre> <p>I want to extract each line from table_x with the matching streetcode from table_y but i'm not sure which <code>join</code> to use and if I should replace <code>foreach</code> with a <code>while</code> loop to achieve my goal.</p> <pre><code>$sql = 'SELECT * FROM table_x ORDER BY id'; foreach ($db-&gt;query($sql) as $row) { echo $row['zipcode'] . "&lt;br&gt;"; // select from other table } </code></pre> <p>Eventually, output each line as the zipcode with the streetcode next to it.. </p> </div>


今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...



和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...


“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...






提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...




私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...


今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...


本文介绍一些C++的两个新特性,它们虽然微小,但对你的编程十分重要 一、Template表达式内的空格 C++11标准之前建议在“在两个template表达式的闭符之间放一个空格”的要求已经过时了 例如: vector&lt;list&lt;int&gt; &gt;; //C++11之前 vector&lt;list&lt;int&gt;&gt;; //C++11 二、nullptr ...


场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...



离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...


不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...




当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...


HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...



面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?







已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...



《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)





作者 | 伍杏玲出品 | CSDN(ID:CSDNnews)格子衬衫、常掉发、双肩包、修电脑、加班多……这些似乎成了大众给程序员的固定标签。近几年流行的“跨界风”开始刷新人们对程序员的...






不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...