Jump to content

Search the Community

Showing results for tags 'mysql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hello I've been trying to fix this problem for around 3 weeks; so what I want is to be able to send a picture and being able to display it in another page. It send it to the server, but still it doesn't show it. Here is my code: <?php require_once('../Connections/connection.php'); ?> <?php $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_post")) { $tiempocotejo= time(); $insertSQL = sprintf("INSERT INTO posts (titulo, categoria, tag, imagen, contenido, descripcion, estatus, plantilla,link, price, autor) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['categoria'], "text"), GetSQLValueString($_POST['tag'], "text"), GetSQLValueString($_POST['imagen'], "text"), GetSQLValueString($_POST['contenido'], "text"), GetSQLValueString($_POST['descripcion'], "text"), GetSQLValueString($_POST['estatus'], "int"), GetSQLValueString($_POST['plantilla'], "int"), GetSQLValueString($_POST['link'], "text"), GetSQLValueString($_POST['price'], "text"), GetSQLValueString($_SESSION['MM_Id'], "int")); mysql_select_db($database_connection, $connection); $Result1 = mysql_query($insertSQL, $connection) or die(mysql_error()); mysql_select_db($database_connection, $connection); $query_SacarIdPost = sprintf("SELECT posts.id FROM posts WHERE time=%s",$tiempocotejo,"int"); $SacarIdPost = mysql_query($query_SacarIdPost, $connection) or die(mysql_error()); $row_SacarIdPost = mysql_fetch_assoc($SacarIdPost); $totalRows_SacarIdPost = mysql_num_rows($SacarIdPost); mysql_free_result($SacarIdPost); $updateSQL = sprintf("UPDATE posts SET urlamigable= %s WHERE id=%s", GetSQLValueString(limpia_espacios($_POST['titulo'],$row_SacarIdPost['id']), "text"), GetSQLValueString($row_SacarIdPost['id'], "int")); mysql_select_db($database_connection, $connection); $Result1 = mysql_query($updateSQL, $connection) or die(mysql_error()); $insertGoTo = "publishedpost" . UrlAmigablesInvertida($row_SacarIdPost['id']).".php"; header(sprintf("Location: %s", $insertGoTo)); } ?> <style> #select{ padding-left:0px; } #select2{ padding-right:0px; } </style> <!DOCTYPE html> <html lang="en"> <?php include("includes/head.php"); ?> <!-- Preloader --> <div id="preloader"> <div id="status"> </div> </div> <body> <div id="sb-site"> <!-- header-full --> <div class="boxed"> <?php include ("../includes/header.php");?> <?php include("../includes/menu.php");?> </div> <!-- header-full --> <header class="main-header" style="background-color:#f1f1f1;"></header> <!-- container --> <div class="container"> <div class="row"> <!-- Sidebard menu --> <?php include ("../includes/adminsidebar.php"); ?> <!-- Sidebar menu --> <!--Container --> <div class="col-md-9"> <form role="form" action="<?php echo $editFormAction; ?>" name="add_post" method="POST"> <!-- Title --> <div class="form-group"> <label>Title</label> <input type="text" class="form-control" name="titulo" placeholder="Enter title"> </div> <!-- Title --> <!-- upload image --> <div class="form-group"> <input class='file' type="file" class="form-control" name="imagen" onClick="gestionimagen.php" id="images" placeholder="Please choose your image"> </div> <!-- Upload Image --> <div class="form-group"> <label> Description </label><br> <textarea class="" name="descripcion" style="width:100%"></textarea> </div> <!-- Text editors --> <div class="form-group"> <label> Contenido </label> <textarea class="ckeditor" name="contenido"></textarea> </div> <!-- Text editor --> <!-- Category --> <div class="form-group"> <label>Categoria</label> <input type="text" class="form-control" name="categoria" placeholder="Enter categoria"> </div> <div class="form-group"> <label>Tag</label> <input type="text" class="form-control" name="tag" placeholder="Enter tag"> </div> <!-- Category --> <!-- Visibilidad --> <div class="col-md-6" id="select"> <div class="form-group"> <label for="select">Visible</label> <select class="form-control" id="estatus" name="estatus"> <option value="1">Si</option> <option value="0">No</option> </select> </div> </div> <!-- Visibilidad --> <!-- Tiplo de Plantilla necesito trabajar en esto!!!!! pero ya!!!--> <script> function plantilla(){ var formData = new FormData($("#formUpload")[0]); $.ajax({ type: 'POST', url: 'plantillapost.php', data: formData, contentType: false, processData: false }); } </script> <div class="col-md-6" id="select2"> <div class="form-group"> <label for="select">Plantilla</label> <select class="form-control" id="plantilla" name="plantilla"> <option value="1" <?php if (!(strcmp(1, ""))) {echo "SELECTED";} ?>>Normal</option> <option value="2" onClick="plantilla" <?php if (!(strcmp(2, ""))) {echo "SELECTED";} ?>>Full-Width</option> </select> </div> </div> <!-- Tipo de Plantilla --> <div class="col-md-6" id="select"> <div class="form-group"> <label>Link</label> <input type="text" class="form-control" name="link" placeholder="Enter link"> </div> </div> <div class="col-md-6" id="select2"> <div class="form-group"> <label>Price</label> <input type="text" class="form-control" name="price" placeholder="Enter price"> </div> </div> <button type="submit" class="btn btn-ar btn-primary pull-right">Agregar</button> <input type="hidden" name="MM_insert" value="add_post"> </form> </div> <!-- Container --> </div> </div> <!-- container --> <?php include("../includes/footer.php");?> </div> <!-- boxed --> </div> <!-- sb-site --> <?php include("../includes/menuderecha.php");?> <!-- sb-slidebar sb-right --> <?php include("../includes/back-to-top.php");?> <!-- Scripts --> <!-- Compiled in vendors.js --> <!-- <script src="js/jquery.min.js"></script> <script src="js/jquery.cookie.js"></script> <script src="js/imagesloaded.pkgd.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/bootstrap-switch.min.js"></script> <script src="js/wow.min.js"></script> <script src="js/slidebars.min.js"></script> <script src="js/jquery.bxslider.min.js"></script> <script src="js/holder.js"></script> <script src="js/buttons.js"></script> <script src="js/jquery.mixitup.min.js"></script> <script src="js/circles.min.js"></script> <script src="js/masonry.pkgd.min.js"></script> <script src="js/jquery.matchHeight-min.js"></script> --> <script src="<?php echo $urlWeb ?>js/vendors.js"></script> <!--<script type="text/javascript" src="js/jquery.themepunch.tools.min.js?rev=5.0"></script> <script type="text/javascript" src="js/jquery.themepunch.revolution.min.js?rev=5.0"></script>--> <!-- Syntaxhighlighter --> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shCore.js"></script> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shBrushXml.js"></script> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shBrushJScript.js"></script> <script src="<?php echo $urlWeb ?>js/DropdownHover.js"></script> <script src="<?php echo $urlWeb ?>js/app.js"></script> <script src="<?php echo $urlWeb ?>js/holder.js"></script> <script src="<?php echo $urlWeb ?>js/home_profile.js"></script> <script src="<?php echo $urlWeb ?>js/efectos.js"></script> </body> </html> But Im still not able to display it, si I tried to do a tutorial that I saw on Internet and it made do another php file, that why I put on the input an action="gestionimagen.php" otherwise I would have never done, here is my code for gestionimagen.php: NOTE: I had to create another table on my server called images, but I would like to be able to do it in my table called posts as I have in the code above. <?php require_once '../Connections/connection.php'; $data = array(); if( isset( $_POST['image_upload'] ) && !empty( $_FILES['imagen'] )){ $image = $_FILES['imagen']; $allowedExts = array("gif", "jpeg", "jpg", "png"); if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } //create directory if not exists if (!file_exists('imagen')) { mkdir('imagen', 0777, true); } $image_name = $image['name']; //get image extension $ext = strtolower(pathinfo($image_name, PATHINFO_EXTENSION)); //assign unique name to image $name = time().'.'.$ext; //$name = $image_name; //image size calcuation in KB $image_size = $image["size"] / 1024; $image_flag = true; //max image size $max_size = 512; if( in_array($ext, $allowedExts) && $image_size < $max_size ){ $image_flag = true; } else { $image_flag = false; $data['error'] = 'Maybe '.$image_name. ' exceeds max '.$max_size.' KB size or incorrect file extension'; } if( $image["error"] > 0 ){ $image_flag = false; $data['error'] = ''; $data['error'].= '<br/> '.$image_name.' Image contains error - Error Code : '.$image["error"]; } if($image_flag){ move_uploaded_file($image["tmp_name"], "../images/post".$name); $src = "../images/post".$name; $dist = "../images/post/thumbnail_".$name; $data['success'] = $thumbnail = 'thumbnail_'.$name; thumbnail($src, $dist, 200); $sql="INSERT INTO images (`id`, `original_image`, `thumbnail_image`, `ip_address`) VALUES (NULL, '$name', '$thumbnail', '$ip');"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } } mysqli_close($con); echo json_encode($data); } else { $data[] = 'No Image Selected..'; } ?> So I don't know if did properly explain myself, but thats what I want, send the picture to my server into my table called posts, otherwise can you help me how to properly adapt it to the new table called "images" .
  2. Im currently doing the generate report from fetched data. I got 2 type of search filter , search by date and search using customername (select dropdown list). The one using the date search is worked but when i try using the drop down list to fetch the data, it does'nt appear. <?php include '../include/navbar.php'; $post_at = ""; $post_at_to_date = ""; $count = 1000; $queryCondition = ""; if(!empty($_POST["search"]["DOCDATE"])) { $post_at = $_POST["search"]["DOCDATE"]; list($fid,$fim,$fiy) = explode("-",$post_at); $post_at_todate = date('Y-m-d'); if(!empty($_POST["search"]["post_at_to_date"])) { $post_at_to_date = $_POST["search"]["post_at_to_date"]; list($tid,$tim,$tiy) = explode("-",$_POST["search"]["post_at_to_date"]); $post_at_todate = "$tiy-$tim-$tid"; } $queryCondition .= "WHERE sl_iv.DOCDATE BETWEEN '$fiy-$fim-$fid' AND '" . $post_at_todate . "'"; } $sql = "SELECT * From `sl_iv` Inner Join `ar_iv` On ar_iv.DOCNO = sl_iv.DOCNO Inner Join `payment_terms` On ar_iv.TERMS = payment_terms.id " . $queryCondition . " ORDER BY sl_iv.DOCNO Asc"; $result = mysqli_query($conn_connection,$sql); $item_q = "SELECT * FROM `sl_iv`"; $item = mysqli_query($conn_connection, $item_q); $curdate = "SELECT DATEDIFF(CURDATE(), `DOCDATE`) AS DAYS FROM ar_iv"; $resultdate = mysqli_query($conn_connection, $curdate); $query = "SELECT * FROM sl_iv GROUP by COMPANYNAME"; $result1 = mysqli_query($conn_connection, $query); ?> <link rel='stylesheet' type='text/css' href='css/style.css' /> <link rel='stylesheet' type='text/css' href='css/print.css' media="print" /> <script type='text/javascript' src='js/jquery-1.3.2.min.js'></script> <script type='text/javascript' src='js/example.js'></script> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> </head> <body class="invoice" onLoad="calculateSum()"> <div class="modal-body"> <div id="page-wrap"> <textarea id="header">Report</textarea> <div id="cust"> <textarea id="cust-title"></textarea> <table id="meta"> <tr> <td class="meta-head">Report No.</td> <td name="reportno" class="input-control" /><?php echo $count; ?></td> </tr> <tr> <td class="meta-head">Date</td> <td placeholder="Today Date" name="todaydate" class="input-control" /><?php echo date('Y-m-d'); ?></td> </tr> </table> </div> <br></br> <form name="frmSearch" method="post" action=""> <p class="search_input" id="hiderow"> <input type="text" placeholder="From Date" id="post_at" name="search[DOCDATE]" value="<?php echo $post_at; ?>" class="input-control" /> <input type="text" placeholder="To Date" id="post_at_to_date" name="search[post_at_to_date]" style="margin-left:10px" value="<?php echo $post_at_to_date; ?>" class="input-control" /> <input type="submit" name="go" value="Search"> </p> <br></br> <p id="hiderow"> <select name= "COMPANYNAME"> <option value="">ALL</option> <?php while ($row = mysqli_fetch_array($result1)):;?> <option value="<?php echo ($row['COMPANYNAME']); ?>"><?php echo ($row['COMPANYNAME']); ?></option> <?php endwhile; ?> </select> <input type="submit" name="submit" value="Submit"/> </p> <br /><hr /> <?php if(!empty($result)) { ?> <table id="items"> <center> <thead> <tr> <th width="15%" style="text-align:center"><span>Doc No.</span></th> <th width="10%" style="text-align:center"><span>Date</span></th> <th width="10%" style="text-align:center"><span>Terms</span></th> <th width="10%" style="text-align:center"><span>Due</span></th> <th width="5%" style="text-align:center"><span>Age</span></th> <th width="20%" style="text-align:center"><span>Customer Name</span></th> <th width="10%" style="text-align:center"><span>Ammount</span></th> <th width="10%" style="text-align:center"><span>Payment</span></th> <th width="10%" style="text-align:center"><span>OutStanding</span></th> </tr> </thead> </center> <tbody> <?php if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { $docamt = $row['DOCAMT']; $paymentamt = $row['PAYMENTAMT']; $outstanding = $docamt - $paymentamt; $then = $row['DOCDATE']; $then = strtotime($then); $now = time(); $difference = $now - $then; $dateage = floor($difference / (60*60*24)); ?> <tr class="item-row"> <td style="text-align:left; font-size:15px" readonly><?php echo ($row['DOCNO']);?></td> <td style="text-align:center; font-size:15px"><?php echo ($row['DOCDATE']);?></td> <td style="text-align:center; font-size:15px"><?php echo ($row['terms']);?></td> <td style="text-align:center; font-size:15px"><?php echo ($row['DUEDATE']);?></td> <td style="text-align:center; font-size:15px"><?php echo $dateage;?></td> <td style="text-align:left; font-size:15px" readonly><?php echo ($row['COMPANYNAME']);?></td> <td><input type="text" style="text-align:right; font-size:15px" class="form-control input-sm TotalAmt" id="TotalAmt0" name="TotalAmt[]" value="<?php echo htmlspecialchars($row['DOCAMT']);?>" readonly></td> <td><input type="text" style="text-align:right; font-size:15px" class="form-control input-sm payment" id="payment0" name="payment[]" value="<?php echo htmlspecialchars($row['PAYMENTAMT']);?>" readonly></td> <td><input type="text" style="text-align:right; font-size:15px" class="form-control input-sm Total_Outstanding" id="Total_Outstanding0" name="Total_Outstanding[]" value="<?php echo number_format((float)$outstanding, 2, '.', '');?>" readonly></td> </tr> <?php } } else { echo "0 results"; } ?> </tbody> </table> <?php } ?> </form> <br> <div class="row"> <div class="col-md-3 pull-right"> <table class="table table-condensed table-bordered table-striped table-custom-font" border="0"> <tr> <td><b>Total Amount (RM)</b></td> <td><input type="text" style="text-align:right; font-size:15px" class="form-control input-sm total_amount" id="total_amount" name="total_amount" value="0.00" readonly></td> </tr> </table> <table class="table table-condensed table-bordered table-striped table-custom-font" border="0"> <tr> <td><b>Total Outstanding (RM)</b></td> <td><input type="text" style="text-align:right; font-size:15px" class="form-control input-sm Net_Total" id="net_total" name="net_total" value="0.00" readonly></td> </tr> </table> </div> </div> <div class="pull-right"> <a href="print_tax.php" target="_blank"> <button type="button" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-print"></span> PRINT </button> </a> </div> </div> </div> <script> <!--unitcost, taxes, qty, discount, price--> function calculate(qty,rt,up,subttl,taxr,taxa,total,disc,totaltax){ var quantity = $('#'+qty).val(); var rate = $('#'+rt).val(); var unit_price = $('#'+up).val(); var subtotal = quantity * rate * unit_price; // count subtotal $('#'+subttl).val(subtotal.toFixed(2)); var t_disc = $('#'+disc).val(); // check something if that something exists. what something? find that something. no spoon feeding. if (/\%/g.test(t_disc)) { var count_disc = t_disc.match(/\%/g).length; } else { var count_disc = 0; } // replace something2 hahahahahaha. go and learn. again, no spoon feeding. var discount = t_disc.replace(/^[ ]+|[ ]+$/g,''); // not full checking, but you get the idea. if ((/\s/g.test(discount)) || (/[a-zA-Z]/g.test(discount)) || (/[^0-9.?%]/g.test(discount))) { alert("Please Re-Enter Your Discount"); } else { if((count_disc == 1) && (discount[discount.length - 1] === '%')) { // if found something at the end of something, something will happen. var s_disc = discount; str_disc = s_disc.slice(0, -1); var disc_amt = subtotal * str_disc / 100; var ttl = subtotal - disc_amt; $('#'+total).val(ttl.toFixed(2)); } else if (count_disc == 0) { var str_disc = discount; var ttl = subtotal - str_disc; if (isNaN(ttl) == 0 ){ $('#'+total).val(ttl.toFixed(2)); } else { alert("Please Re-Enter Your Discount"); } } else { alert("Please Re-Enter Your Discount"); } } var t_rate = $('#'+taxr).val(); var temp1 = ttl * t_rate / 100; var tax_amount = Math.round(temp1 * 100) / 100; $('#'+taxa).val(tax_amount.toFixed(2)); var total = ttl + tax_amount; $('#'+totaltax).val(total.toFixed(2)); calculateSum(); } function calculateSum() { var total = 0; $(".Total_Outstanding").each(function() { //add only if the value is number if(!isNaN(this.value) && this.value.length!=0) { total += parseFloat(this.value); } }); $("#net_total").val(total.toFixed(2)); var sum_gst = 0; $(".TotalAmt").each(function() { //add only if the value is number if(!isNaN(this.value) && this.value.length!=0) { sum_gst += parseFloat(this.value); } }); $("#total_amount").val(sum_gst.toFixed(2)); var totaltax = 0; $(".TotalTax").each(function() { //add only if the value is number if(!isNaN(this.value) && this.value.length!=0) { totaltax += parseFloat(this.value); } }); $("#total_including_gst").val(totaltax.toFixed(2)); //var aftr_rndg = rndfunc(sum_final*2, 1)/2; //var rndg_adj = aftr_rndg - sum_final; //$("#rounding_adjustment").val(rndg_adj.toFixed(2)); //var pewpewpew = sum_final + rndg_adj; //$("#final_total").val(pewpewpew.toFixed(2)); //$("#bal_payable").val(pewpewpew.toFixed(2)); } function rndfunc(number, p) { //return Math.round((number*2))/2; return +(Math.round(number + "e+"+p) + "e-"+p); } function RoundNum(num, length) { var number = Math.round(num * Math.pow(10, length)) / Math.pow(10, length); return number; } </script> <script> function myFunction() { window.print(); } </script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script> $.datepicker.setDefaults({ showOn: "button", buttonImage: "datepicker.png", buttonText: "Date Picker", buttonImageOnly: true, dateFormat: 'dd-mm-yy' }); $(function() { $("#post_at").datepicker(); $("#post_at_to_date").datepicker(); }); </script>
  3. I was practicing OOP and made a simple class to log logins. Does anyone see any problems with this or improvements that can be made? Any issue with using NOW() in the query string instead of a placeholder? In another thread, @Jaques1 said: How would I implement that? I rtfm and don't understand it as of yet. <?php // ---------------------------------------------------------------------------- // Database Connection // ---------------------------------------------------------------------------- $dbhost = 'localhost'; $dbname = 'test'; $dbuser = 'root'; $dbpass = ''; $charset = 'utf8'; $dsn = "mysql:host=$dbhost;dbname=$dbname;charset=$charset"; $opt = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; $pdo = new PDO($dsn, $dbuser, $dbpass, $opt); //------------------------------------------------------------------------ // //------------------------------------------------------------------------ $valid_login = new LogLoginStatus($pdo); $valid_login->validLogin('goodusername'); $invalid_login = new LogLoginStatus($pdo); $invalid_login->invalidLogin('bad_username', 'bad_password'); //------------------------------------------------------------------------ // //------------------------------------------------------------------------ class LogLoginStatus { /** * Log Valid/Invalid logins * * @param string login_username * @param string login_password */ public function __construct($pdo) { $this->pdo = $pdo; } function validLogin($username) { $sql = "INSERT INTO user_login (login_status, login_ip, login_username,login_password, login_datetime) values(?, INET_ATON(?), ?, ?, NOW())"; $stmt = $this->pdo->prepare($sql); $stmt->execute(array( 1, $_SERVER['REMOTE_ADDR'], $username, '***' )); } function invalidLogin($username, $password) { $sql = "INSERT INTO user_login (login_status, login_ip, login_username,login_password, login_datetime) values(?, INET_ATON(?), ?, ?, NOW())"; $stmt = $this->pdo->prepare($sql); $stmt->execute(array( 0, $_SERVER['REMOTE_ADDR'], $username, $password )); } } ?> CREATE TABLE `user_login` ( `login_id` int(11) NOT NULL AUTO_INCREMENT, `login_status` tinyint(1) DEFAULT NULL, `login_ip` int(10) unsigned DEFAULT NULL, `login_username` varchar(255) DEFAULT NULL, `login_password` varchar(255) DEFAULT NULL, `login_datetime` datetime DEFAULT NULL, PRIMARY KEY (`login_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  4. Hi I am getting the above error on line highlighted In red below but cannot work out why. Any ideas? <?php session_start(); if(isset($_SESSION['usr_id'])!="") { header("Location: index.php"); } include_once 'dbconnect.php'; //check if form is submitted if (isset($_POST['login'])) { $email = mysqli_real_escape_string($con, $_POST['email']); $password = mysqli_real_escape_string($con, $_POST['password']); $result = mysqli_query($con, "SELECT * FROM users WHERE email = '" . $email. "' and password = '" . md5($password) . "'"); if ($row = mysqli_fetch_array($result)) { $_SESSION['usr_id'] = $row['id']; $_SESSION['usr_name'] = $row['name']; header("Location: index.php"); } else { $errormsg = "Incorrect Email or Password!!!"; } } ?> <!DOCTYPE html> <html> <head> <title>PHP Login Script</title> <meta content="width=device-width, initial-scale=1.0" name="viewport" > <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" /> </head> <body> <nav class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <!-- add header --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="index.php">Koding Made Simple</a> </div> <!-- menu items --> <div class="collapse navbar-collapse" id="navbar1"> <ul class="nav navbar-nav navbar-right"> <li class="active"><a href="login.php">Login</a></li> <li><a href="register.php">Sign Up</a></li> </ul> </div> </div> </nav> <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4 well"> <form role="form" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="loginform"> <fieldset> <legend>Login</legend> <div class="form-group"> <label for="name">Email</label> <input type="text" name="email" placeholder="Your Email" required class="form-control" /> </div> <div class="form-group"> <label for="name">Password</label> <input type="password" name="password" placeholder="Your Password" required class="form-control" /> </div> <div class="form-group"> <input type="submit" name="login" value="Login" class="btn btn-primary" /> </div> </fieldset> </form> <span class="text-danger"><?php if (isset($errormsg)) { echo $errormsg; } ?></span> </div> </div> <div class="row"> <div class="col-md-4 col-md-offset-4 text-center"> New User? <a href="register.php">Sign Up Here</a> </div> </div> </div> <script src="js/jquery-1.10.2.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html> Thank in advance Shane
  5. Hello everyone. Hope you will fine. i want to work on a project which will have three tables, i want to insert and fetch data from tables on webpage. on index page there will list of categories, when user click on anyone of category an other Page "Data Mini" will open, on "data mini" page there will 4 lines of each ROW Record and below it a button for READ MORE, when user click on Read More button, data of mentioned record will Open. so how to do it ? can anybody help ?
  6. Hello! I need help making a query for this statement: Drinkers who frequent exactly one of the bars which Joe frequents The table looks like this: --------------------------------------------- | drinker | bar | --------------------------------------------- | Mike |A.P. Stump's | | Bob |Blue Angel | | Erik |Blue Angel | | Herb |Blue Angel | | Jesse |Blue Angel | | Joe |Blue Angel | | John |Blue Angel | | Justin |Blue Angel | | Mike |Blue Angel | | Rebecca |Blue Angel | | Tom |Blue Angel | | Vince |Blue Angel | | John |Cabana | | Mike |Cabana | | Vince |Cabana | | Joe |Caravan | | John |Caravan | | Tom |Caravan | | Bob |Coconut Willie's Cocktail Lounge | | Joe |Coconut Willie's Cocktail Lounge | | Rebecca |Coconut Willie's Cocktail Lounge | | Justin |Gecko Grill | | Rebecca |Gecko Grill | | Herb |Seven Bamboo | | Vince |Seven Bamboo | | Mike |The Shark and Rose | --------------------------------------------- I can't seem to understand the logic that is needed to build the query. I started with this: SELECT DISTINCT * FROM frequents F1 WHERE NOT EXISTS (SELECT * FROM frequents F2 WHERE F1.drinker = 'Joe' AND /* Something here */); The way I'm reading is that my NOT EXISTS sub query should have Drinkers who like SOME of the bars which Joe frequents then somehow turn that into only one. How should I proceed? Any help would be appreciated! Thanks in advance!
  7. Hi all, Is there a better, shorter, sweeter way to pull out the data from the two similar set of queries below? $staff_id = '34'; if($staff > 0) { $query = "SELECT fname, lname, city, email, cell FROM staff"; $stmt = $con->prepare($query); $stmt->execute(); $stmt->bind_result($fname, $lname, $city, $email, $cell); $stmt->store_result(); $stmt->close(); } else { $query = "SELECT fname, lname, city, email, cell FROM staff WHERE staff_id=?"; $stmt = $con->prepare($query); $stmt->bind_param('i',$staff_id); $stmt->execute(); $stmt->bind_result($fname, $lname, $city, $email, $cell); $stmt->store_result(); $stmt->close(); } Thanks !
  8. First code <?php include("conf.php"); $fixtures_data = mysqli_query($conn,"SELECT Location,Date,HomeTeam,AwayTeam FROM datagmaes"); if ($fixtures_data->num_rows > 0) { // output data of each row while($row = $fixtures_data->fetch_assoc()) { $team1 = $row["HomeTeam"]; $team2 = $row["AwayTeam"]; } } else { echo "0 results"; } ?> Second code <?php include("conf.php"); include("poi.php"); $home = mysqli_query($conn,"SELECT Teamdata1 FROM gamesdata WHERE Team='$team1'"); $row1 = $home->fetch_assoc(); $hometeam = number_format($row1['Teamdata1'],2); $away = mysqli_query($conn,"SELECT Teamdata2 FROM gamesdata WHERE Team='$team2'"); $row2 = $away->fetch_assoc(); $awayteam = number_format($row2['Teamdata2'],2); $calAll = array(); /////All calculations for($goals = 0 ; $goals <= 9 ; $goals++) { array_push($calAll, (poi($goals,$hometeam) * poi(0,$awayteam))*100, (poi($goals,$hometeam) * poi(1,$awayteam))*100, (poi($goals,$hometeam) * poi(2,$awayteam))*100, (poi($goals,$hometeam) * poi(3,$awayteam))*100, (poi($goals,$hometeam) * poi(4,$awayteam))*100, (poi($goals,$hometeam) * poi(5,$awayteam))*100, (poi($goals,$hometeam) * poi(6,$awayteam))*100, (poi($goals,$hometeam) * poi(7,$awayteam))*100, (poi($goals,$hometeam) * poi(8,$awayteam))*100, (poi($goals,$hometeam) * poi(9,$awayteam))*100 ); } $result1 = number_format(array_sum($calAll),2); echo $result1 . "\n"; ?> The first code return multiple items i need to apply the second code to every item in first code and then to save $result1 in mysql table. First code results if echo $team1," vs ",$team2; scgohometeam1 vs csgoawayteam1 scgohometeam2 vs csgoawayteam2 scgohometeam3 vs csgoawayteam3 scgohometeam4 vs csgoawayteam4 scgohometeam5 vs csgoawayteam5 scgohometeam6 vs csgoawayteam6 ... etc. Thes desired final echo after combinin the two codes Final code results if echo $team1," vs ",$team2," = ", $result1 ; scgohometeam1 vs csgoawayteam1 = 25 scgohometeam2 vs csgoawayteam2 = 45 scgohometeam3 vs csgoawayteam3 = 40 scgohometeam4 vs csgoawayteam4 = 30 scgohometeam5 vs csgoawayteam5 = 15 scgohometeam6 vs csgoawayteam6 = 23 ... etc.
  9. I have an html form that inserts a record into database. I also have a an html edit form that retrieves the data from the database. Normally everything works. But I just noticed that I have an issue if I use double quotes in the form field. It'll insert into the database fine. The problem arises when outputting the variable in the form field. If I echo it outside the form field, it'll show up fine with the double quotes. But inside the field, I only geta partial string. For eg. $variable_input = '5 3/4" Glitter Concealed Platform Pump'; The above will insert to the database. But if I retrieve it in the form field below, it'll return with one number only. <input type="text" name="title" value="5" /> Is there a way to fix the variable output of the wording that includes the double quotes?
  10. Hi I have been putting together a CMS system for users that have no idea how to use HMTL, at this time I have managed to build a basic CMS and now I am looking to extend the functionality of its use, right now the user can view the public pages with links, login to the Admin area to manage the subjects or pages and visibility of all and delete any of all or add an admin member, that's a nut shell to a ot of work already done; moving forwards I want to take away the need for any user ever needing to type any code, so if they wish to change the font colour, weight, type o back ground colour or image etc..... so how would anyone recommend working this, I was thinking maybe add buttons and selection boxes that save the correct data into a separate table and retrieve both and concatenate it back together
  11. Hi all ! This works fine and returns a row of the result SELECT fd.fname, fd.lname, fd.role, fd.city, fd.cell, fd.email, fd.fid From fd WHERE fd.recruiter = 118 GROUP by fd.role and if I add Limit 1, 10 to this like this :- SELECT fd.fname, fd.lname, fd.role, fd.city, fd.cell, fd.email, fd.fid From fd WHERE fd.recruiter = 118 GROUP by fd.role LIMIT 1, 10 I get 0 rows. . What's going wrong here or is this like normal ?? Thanks all !
  12. Below I have "Input" where it shows the original string. Basically I want to remove everything before " - ". I would like to know how can I get the "Output" results using PHP? Input $variable_1 = Lulu-free - Swimsuit swimwear red $variable_2 = Pap & Jones - Bard Mini Dress Output $variable_1 = Swimsuit swimwear red $Variable_2 = Bard Mini Dress
  13. I have a Mysql table where I store prices of a product. I have the values in "varchar" format because I needed to include "decimals" in the prices(for eg. 15.30) and "int" doesn't allow that. Having done that, when ever I filter the products by prices in Ascending or Descending order, they don't show up in proper order. It seems like the decimal in the prices is messing up the order. Is there a way to fix this so that the php query can filter the prices in proper order despite the decimals? Here's the eg of the query. $get_records = $db->prepare("SELECT * FROM records ORDER BY records.price DESC");
  14. Hi, I have been reading up on ajax using jquery, and theres something I can't seem to find, i have a form that gets the field values from mysql when the page loads, what is the best way to use ajax to edit this form? Obv the ajax request will execute the mysql update statement but how do i get the edited data back into the form, ready to be worked with again. thanks, hope i made sense, just looking for a little direction. MsKazza
  15. Hi all ! while this query (with table names shortened for clarity) works great and returns a result set just fine, SELECT mr.st_id as st_id from mr,ar where mr.mid = ar.st_id and ar.aid = 1 UNION SELECT ar.st_id as st_id from ar WHERE ar.aid = 1 && ar.role <> 'master' this following one executes and returns a zero result set. CREATE TEMPORARY TABLE tmp_result SELECT st_id from (( SELECT mr.st_id as st_id from mr,ar where mr.mid = ar.st_id and ar.aid = 1) UNION (SELECT ar.st_id as st_id from ar WHERE ar.aid = 1 && ar.role <> 'master')) tt I wish to use the result set obtained from the first query to join with another query a few lines away. Please suggest what is going wrong here & if this approach is fine and workable. Thanks all !
  16. <?php $database = array(); $database['host'] = "localhost"; $database['port'] = '3306'; $database['name'] = "forumtest"; $database['username'] = "root"; $database['password' = "Password"; $link = mysql_connect($database['host], $database['username'], $database['password']); if ($link) { echo "Connected to a database".$database['name']; }else{ echo connect to a database"$database['name'] . "failed<br/>"; echo "Error: ".mysql_error(); } ?> This is my code for a test to connect to a database however, there seems to be a problem with the code as when I try to connect it just gives me a error 500. I would appreciate any help.
  17. Say I have 2 tables. Table 1: Type(type_id, type_name) Table 2: Records(record_id, record_name, record_type) Under the "record_type" column, is it better to use type_id(eg. 10) or type_name(eg. Clothing & Watches)? If the answer is use the name, is it better to use the original name(Clothing & Watches) or a slug name(clothing-watches)?
  18. I would like to simplify my request... here is my query SELECT emp_id, ROUND(SUM((Invoice.invoiceTotal-NewQuote.total)*.30),2) AS thirtypercent, ROUND(SUM(NewQuote.total*.20),2) AS twentypercent FROM `NewQuote` INNER JOIN Invoice ON Invoice.quoteID=NewQuote.quoteID INNER JOIN schedules ON schedules.quoteId=NewQuote.quoteID WHERE (rem=1 OR rem=2) AND (schedules.redo IS NULL) AND invoiceTotal!=0 AND (DATE_FORMAT(date_start, '%m/%d/%Y') >= '07/01/2016') AND ((DATE_FORMAT(date_start, '%m/%d/%Y')<='07/31/2016')) GROUP BY emp_id What im aiming here is this line "AND invoiceTotal!=0" should only be used in getting the thirtypercent and should not be applied in getting the twentypercent. Can you help me on how i can do this? Thank you
  19. hi there, can i ask some help please. i need to get the addon percentage on my database... add on is being computed based on the difference between an invoice and estimate. my query goes like this: SELECT COUNT(estimate) as est, SUM(invoice-estimate) as addons, SUM(addons / est) * 100 as Percentage FROM tblestimates What is the best way to do this? i know that i cant use aliases on the computation i made. Thank you
  20. Hi all, thank you for taking time to browse my thread. I have had some code written for me a while back which fetches either 1 or 2 rows from a database depending on if there are one or two rows based on the date. What it does is simply keep track of lotto results for each of the 2 daily draws along with the booster ball. Now, here's what I'm trying to do. Each row should really have it's own header such as Lunchtime or Teatime based on the draw number fetched from the database. I'm struggling a little. I understand how the code works and that I should have some kind of if/else (I think) in there, but I can't understand where or how to place it. Here is the current code <?php $color_mapping=array('0'=>'BLUE','1'=>'GREEN','2'=>'RED','3'=>'ORANGE','4'=>'YELLOW','5'=>'BROWN','6'=>'VIOLET', '7'=>'BLUE'); for($i = 0; $i < count($rows); $i++) { $res = explode(",", $rows[$i]['result']); $rRows = array(); //echo "<tr><td><p style='float:left;'>".$rows[$i]["draw_nr"].".</p></td>"; for($j = 0; $j < count($res); $j++) echo "<img class='ball' src='http://www.number49s.co.uk/images/fortyninesballs/".$res[$j].".gif'>"; echo "<td><img class='ball booster img-responsive' src='http://www.number49s.co.uk/images/fortyninesballs/".$rows[$i]["booster_ball"].".gif'></td><p style='clear:both;'></p>"; } From what I understand it fetches the results, turns them into an array and pulls each ball separately, from the rows and then appends the booster ball result for the current row. I'm thinking that it should have an if statement around $rRows array which reads if there is only a single row (based on draw number and date) and if it is outputs the code for the single row, then the else statement outputs the code for both. With a different header for each row I know I look like an idiot to you guys (and gals) who know this stuff inside out, but I am trying to learn although sadly this is WAY out of my ability at the moment. Any help as to where to place the if statement and how to get the results based on row number would be very gratefully accepted, but please don't be rude, I know I'm asking a lot, and I also know I know very little compared to the rest of you, but it doesn't give you warrant to be nasty. Thank you in advance to anybody who may be able to help me get this working, it's been driving me nuts for over 3 hours now
  21. Hello, I am doing my best to learn mysql but I still have a lot to learn when queries involve loops or complex syntax. Here's what I would like to achieve: Table 1 includes games played since the beginning of the season (where homeTeamScore or awayTeamScore > 0): Table 2 includes predictions made by users as to which team will win each game (gameId in T2 = id in T1): The following query lets me know how many games have been played since the beginning of the season: $query = "SELECT COUNT(`id`) FROM " . SPORTS_BOL_GameDao::getInstance()->getTableName() . " WHERE SeasonID = " . $seasonId . " AND (homeTeamScore > 0 OR awayTeamScore > 0) ORDER BY gametime DESC"; $totalGames = $this->dbo->queryForColumn($query); And this one how many predictions each user has registered: $query = "SELECT COUNT(`g`.`id`) FROM " . SPORTS_BOL_GameDao::getInstance()->getTableName() . " g INNER JOIN " . SPORTS_BOL_PredictionDao::getInstance()->getTableName() . " p ON g.id = p.gameId WHERE g.SeasonID = " . $seasonId . " AND (g.homeTeamScore > 0 OR g.awayTeamScore > 0) AND p.userId = " . $point['userId'] . " ORDER BY g.gametime DESC"; $totalPreds = $this->dbo->queryForColumn($query); First question: how could I combine these two queries into one and get the total number of missing predictions for each user? As an example, if 89 games have been played and user has registered 70 predictions, I would like to get "19" out of the query. Second question, more complex (at least to me!): what would the query look like if I wanted to know how many consecutive games has each user missed since their last prediction? As an example, if my last prediction was registered on gameId "460" and 4 more games have been played since then (id 468, 469, 470 and 471), I would like to get "4" out of the query. Hope this makes sense and is easy to understand! Thank you very much for your support!
  22. Hi all, Hoping someone might have an insight as to why this isn't working for me. The post is working as everything echo's ok, and there are no error messages, however it doesn't update at all. The db connection must be working as the text boxes on forms have an echo of the current content which displays ok. $recordID = $_GET["recordID"]; $result = mysqli_query($con,"SELECT * FROM news WHERE news_id = '$recordID'"); $row = mysqli_fetch_array($result); if (isset($_POST['submit'])) { $news_id = $_POST['recordID']; $news_title = $_POST['news_title']; $news_content = $_POST['news_content']; $publish = $_POST['publish']; $facebook = $_POST['facebook']; echo $news_id; echo $news_title; echo $news_content; echo $publish; echo $facebook; // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // Perform queries mysqli_query($con,"UPDATE news SET news_title='$news_title', news_content='$news_content', publish='$publish', facebook='$facebook' WHERE news_id='$news_id'"); mysqli_close($con);
  23. Hello there, my name is Ryan. I am a Web Developer from England that specialises in creating mobile-responsive websites. Whether you need a website that takes monthly payments, one-off purchases or runs ads I will take your idea and craft an elegant solution. Skills - PHP HTML5 CSS Javascript I have built user-interfaces and backend database systems, in my 10 years of web development there is little I haven't touched upon. If you are interested in my services you can contact me at: Email ryansocratous@gmail.com Skype ryanify Thank you.
  24. Hello. I have a problem in displaying the user data form database which associated with the user. Maybe i'm messing up the _SESSION part. Im stucked at this part when im changing the add_parcel send_to attribute from (student_username) to (student_name). Since i wanted to display the name of student not the username. <?php session_start(); if(!($_SESSION['username'])){ header("location:index.php?login_first"); } ?> <!-- end navbar top --> <?php include("sidemenu.php"); ?> <!-- page-wrapper --> <div id="page-wrapper"> <div class="row"> <!-- Page Header --> <div class="col-lg-12"> <h1 class="page-header">Dashboard</h1> </div> <!--End Page Header --> </div> <div class="row"> <!-- Welcome --> <div class="col-lg-12"> <div class="alert alert-info"> <?php include("connection.php"); $username=$_SESSION['username']; $sql=mysql_query("SELECT student_name FROM register WHERE student_username='$username'"); $ee=mysql_fetch_array($sql); ?> <i class="fa fa-folder-open"></i><b> Hello ! </b>Welcome Back <b><?php echo $ee['student_name']; ?> </b> </div> </div> <!--end Welcome --> </div> <div class="row"> <div class="col-lg-12"> <div class="table table-responsive"> <table class="table table-hover"> <thead> <tr> <th>S.no</th> <th>Parcel Number</th> <th>Date Recieved</th> <th>Date of Collected</th> <th>Recieved Time</th> <th>Collect Time</th> <th>Status</th> <th>Sent By</th> <th>Sent To</th> </tr> </thead> <?php include("connection.php"); $sql1=mysql_query("SELECT * FROM add_parcel WHERE send_to='$username'"); $i=1; while($row=mysql_fetch_array($sql1)){ echo '<tr class="record"><td>'.$i++.'</td><td>'.$row['parcel_num'].'</td><td>'.$row['date_recieve'].'</td><td>'.$row['date_collect'].'</td><td>'.$row['recieve_time'].'</td><td>'.$row['collect_time'].'</td><td>'.$row['status'].'</td><td>'.$row['sender_name'].'</td><td>'.$row['send_to'].'</td></tr>'; } ?> </html> I tried to change the below code $sql1=mysql_query("SELECT * FROM add_parcel WHERE send_to='$username'"); to $sql1=mysql_query("SELECT * FROM add_parcel"); it displayed all the data of table. I will attach together with some screenshot as well to make it easier. below is image of the Dashboard of user (Screenshot_1 (1).png). Add parcel panel (Screenshot_1 (2).png) Table add_parcel (Screenshot_1 (3).png) Table register (Screenshot_1 (4).png)
  25. Hi all, I have some data in a table to do with 20 users appointments every day for a month. I am trying to organise the appointments in to a large table so the clients can see all the appointments of every colleague by date (in columns) and by user name (in rows). for example: 20th May | 21st May | 22nd May | 23rd May Mike Jones London, Paris | Paris, Rome | Rome, London | London, New York 06:15 - 10:15 | 08:20 - 14:00 | 03:30-05:30 | 05:25-09:30 ----------------------------------------------------------------------------------------------------------------------------------------- Bethan Cray OFF | Belfast, Madrid | Madrid, Fez | Fez, Athens 11:15 - 16:35 | 08:45 - 12:10 | 13:55-15:30 | 09:25-13:20 The data is currently stored in the mysql table such as below, and has over 40 users with over 30 rows each in the same format. SectorDate Code BeginTime Dep Arr EndTime 2016-05-20 Mike Jones 06:15 London Paris 10:15 2016-05-21 Mike Jones 08:20 Paris Rome 14:00 2016-05-20 Bethan Cray 11:15 OFF 16:35 Please can someone show how best to arrange the mysql database to give the output above! Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.