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. I have a posting system worked out, as well as my database configured to my linking.. But as of right now, my posts are posted from oldest to newest, having users scroll down or go to the next page to see the most recent post. How would I "flip" that around and make my posts start from newest to oldest by its date/time (Which is stored in the database)? Thanks!
  2. Hi I'm currently experiencing a problem with my query. I've used the `INSERT IGNORE` option in my query and it works pretty well not to add duplicates, but the problem is that if my unique field match it doesn't update any other info in the row, is there maybe another option to update a row if an existing field exists but insert new row if it doesn't exists? my current query is as follow $query = mysqli_query($con,"INSERT IGNORE INTO mxit (ip,time,user_agent,contact,userid,id,login,nick,location,profile) VALUES ('$ip','$post_time','$mxitua','$mxitcont','$mxituid','$mxitid','$mxitlogin','$mxitnick','$mxitloc','$mxitprof')") or die(mysqli_error($con));
  3. Hello every body. Currently I am creating a quiz section but I'm facing some problem. The thing i want is that the questions which the user has played before should not come again. So here is my quiz table. +-------------+-------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------------------------------+------+-----+---------+----------------+ | qid | int(11) | NO | PRI | NULL | auto_increment | | questions | varchar(255) | NO | UNI | NULL | | | correct_ans | varchar(50) | NO | | NULL | | | option1 | varchar(50) | NO | | NULL | | | option2 | varchar(50) | NO | | NULL | | | option3 | varchar(50) | NO | | NULL | | | category | enum('Maths','Bollywood','Special') | NO | | NULL | | +-------------+-------------------------------------+------+-----+---------+----------------+ Then I have created another tablle where I stored their user id and the questions Iid they have played. Here is the table. +----------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------+------+-----+---------+-------+ | mid | int(11) | NO | PRI | NULL | | | quiz_questions | text | NO | | NULL | | +----------------+---------+------+-----+---------+-------+ In the above table, the ids are stored in this pattern 1,5,10,6,7,11,15,29,2 ------------------> Tis are the quiz id. I'm using this query but to bring the uinque questions but still the same questions are comming.. $q = $this->database()->prepare("SELECT quiz_questions FROM quiz_played WHERE mid = ?"); $q->bindParam(1, $mid,PDO::PARAM_INT); $q->execute(); $row = $q->fetch(PDO::FETCH_ASSOC); $q->closeCursor(); $q1 = $this->database()->prepare("SELECT * FROM quiz WHERE qid NOT IN (?) ORDER BY RAND()"); $q1->bindParam(1, $genre,PDO::PARAM_STR); $q1->bindParam(1, $row['quiz_questions'], PDO::PARAM_STR); $q1->execute(); return $q1->fetch(PDO::FETCH_ASSOC); Any help will be really appreciated.
  4. I'm trying to pass php select option value to another page through url.but it's not working.please help me. member.php <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("nordfxlk_member")or die(mysql_error()); $result = mysql_query("SELECT id,ugroup FROM ugroups"); ?> <select name='group' id='group' > <?php while ($line = mysql_fetch_array($result)) { echo '<option value=' . $line['ugroup'] . '>' . $line['ugroup'] . '</option>'; }?> </select> <a href="db_sql/add_group.php?ugroup=<?php echo $line['ugroup'] ;?>"> click</a> add_group.php include('../limoconfig.php'); if(!isset($_SESSION['adminuserid']) ) { header('Location:../index.php'); } else { $ugroup = $_GET['ugroup']; /*$id = $_GET['id'];*/ $acc_status = "update users set ugroup='".$ugroup."' where id=1931"; echo $acc_status; $rate = db::getInstance()->exec($acc_status); header('Location:../test.php'); } }
  5. Hi, Ive stumbled apon a Mongo database connected to a broadcast script. I would like to change it to a Mysql database can anybody please show me an example how it will look in Mysql format <?php /* Require the PHP wrapper for the Mxit API */ require_once ('MxitAPI.php'); /* Function to count the number of users in MongoDB */ function count_users() { $mongo = new Mongo('127.0.0.1'); $collection = $mongo->sampleapp->users; $collection->ensureIndex(array('uid' => 1)); return $collection->count(); } /* Function to get batches of users from MongoDB */ function get_users($skip=0, $limit=50) { $mongo = new Mongo('127.0.0.1'); $collection = $mongo->sampleapp->users; $collection->ensureIndex(array('mxitid' => 1, 'created_at' => 1)); $users = $collection->find()->sort(array('created_at' => 1))->skip($skip)->limit($limit); return iterator_to_array($users); } /* Instantiate the Mxit API */ $api = new MxitAPI($key, $secret); /* Set up the message */ $message = "(\*) Congratulations to our winners (\*)\n\n"; $message .= "1st place - Michael with 100 points\n"; $message .= "2nd place - Sipho with 50 points\n"; $message .= "3nd place - Carla with 25 points\n\n"; $message .= 'Good Luck! $Click here$'; /* Mxit Markup is included in the message, so set ContainsMarkup to true */ $contains_markup = 'true'; /* Count the number of users in the database */ $count = count_users(); /* Initialise the variable that counts how many messages have been sent */ $sent = 0; /* Keep looping through the user list, until the number of messages sent equals the number of users */ while ($sent < $count) { /* Get users in batches of 50 */ $users = get_users($sent, 50); /* The list where the user MxitIDs will be stored */ $list = array(); foreach ($users as $user) { $list[] = $user['mxitid']; $sent++; } /* If there is a problem getting an access token, retry */ $access_token = NULL; while (is_null($access_token)) { /* We are sending a message so request access to the message/send scope */ $api->get_app_token('message/send'); $token = $api->get_token(); $access_token = $token['access_token']; // Only attempt to send a message if we have a valid auth token if (!is_null($access_token)) { $users = implode(',', $list); echo "\n$sent: $users\n"; $api->send_message($app, $users, $message, $contains_markup); } } } echo "\n\nBroadcast to $sent users\n\n";
  6. I created a form where someone can add their name and a comment and then submit it to my database. here's the code of the form PHP <form method="post" action="addcomments_per_student_action.php" enctype="multipart/form-data" style="width: 700px; height: 400px;"> <?php $x=$_GET['st']; $result = $log->qry("Select * from students where id=".$x); $row=mysql_fetch_assoc($result); echo $row['name'].' - '.$row['surname']; ?> <input type="hidden" name="st" value="<?php echo $row['id']; ?>"> <br><br> <label>name</label> <input type="text" name="comm" required><br> <label>comment</label> <textarea name="comments" style="width: 600px; heigh: 350px;"></textarea> <br> <input name="submit" id="submit" value="submit" type="submit" style="width: 150px;"><br> </form> and here's the code of the form's action PHP <?php require ('logmein.php'); $log = new logmein(); if($log->logincheck($_SESSION['loggedin'],"logon","password","username") == false) { //elenxos egkirotitas sindesis tou xristi sto sistima.An oxi epistrofi stin index me plirofories tou lathous $log->redirect($log->getHost()); } if($_SESSION['userlevel']!=0) { $log->redirect($log->getHost()."?result=3"); } $student=$_POST['st']; $comm=$_POST['comm']; $comments=$_POST['comments']; $log->qry("Insert into comments (student,comm,comment) values (".$student.",'".$comm."','".$comments."')"); $log->redirect("http://spoudastirio.com.gr/grades/comments.php"); ?> THE PROBLEM: When someone submits a plain text, it works fine , but where they write ' symbol the file gets an error. THE ERROR: When i type "here's the game" in the textarea i get this error. You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 's the best game.')' at line 1 My database table is utf8-general ci // text format. How can i solve it, so there won't be this kind of problems.
  7. I have jobs portal where registered users posts new jobs searches This weekly newsletter will send all the jobs posted in the site (in a week) to the registered users but in a more personalized way: For example, posted jobs looking for designers should be sent to users registered as designers. what is the best way to do this? any recommendations? Thanks in advance.
  8. Sorry for the beginner question, here I'm trying to retrieve data from the database and display it in the table format. But only table headers are printed, and not the actual values. The count variable is echoing 2 saying that data is present and correctly retrieved. Can anyone help? <?php include 'connect.php'; error_reporting(E_ALL ^ E_DEPRECATED); error_reporting(E_ERROR | E_PARSE); $sql="SELECT * FROM `resources` as r INNER JOIN `project_resources` as pr ON r.res_id =pr.res_id WHERE project_id='$_POST[project_id]'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($result === FALSE) { die(mysql_error()); } echo "$count"; echo '<table> <tr> <th>Resource ID</th> <th>Resource Name</th> <th>Email</th> <th>Phone Number</th> <th>Reporting Manager</th> <th>Role</th> <th>Designation</th> </tr>'; while ($row = mysql_fetch_array($result)) { echo ' <tr> <td>'.$row['res_id'].'</td> <td>'.$row['res_name'].'</td> <td>'.$row['email'].'</td> <td>'.$row['phone_number'].'</td> <td>'.$row['reporting_manager'].'</td> <td>'.$row['role'].'</td> <td>'.$row['designation'].'</td> </tr>'; } echo ' </table>'; ?>
  9. I have a Joomla website having one folder for audio files in it and their links are saved in database. Now I want to show two calendars to the user at front end, so that they can choose that from when to from he want to download the audio files? for e.g he can select june-2-2014 in one calendar and august-2-2014 in second calendar, now on clicking download button the files residing between the two specific dates must get archived into one zip file and then start downloading... i have a reference link for creating a zip and downloading the zip :http://coursesweb.net/php-mysql/create-zip-file-archive-php_cs now i am stuck that how to get the selection of user from calendar , save it into the array , and from the array get the files from the folder matching the array indexes and then zip , download them. please tell me how to achieve this task ?
  10. Hi there, hope have some help. I have a form where a user select time and days of the week (monday, tuesday..) that he is available. The insert script works fine, it insert and the days of week he checked in the table, the only problme is when i try to update each of them. I used this code above, but is not working, instead of updating/inserting days that is selected is inserting multi-records with the same day of the week value. here it is: foreach($weekDay as $DaysofWeek){ $sql_days = "UPDATE available SET day_time = '$day_time', week_day = '$DaysofWeek' WHERE user_id = '$id_user'"; $update_availability = mysql_query($sql_days); }
  11. I am having a very strange issue on one server. I have the same code in a development server running fine, but in my prod server it is failing. Here is the main issue: I have a user authentication routine that accepts UserID and Password from a form and validates it against a MySQL database. So to start, UserId and Password are entered via POST variables as is standard: $UserId=@$_POST['UserId']; $Password=@$_POST['Password']; The Password is encrypted using a standard crypt method such as: $encrypt = crypt($Password,'6!68$7435!'); And this is stored in a MySQL database. This part is working fine, that is, the password is encrypted in value and stored in the MySQL database as 'epasswd'. On login, I am using session, so a standard session_start() and eventual session_destroy() on logout are used. The reason I mention this is because I suspect my issue is session related. So normally this works well. User logs in and I check credentials as follows in one part of my auth routine: elseif(UserAuth($UserId,$Password)){ $UserLogin=$UserId; session_start(); $_SESSION['UserLogin'] = $UserLogin; sql_insertActivity(); header("Location: home.php"); And the auth routine is as follows: <? function UserAuth($UserId,$Password){ global $conn; $Stmt="select epasswd from Users where UserId='$UserId' and Approved='1' or Approved='-1' or Approved='-2'"; $Result = mysql_query($Stmt, $conn) or die(mysql_error()); $Result=mysql_fetch_row($Result); $epasswd=$Result[0]; $retval=($epasswd==crypt($Password,$epasswd)); return($retval); } ?> So I am checking for a valid UserID and Password on form input, and I have a few other variables set for approved status. The retval checks the password they enter versus the encrypted value for a match. This usually works well. Then login occurs and session started, etc. Here is the issue. I added a quick admin routine a little while ago which helps reset a user's password to a temporary value. Once this value is set, along with a setting of approved=-1 in my database, then the user is re-directed to a Change Password screen to update his or her password. *Note: I changed the value to 'Charlie' for this discussion purpose. Here is that quick admin routine I run when I need to change a User to a temp setting: // ----- Establish database connection ----- require "../inc_php/inc_mysql_prod.php"; // $UserId=@$_GET['UserId']; $Password='Charlie'; $encrypt = crypt($Password,'6!68$7435!'); $sql = "UPDATE Users set epasswd='$encrypt', approved='-1' where UserId='$UserId'"; mysql_query($sql, $conn) or die(mysql_error()); So this does work as I validate the UserID is updated in the MySQL database along with an encrypted value for 'Charlie'. However, this is where things breakdown going forward. When the user logs in with the temp credentials, and enters in the Change password routine, their new password is saved in the table. However, when logging back in with the new credentials, the new password is not valid. And what's odd is that 'Charlie', the temp password, works for them on login and nothing else, no matter how many times they change the password in the form. So seems a case of session management out of control? What is the issue? I am defining session on all Php pages used, and have a logout to destroy session, etc. The temp password routine is something I run as an admin in the system and it doesn't have a session start statement. And I am not defining any global vars for Password. I lloked into session management and tried some UNSET paths and such, but may not be doing this correctly. Also I did a complete stop apache, remove all php sess_ files, restart and to no avail. I tried the clear my client side cookies deal in the browser, and still the same problem. What is odd is that this same set of code works fine on my other server, but breaks down on the mirrored server. They are essentially twins in all setup. Some minor differences between the two servers regarding PHP setup that might(?) make a difference. DEV server: SERVER_SOFTWARE Apache/2.2.3 (Red Hat) PROD server: (server showing the issues): SERVER_SOFTWARE Apache/2.2.3 (CentOS) HTTP_COOKIE PHPSESSID=3gocr0hhelvsjjlt63pp4qlnp3 _REQUEST["PHPSESSID"] 3gocr0hhelvsjjlt63pp4qlnp3 _COOKIE["PHPSESSID"] 3gocr0hhelvsjjlt63pp4qlnp3 _SERVER["HTTP_COOKIE"] PHPSESSID=3gocr0hhelvsjjlt63pp4qlnp3 Thanks appreciate the help! -Eddie
  12. Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10048) in C:\xampp\htdocs\chat\admin_logout.php on line 22 Could not connect: Can't connect to MySQL server on 'localhost' (10048) can anyone help me in finding the error ?? Thanks for your help !!
  13. I have been using an inventory application built on PHP/MySQL. Since this morning I could submit the data and they were perfectly reflected on the MySQL Table. However, for a few hours I cannot save the submitted data to the table and it doesn't show any error message. Please note no change have been made since it was successfully running. The developer of this application is not available right now. PLEASR HELP I AM A NOVICE IN PHP/MYSQL.
  14. This is more of a database architect question. I am building a CMS for website development. I am ready to use it for the first time on one of my clients. Now, my issue is is how to set up some or one of my table(s) for some areas that my client wants to be able to change in the admin section. In their website on the front page, I put together this nice block slider. Its 6 blocks with text, a background image and nice effects. At first it was always going to be static, which was no issue at all, but later they came to me and asked if they could be able to change words in the boxes themselves in the admin section.. Of course this can be easily done by creating a table that is associated with this home page block thing and each row in the table will correspond to one of the blocks on the home page. But I believe there might be an easier way to store this type of data without having to create another table for every feature the client wants to edit, for example they also want to be able to edit a slider on another page. The WordPress database then came into my mind and how they store most of their data as JSON. So I was then thinking of creating a table named 'modules' for examples with three columns (id, title, data). Then inside the data column store the editable fields as a JSON string object. For example a row could like like : 1, "Front Page Box Slider", {"slider-home" : [ {"data" : "value", "img_1", "value1"}, {"data" : "value", "img_2", "value2"} ]} I've been doing a bit of research on this and people have just been saying, never do this if you do want your data to be searched through, which I don't. Can anyone tell me why or why not I should do this, or maybe a better solution to my problem? Thank you
  15. I have a DB It gets records from a sensor every 5 min This is then displayed on a Chart When I request 4 Hrs I get 48 records x 12 Sensors, Not a issue When I request 12 Hrs I get 144 records x 12 Sensors, A little Slower but Still OK But as I start to request longer periods Like 7 Days I start getting larger and Larger data sets causing time out issues with the AJAX Calls (4-30MB per sensor downloads of data) When looking at 4 weeks I really cant see the fine detail so is there a way to request records from MYSQL that drops some records in between Kinda like the Step function in a For loop If I request a period that has 2048 records but only want 204 records is there a way to say give me From -> To dates Step 10 and only return every 10th Record in the data set Thanks
  16. I'm using a web service call, my response comes back as an array: stdClass Object ( [contractVehicle] => Array ( [0] => ITSchedule70 [1] => ITCommodityProgram ) ) I then need to hand this response off to anther developer who needs to know that "ITSchedule70" is the selected Contract Vehicle (actually there could be more than one, this only returns one for now), so he can insert it into a SQL query against a MySQL database (to match "Products" with the right "Contract Vehicle". So basically how do I do that? How to wrap it up and send it off, and how to insert a query?
  17. I am having trouble trying to save my image file names to mysql after reading a dir. I am trying to use the file below. Any help would be appreciated. I was originallly getting the files to list but they we not showing up in the database. Now the page shows up blank. <?php require("config_0.php"); // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("test")or die("cannot select DB"); $files = glob("images/*.jpg"); for ($i=1; $i<count($files); $i++) { $num = $files[$i]; $sql="INSERT INTO images (url) VALUES ('$num')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo '<img src="'.$num.'" alt="random image">'." "; } ?>
  18. Hi guys, i'm in a dead end with this. I'm more a design guy and i'm trying to implement these 2 payment gateways on a website i'm launching soon but don't know how to do it. I have the php sample files from bitpay and the other payment gateway (offline atm payments). I can implement a button for the payment but the php needed to receive payment notification, ipn or callback, and update user balance in the database it's way out of my knowlegde. Can someone give me a hand in implementing this? I have paypal runing but i'd like to have these other two options. Thanks in advance, Tiago Vasconcelos
  19. Hi all, Im a bit new to this forum so sorry if I ask rather silly questions.. Anyways I got given a project with entails making a simple php calendar, with hover effects to show the daily events ect.. I would use the source I was given but its making nearly no sense to me at this point.. Anyone know of a tutorial or vid I could read/watch to get a grip of what is needed.. Or maybe a snippet and/or advice how to tackle it Thanks in advance
  20. i have a register and login page where the users can perform register and login task and their detail gets saved in the database. my requirement is that when the user enters his/her account, they should be redirected to their profile page, where they can view all their profile details. Till now i have been able to make the user login and dislay a part of their profile page, for this purpose the code that i am using is <code> <?php include('retailer_session.php'); ?> <!DOCTYPE> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Welcome to your homepage</title> <meta name="viewport" content="width=device-width", initial-scale=1.0"> <link href="css/bootstrap.min.css" rel="stylesheet" /> <link href="css/styles.css" rel="stylesheet" /> <link href="css/carousel.css" rel="stylesheet"> </head> <body> <div id="profile"> <div class="navbar navbar-inverse navbar-static-top"> <div class="container"> <a href="#" class = "navbar-brand"> <id="welcome">Welcome : <i><?php echo $login_session; ?></i> </a> <button class = "navbar-toggle" data-toggle = "collapse" data-target = ".navHeaderCollapse"> <span class = "icon-bar"> </span> <span class = "icon-bar"> </span> <span class = "icon-bar"> </span> </button> <div class="collapse navbar-collapse navHeaderCollapse"> <ul class = "nav navbar-nav navbar-right"> <li class ="active"> <a href="admin_profile.php">Home</a></li> <li> <a href="retailer_logout.php"><id="logout">Log Out</a></li> </ul> </div> </div> </div> </div> </body> </html> Apart from this i want a listing where the user can view their data and edit their details as it is done on many websites. can anyone please help me with the code </code>
  21. I am working on a project that involves providing details for county government, and if applicable, cities independent of county oversight. Virginia is a state with a lot of independent cities, so I wanted to echo them in a separate list underneath the county governments. This code works fine when displaying Virginia information. However, I would like to hide the Independent Cities heading in every other state. For some reason, this code still echoes the Independent Cities heading in states without independant cities in the database. Any thoughts or wisdom? (sorry for pasting the whole bulky code) $query = "SELECT * FROM state WHERE st_id=$statecode"; $result = mysql_query($query) or die("Query $query failed : " . mysql_error()); $row = mysql_fetch_assoc($result); $state_name=$row["st_name"]; $state_note=$row["state_notes"]; echo "<h2>Counties of " . $state_name; "</h2>\n"; $query = "SELECT * FROM counties WHERE st_id=$statecode AND visible=1 ORDER BY county_name ASC"; $result = mysql_query($query) or die("Query $query failed : " . mysql_error()); echo "<table width=100%><tr><td valign=top width=33%>\n"; $count = 1; $col = 0; $rowcount = (int)(mysql_num_rows($result) / 3) + 1; $remainder = mysql_num_rows($result) - ($rowcount - 1) * 3; /* ********************************************************* */ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<a href=\"services.php?county=".$row["county_id"]."\">".$row["county_name"] . "</style></a><br />\n"; $count = $count + 1; if ((($remainder > 0) && ($count == ($rowcount + 1))) || (($remainder <= 0) && ($count == $rowcount))) { $col = $col + 1; if ($col!=3) { echo "</td><td valign=top width=33%>\n"; $count = 1; if ($remainder > 0) $remainder = $remainder - 1; } } } /* ********************************************************* */ echo "</td></tr></table><br>\n"; mysql_free_result($result); /* ********************************************************* */ $query2 = "SELECT * FROM cities WHERE st_id=$statecode AND visible=1 ORDER BY city_name ASC"; $result2= mysql_query($query2) or die("Query $query failed : " . mysql_error()); $city_id = $row['city_id']; $city_name = $row['city_name']; if ($city_id!="") { echo "<h3>Independent cities of " . $state_name; "</h3>\n"; echo "<table width=100%><tr><td valign=top width=33%>\n"; $count2 = 1; $col2 = 0; $rowcount2 = (int)(mysql_num_rows($result2) / 3) + 1; $remainder2 = mysql_num_rows($result2) - ($rowcount2 - 1) * 3; /* ********************************************************* */ while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { echo "<a href=\"services.php?county=".$row["city_id"]."\">".$row["city_name"] . "</style></a><br />\n"; $count2 = $count2 + 1; if ((($remainder2 > 0) && ($count2 == ($rowcount2 + 1))) || (($remainder2 <= 0) && ($count2 == $rowcount2))) { $col2 = $col2 + 1; if ($col2!=3) { echo "</td><td valign=top width=33%>\n"; $count2 = 1; if ($remainder2 > 0) $remainder2 = $remainder2 - 1; } } } /* ********************************************************* */ echo "</td></tr></table><br>\n"; mysql_free_result($result2); /* ********************************************************* */ } ?>
  22. So currently I have 2 files that pretty much does the same thing but connects to 2 different tables. I sort of want to merge it together to save file space and make everything more efficient: caseprice.php <?php $q = intval($_GET['q']); $con = mysqli_connect('localhost','root','','test'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"compcase"); $sql="SELECT * FROM compcase WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['case_price'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> caselightprice.php <?php $q = intval($_GET['q']); $con = mysqli_connect('localhost','root','','test'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"complight"); $sql="SELECT * FROM complight WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['caselight_price'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> also how can I use all this to display a sub total on my page when the radio buttons are pressed? I have it so the price shows I just cant seem to add them both up: index.php <script> //CASE PRICE// function casePrice(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","caseprice.php?q="+str,true); xmlhttp.send(); } //CASE PRICE// //CASE LIGHT PRICE// function caselightPrice(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","caselightprice.php?q="+str,true); xmlhttp.send(); } //CASE LIGHT PRICE// </script> <Input type = 'Radio' Name ='compcase' onchange="casePrice(this.value)" value= '1' />NZXT Phantom Enthusiast USB3.0 Full Tower Case - White <br /> <Input type = 'Radio' Name ='compcase' onchange="casePrice(this.value)" value= '2' />Corsair Obsidian 750D Large Tower Case Black <br /> <Input type = 'Radio' Name ='compcase' onchange="casePrice(this.value)" value= '3' />Cooler Master CM Storm Trooper Black Full Tower Gaming Case <br /><br /> <Input type = 'Radio' Name ='caselight' onchange="caselightPrice(this.value)" value= '1' />Red<br /> <Input type = 'Radio' Name ='caselight' onchange="caselightPrice(this.value)" value= '2' />Green <br /><br /> <div id="txtHint"><b>Processor listed here</b></div> <div id="txtTest"><b>Processor listed here</b></div> as you can see, the price is displaying separately. Can I somehow calculate it as a subtotal instead of separate totals? Thanks for any help.
  23. Hi All, The Problem: I'm trying to learn how to take records from the NAME row of one table (i.e. Tom, Jim, Chris, Mike) and put them into a SELECT (drop down menu) box, then select a name and save it to a DIFFERENT table where the row is also called NAME, and THEN have that selection I just saved show in the SELECT box as SELECTED when the page refreshes. I have found a hundred websites showing how to bind a SELECT box to a table and put them into a SELECT box via $key => $val and even how to save it to ANOTHER textbox on the page, which is a lot easier, but never a step further as described in the first paragraph above. Seems unbelievable to me since it's so common. Maybe I'm just not using the proper search terms/keywords. Here's an example: Let's say you wanted to notify 3 people of your birthday. So, on the notification page, you would enter three names of people you would want notified all in separate input textboxes with [keys]. So, you enter John, Chris, and Tom into three text boxes and save the page. Done. Now, on another page, I have -- say .... five select boxes. For arguments sake, let's just say I click on all of them one at a time. In each of them, I would only see three names (John, Chris, and Tom). Now, in the first SELECT box I click on John. In the second select box I click on Chris, and on the third I click on Tom. Then save the form. I would like to see John, Chris, and Tom in the first three boxes after refreshing and I would like to see SELECT A NAME on the last two Select boxes that we never did anything with. Remember, there are NO default names in the first table with row called NAMES. They are populated by the user and saved to the row. I'm attaching an image of what the page looks like that I want to see the names and be able to select them. Does anyone have a link to a site that shows how to do this... or maybe have something very basic that would show me the process? Or, if not too difficult, maybe you could show me? Thanks in advance for any help!
  24. i am looking for simple php mysql base event calender..that shows upcoming events...i would very helpful for your help.any tutorial.video.or helping link..??
  25. hey i was trying to make a new login system with member area the problem is that i wanted to add point system which i can add points manual to members by creating a new column called 'points' and add the following code to member area echo 'you got , '.$_SESSION['points']; but it didn`t work here is my member.php page any tip or advice would be helpful much appreciated ♥ <?php session_start(); $user = $_SESSION['points']; //Connects to your Database mysql_connect("sql206.byethost15.com", "b15_15261909", "7076300") or die(mysql_error()); mysql_select_db("b15_15261909_logim") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } //otherwise they are shown the admin area else { echo "Admin Area<p>"; echo "Your Content<p>"; echo 'Welcome, '.$_SESSION['username']; echo 'you got 34, '.$_SESSION['points']; echo "<a href=logout.php>Logout</a>"; } } } else //if the cookie does not exist, they are taken to the login screen { header("Location: login.php"); } ?> my login.php page <?php session_start(); $_SESSION['points'] = $_POST['points']; include("dbconnect.php"); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: members.php"); } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('That user does not exist in our database. <a href=add.php>Click Here to Register</a>'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area header("Location: members.php"); } } } else { // if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?>
×
×
  • 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.