PHP - Display Existing Database Where I Can Edit In Html
hi again,
after I clicked a particular data to edit, it will bring me to a html which i created, UpdateRecordForm.html In there, how do i retrieve the data from database so it will show the data in the textbox that i can edit it. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>adding a new data record</title> </head> <body> <form id="form1" name="form1" method="post" action="processUpdateRecord.php"> <p> <label>Student Number: <input name="StudentNumber" type="text" id="StudentNumber" size="10" /> </label> </p> <p> <label>First Name: <input name="FirstName" type="text" id="FirstName" size="20" /> </label> </p> <p> <label>Last Name: <input name="LastName" type="text" id="LastName" size="20" /> </label> </p> <p> <label>Email Address: <input name="EmailAddr" type="text" id="EmailAddr" size="50" /> </label> </p> <p> <label>Telephone: <input name="PhoneNumber" type="text" id="PhoneNumber" size="20" /> </label> </p> <p> <input type="submit" name="submit" id="submit" value="Update Record" /> </p> </form> </body> </html> Similar TutorialsEDIT: sorry - new to posting guidelines - using XAMPP with mysql 5.1.44 (I think this is correct!!) Newbie question he I have successfully created a form that that displays students (based on a selected lesson/group/date) with the ability to enter scores. I'm now trying to set the form up so that if data already exists then it is displayed in the form. Eg: if a member of staff choses group 7AS, lesson 1, 24/09/2010 and another member of staff has entered a score already for one student it shows up in the <select> drop down by using Code: [Select] <option>" . $scorevalue . "</option> I had this working at one point but have made a change somewhere and cannot get it working again! can anyone spot an obvious mistake I am making? The code I am using is as follows: Code: [Select] <input type="hidden" name="tutor" value="<?php echo $_GET["tutor"]; ?>" /> <input type="hidden" name="date" value="<?php echo $_GET["date"]; ?>" /> <input type="hidden" name="lesson" value="<?php echo $_GET["lesson"]; ?>" /> <?php error_reporting(-1); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("lakeside", $con); $result = mysql_query("SELECT students.admin, students.fname, students.surname, students.tutor FROM students WHERE tutor='$_GET[tutor]' ORDER BY students.tutor, students.surname"); echo "<table class='scores'> <tr> <th>Admin</th> <th>Firstname</th> <th>Surname</th> <th>Tutor</th> <th>Score</th> <th>Code</th> <th>Comment</th> </tr>"; while($row = mysql_fetch_array($result)) { $sqlstatement = "SELECT * FROM scores where admin = '" . $row['admin'] . "' and lesson = '" . $_GET[lesson] . "' and date = '" . $_GET[date] . "' "; $scorevalue = mysql_query($sqlstatement); echo " . $score . "; while($rowvalue = mysql_fetch_array($scorevalue)) { $score = $rowvalue['score']; $comment = $rowvalue['comment']; $code = $rowvalue['code']; } echo "<tr>"; echo "<td>" . $row['admin'] . "</td>"; echo "<td>" . $row['fname'] . "</td>"; echo "<td>" . $row['surname'] . "</td>"; echo "<td>" . $row['tutor'] . "</td>"; echo "<td><select name='score" . $row['admin'] . "' value='{$row['score']}' /> <option>" . $scorevalue . "</option> <option>0</option> <option>1</option> <option>2</option> <option>2.5</option> <option >3</option> <option>3.5</option> <option>4</option> </select> </td>"; Hi guys, I've spent quite a bit of time searching the site and have a good start - hoping for some help. I run a hockey league and have a database that keeps our stats. Regular stats page is here - http://okchockey.com/stats/stats.php I need a web form that can update existing records in the database. Maybe I am going thru this the wrong way - please let me know. I know there's a better way than my current version. Basically I have a table that has fields of Week, Jersey, Name, Goals, Assists, Points, and Penatly_Min. Again - excuse the newbie-ness - what I did is have a record for each player for each week. I already pre-created a record for each player for each week. I just need a web form that will update these existing records. I already created one that can add new records but I am having a tough time creating one to update existing ones. I'd like to be able to select the week (week 1-10) then select a player and update his stats for that particular week. Hopefully this makes sense. If anyone has some sample code I can look at I'd sure appreciate it. Really struggling trying to teach myself PHP Hello and good day to all of you I have passed my midterms project(Online Shopping) with a score of 94 in PHP ( Click here to see file ) ( Sorry if the design is too ugly, I'm just new in programming XD ) Now our finals project will be a PHP site again but now with a database in it.. So instead of making a new project/design for a site, why not just add a database to my existing midterms? I would like to ask for some help here in helping me on connecting to the database, adding a database/tables and anything that would be of help like suggesting Databases would be like, - Users ( Admin and Members ) - Upper Clothing ( Shirts, Jackets, Long Sleeves, Raglan and etc ) - Lower Clothing ( Pants, Shorts, Boxers and etc ) - Stock on a current item - Single member's Transaction History - All user's Transaction History Is there a way that I could add those database named above to my project? Thank you in advance! I currently have a MyBB forum and I'm going to attempt to create a top list for it, but I'd like users that have already registered on my forum to be able to log into the top list area and either add or edit their website on the top list. How would I go about creating a login script with an already existing MySQL database that contains my MyBB users? Hi there I never had any php lessons. But I made a site, and now I'm kinda sorta working on a CMS so that someone else can edit the information on the site. Now I was wondering if there was a simple way of displaying all the data from a table, and editing it (not in phpmyadmin). This is my current method; it's rather sloppy but it works like a charm: Code: [Select] mysql_select_db('yourdatabase')or die(mysql_error()); $query = mysql_query("SELECT * FROM activiteit ORDER BY datum"); if(isset($_POST['editActiviteit'])){ $id = mysql_real_escape_string(htmlentities($_POST['id'])); }else{ $id = ''; } echo "<table border='1'><tr><th>Begindatum</th><th>Einddatum</th><th>Titel</th><th>Omschrijving</th><th>Zichtbaar?</th><th>Aanpassen</th><th>Verwijderen</th><th>Voorbeeld</th></tr>"; while($row = mysql_fetch_array($query)){ if($id == $row['id']){ if(empty($row['einddatum'])){ $einddatum = "<input type='text' size='2' name='activiteitDagEind' placeholder='dd' />/<input type='text' size='2' maxlength='2' name='activiteitMaandEind' placeholder='mm' />/<input typ='text' size='4' maxlength='4' name='activiteitJaarEind' placeholder='jjjj' />"; }else{ $explode = explode('/',$row['einddatum']); $einddatum = "<input type='text' size='2' name='activiteitDagEind' value='$explode[0]' />/<input type='text' size='2' maxlength='2' name='activiteitMaandEind' value='$explode[1]' />/<input typ='text' size='4' maxlength='4' name='activiteitJaarEind' value='$explode[2]' />"; } $explode2 = explode('/',$row['datum']); $datum = "<input type='text' size='2' name='activiteitDag' value='$explode2[0]' />/<input type='text' size='2' maxlength='2' name='activiteitMaand' value='$explode2[1]' />/<input typ='text' size='4' maxlength='4' name='activiteitJaar' value='$explode2[2]' />"; if($row['actief'] == 0){ $actief = "<select name='actief'><option value='1'>1</option><option value='0' selected='selected'>0</option></select>"; }else{ $actief = "<select name='actief'><option value='1' selected='selected'>1</option><option value='0'>0</option></select>"; } echo "<form action='ward.php' method='post'>"; echo "<tr><td>$datum</td><td>$einddatum</td><td><input type='text' name='activiteitTitel' value='".$row['titel']."' /></td><td><textarea name='activiteitOmschrijving'>".$row['omschrijving']."</textarea></td><td>$actief</td><td><input type='hidden' value='".$row['id']."' name='id' /><input type='submit' value='Slaag op' name='saveActiviteit' /></form></td><td><form action='ward.php' method='post'><input type='hidden' value='".$row['id']."' name='id' /><input type='submit' name='verwijderActiviteit' value='verwijderen' /></form></td><td><input type='button' disabled='disabled' value='Voorbeeld' /></td></tr>"; }else{ echo "<tr><td>".$row['datum']."</td><td>".$row['einddatum']."</td><td>" . $row['titel'] . "</td><td>" . bbcode_format($row['omschrijving']) . "</td><td>" . $row['actief']."</td><td><form action='ward.php?fx=activiteit' method='post'><input type='hidden' value='".$row['id']."' name='id' /><input type='submit' value='Pas aan' name='editActiviteit' /></form></td><td><form action='ward.php' method='post'><input type='hidden' value='".$row['id']."' name='id' /><input type='submit' value='verwijderen' name='verwijderActiviteit' /></form></td><td><input type='button' value='Voorbeeld' onClick=\"parent.location='ward.php?fx=activiteit&voorbeeld=".$row['id']."'\" /></td></tr>"; } } echo "</table><br /><br />"; I just copy pasted all the code but I'll explain it in big lines: First I open a table. I manually enter a row with the headers. Then every result of the query gets shown in a cell. The last cells of each row contain a delete and an edit button. The delete button deletes that row with the hidden id and reloads the page. When the edit button is clicked, it sends a form with the name of the button, here 'editActiviteit', and the id of the entry. And then the page gets reloaded. When the query is then done again, it checks if $_POST['editActiviteit'] is set, and if it is, it displays input fields with the values in the cells instead of pure text, and a save button instead of a edit button. The system works just fine, but it's heaps of work every time I implement it, for activities, users, ... Also I've been told that table's are not the correct way for displaying results (and they also get a little stretched). How should it be displayed? Thanks in advance. Hi, very new to all this, so don't really know too much! I have been trying to edit some code to be able to retrieve some blocks of text from a database, then edit them and post them back. I have managed to retrieve them, however I can't seem to be able to post them back to the database edited. This is the code I'm using: Code: [Select] <?php require_once('config.php'); $con = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); if (!$con){ die('Failed to connect to server' . mysql_error()); } mysql_select_db(DB_DATABASE); $ide15 = $_POST[idf]; $query15 = "SELECT id,titleus,aboutus FROM about WHERE id = 1"; $result15 = mysql_query($query15) or die ("Query:<br />$query15<br />Error:<br />".mysql_error()); while ($row15 = mysql_fetch_assoc ($result15)) { $title15 = htmlentities ($row15['titleus']); $news15 = nl2br (strip_tags ($row15 ['aboutus'], '<a><b><i><u>')); echo "<form class ='addform' action='editabouttext.php' enctype='multipart/form-data' method='post'>"; echo "<p>Uttsav Title:<br /><input class='titlefield' type='text' name='title' value='$title15' /></p><br />"; echo "<p>Uttsav About:<br /> <textarea name='news' rows='1' cols='15'>$news15</textarea></p><br />"; echo "<p><input name='submit' type='submit' value='Submit' /></p>"; echo "</form>"; } if ($_POST['submit']) { mysql_select_db(DB_DATABASE); $upid = $_POST[idf]; $uptitle = $_POST[title]; $upnews = $_POST[news]; $upimage = $_FILES['userfile']['name']; $sql = "UPDATE about SET titleus = '$uptitle', aboutus = '$upnews', WHERE id = '1'"; mysql_query($sql); if ($_POST['submit']) { echo "<p class='admintext'>Your project thumbnail has now been edited - <a href='about.php'>View The About Page</a></p><br />"; $name = $_FILES['userfile']['name']; $type = $_FILES['userfile']['type']; $size = $_FILES['userfile']['size']; $tmpname = $_FILES['userfile']['tmp_name']; $ext = substr($name, strrpos($name, '.')); if (strstr($type, "image")) { move_uploaded_file($tmpname, "images/portfolio/".$name); } } } ?> I am using an apache server at the minute and have had this code working for other pages and scenarios, yet can't get it working on this, I think it may have something to do with the id of the post, but as I am only going to be using one post that will just get edited I took out the WHERE id = $ide15 and put in WHERE id = 1 as this is the id of the only post! Any help would be much appreciated! as I said, just starting to get to grips with things like this! Thank you Martin Hey everyone. I'm making a php/mysql game and I don't understand how do to this. please read the whole thing and dont just say use paypal. thanks in advanced. The game is free to play but if you want some extra perks like gold and what not I want to you be able to pay with real money to get them. I dont have ANY idea how to do this.... Say there are three parts 100gold 1,000gold 10,000gold $5 $10 $20 Is this possible: use paypal set up three different buttons/links for that then I know paypal asks if you wants to point them to a thankyou page so I would make the thankyou page have the PHP in it to update they database with the new gold values. the problem I see is how will paypal save their member id or user id number so my script in the thankyou page will update the right account and also what is stopping people from just going straight to the thankyou page without paying? Thanks for the info Hi, I have a webpage that the super administrator log's into. Once the super administrator is logged in he/she can view his/her clients. The super admins clients also have their own clients, once the super admins clients login they can view their own clients details who register with them. What i am trying to do is have a link on that clients name (for the super admins clients) that will bring me to a new page where i can edit his/her details that is stored in the mysql database. I have used INPUT buttons for each clients row in a FORM which works......but i know this is not the right way to do it. This is the code i have used to display the clients with the input button: <?php $query = "SELECT ID FROM clients WHERE username = '$username'"; $result = mysql_query($query); if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)){ $userID = $row['ID']; $query = "SELECT * FROM users WHERE userID = '$userID'"; $result = mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="0" cellspacing="3" cellpadding="3" width="100%"> <tr> <th width="30%"><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Username</font></th> <th><font face="Arial, Helvetica, sans-serif">Email Address</font></th> <th> </th> </tr> <?php $i=0; while ($i < $num) { $userID=mysql_result($result,$i,"userID"); $name=mysql_result($result,$i,"name"); $username=mysql_result($result,$i,"username"); $email=mysql_result($result,$i,"email"); ?> <tr> <td width="30%"><?php echo $name; ?></td> <td><?php echo $username; ?></td> <td><?php echo $email; ?></td> <td><form action="http://localhost/single-client.php?userID=<?php echo $userID; ?>&name=<?php echo $name; ?>" method="post" style="margin:0px;"> <input type="hidden" name="selectuser" id="selectuser" value="<?php echo $userID; ?>" /><input type="hidden" name="username1" id="username1" value="<?php echo $username; ?>" /><input type="hidden" name="name1" id="name1" value="<?php echo $name; ?>" /><input type="submit" name="submit" value="View Info" class="button" /></form></td> </tr> <?php $i++; }}} ?> </table> From the above code when i use the following code: ?userID=<?php echo $userID; ?>&name=<?php echo $name; ?> It doesn't make a difference .... it just displays the correct userID and name in the link. Once the INPUT button is clicked it will bring you to this page: <?php $query = "SELECT * FROM users WHERE userID = '".$_POST['selectuser']."' AND username = '".$_POST['username1']."'"; $result = mysql_query($query); if(mysql_num_rows($result)) { $userID = $_POST['selectuser']; while($row = mysql_fetch_assoc($result)){ $name = $row['name']; $userID = $row['userID']; $email = $row['email']; $username = $row['username']; $registered = $row['registered']; $last = $row['last']; ?> <?php echo $brokerID; ?> <table border="0" cellspacing="3" cellpadding="3" width="100%" summary="Client table"> <tr> <td><form action="http://localhost/single-client.php?userID=<?php echo $userID; ?>&name=<?php echo $name; ?>" method="post" style="margin:0px;"> <input type="hidden" name="selectuser" id="selectuser" value="<?php echo $userID; ?>" /><input type="hidden" name="username1" id="username1" value="<?php echo $username; ?>" /><input type="hidden" name="name1" id="name1" value="<?php echo $name; ?>" /><input type="submit" name="submit" value="Income" class="button" /></form></td> <td><form action="http://localhost/single-client.php?userID=<?php echo $userID; ?>&name=<?php echo $name; ?>" method="post" style="margin:0px;"> <input type="hidden" name="selectuser" id="selectuser" value="<?php echo $userID; ?>" /><input type="hidden" name="username1" id="username1" value="<?php echo $username; ?>" /><input type="hidden" name="name1" id="name1" value="<?php echo $name; ?>" /><input type="submit" name="submit" value="Bills" class="button" /></form></td> </tr> </table> <h2>Client Profile - <?php echo $_POST['name1']; ?></h2> <table border="0" cellspacing="3" cellpadding="3" width="100%"> <tr> <th><font face="Arial, Helvetica, sans-serif">Name</font></th> <th><font face="Arial, Helvetica, sans-serif">Username</font></th> <th><font face="Arial, Helvetica, sans-serif">Email Address</font></th> <th><font face="Arial, Helvetica, sans-serif">Registered</font></th> <th><font face="Arial, Helvetica, sans-serif">Last</font></th> </tr> <tr> <td><?php echo $name; ?></td> <td><?php echo $username; ?></td> <td><?php echo $email; ?></td> <td><?php echo $registered; ?></td> <td><?php echo $last; ?></td> </tr> </table> <?php } } else { echo "<p>Error</p>"; } ?> This page displays the correct user info. Is there a way to do it differently instead of using FORMS and INPUT buttons? and rather using links? Any help would be greatly appreciated. Sir/ma'am,
With the script I'm using to run my website, I've been trying to add an additional feature for the users to add/edit. I'll try to provide as much info as I can, hopefully it'll help.
Here is the code I'm using to display the user's unique info from the db.
<a class="wallet-edit"><?php echo $_SESSION['simple_auth']['INFO']?></a>That displays the user's info from the column 'INFO' perfectly. It's also a js popup to a menu to where I'm hoping to add a single textbox to edit the INFO. The script uses a similar function to edit the password with a popup. I've tried modifying the code to edit the INFO column but it doesn't work. Here is the default code it has to edit the password. I'm not sure if it can be changed to edit another column or needs a new piece of code for that. // user edit $('body').on('click', '.username-edit', function() { $('#modal').html(' '); var output = '<div class="modal-content"><h5><?php echo lang::get("Change password")?></h5><hr />'; output += '<h5><?php echo lang::get("New password:")?></h5><input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />'; output += '<h5><?php echo lang::get("Confirm password:")?></h5><input type="password" name="password2" id="password2" value="" class="text ui-widget-content ui-corner-all" />'; output += '</div>'; output += '<div class="modal-buttons right">'; output += '<button id="confirm-button" type="button" class="nice radius button"><?php echo lang::get("Change")?></button>'; output += '</div>'; output += '<a class="close-reveal-modal"></a>'; $('#modal').append(output); $('#second_modal').hide(); $('#modal').reveal(); $('#confirm-button').click(function(){ $('#password').css('border-color', '#CCCCCC'); $('#password2').css('border-color', '#CCCCCC'); var password = $('#password').val(); var password2 = $('#password2').val(); if(typeof(password) === 'undefined' || password == ''){ $('#password').css('border-color', 'red'); return false; } if(password != password2){ $('#password2').css('border-color', 'red'); return false; } password_data = encodeURIComponent(password); $.post("<?php echo gatorconf::get('base_url')?>", { changepassword: password_data} ).done(function(data) { // flush window.location.href = '<?php echo gatorconf::get('base_url')?>'; }); }); });If the code above can be edited to work with what I'm trying to do, it of course only needs one textbox and doesn't have to be confirmed by a second input. Please help! Thanks! Hello ,
I am trying to display my planned events in calendar using full calendar json, jquery. But its not getting displayed, but its getting inserted. I am not very good at jquery or json. please somebody help me in this...
here is my code
in my calendar.php (display page)
<div class="span8"> <div class="w-box w-box-green"> <div class="w-box-header"></div> <div class="w-box-content"> <div id='calendar_json'></div> </div> <div class="w-box-footer"> <p class="f-text">JSON events fetched from a script</p> </div> </div> </div> </div>and in my calendar.js jsonEvents: function() { if($('#calendar_json').length) { $('#calendar_json').fullCalendar({ header: { left: 'month,agendaWeek,agendaDay', center: 'title', right: 'prev,next' }, buttonText: { prev: '<i class="icon-chevron-left icon-white cal_prev" />', next: '<i class="icon-chevron-right icon-white cal_next" />' }, editable: true, firstDay: 1, // 0 - Sunday, 1 - Monday events: "php_helpers/json-events.php", eventDrop: function(event, delta) { alert(event.title + ' was moved ' + delta + ' days\n' + '(should probably update your database)'); } }); }json-events.php include("connect.php"); $year = date('Y'); $month = date('m'); //$db=public_db_connect(); $year = date('Y'); $month = date('m'); $command = "SELECT * FROM planner"; $result = mysql_query($command) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { echo "hi"; //$start = date("D, j M Y G:i:s T", strtotime($row['start'])); //$end = date("D, j M Y G:i:s T", strtotime($row['end_time'])); $start = date("Y-m-d", strtotime($row['from_time'])); //$start = "$year-$month-20"; $myid = $row['plan_id']; $eventsArray['plan_id'] = (int)trim($myid); //$eventsArray['title'] = $row['title']; $title = $row['company']; //$title = $row['title']; //echo $title; $eventsArray['company'] = $title; $eventsArray['from_time'] = $start; $eventsArray['to_time'] = $start; $eventsArray['url'] = "edit_calendar.php?calendarid=".$row['plan_id']; // $eventsArray['end'] = $end; // $eventsArray['allDay'] = false; $events[] = $eventsArray; } echo json_encode($events); Help please.. 50yr old PHP noob.. I have a PHP script that runs a personality survey and returns the dominant personality type, but I need to display the results as a bar chart reflecting the % totals for each of the 4 personality types. Code is he http://codepad.org/wQN3qN3v Grateful for any help! Hi friends. I want to php code on how i can modify my retrieved database values from a particular table before echoing out. Please could you help me correct the code. Or if there is any better way of editing loop datas before printing out, please kindly drop the code for me. Thanks <?php please if there is any better way of editing loop values from mysql database before printing out, please kindly drop the code for me. Thanks Let me apologize in advance for what may seem like a very stupid question for most of you. I am very new to php. I am simply trying to view/html in a .PHP file using Alleycode text editor. When I download the file from the server to my local PC, open the file in Alleycode, I cannot see the HTML. All that I see is the PHP code. Can someone provide me with instruction on how I might view then edit the HTML? Here is the code from Alleycode: <?php /*******************************************************************\ * CashbackEngine v1.1 * http://www.CashbackEngine.net * * Copyright (c) 2010 CashbackEngine Software. All rights reserved. * ------------ CashbackEngine IS NOT FREE SOFTWARE -------------- \*******************************************************************/ session_start(); require_once("inc/config.inc.php"); require_once("inc/pagination.inc.php"); $results_per_page = RESULTS_PER_PAGE; $cc = 0; function getCategory($category_id, $description = 0) { if (isset($category_id) && is_numeric($category_id) && $category_id != 0) { $query = "SELECT name, description FROM cashbackengine_categories WHERE category_id='".(int)$category_id."'"; $result = smart_mysql_query($query); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); if ($description == 1) return $row['description']; else return $row['name']; }else { return "Category not found"; } } else { if ($description != 1) return "Retailers"; } } ////////////////// filter ////////////////////// if (isset($_GET['column']) && $_GET['column'] != "") { switch ($_GET['column']) { case "title": $rrorder = "title"; break; case "added": $rrorder = "added"; break; case "visits": $rrorder = "visits"; break; case "cashback": $rrorder = "cashback"; break; default: $rrorder = "title"; break; } } else { $rrorder = "title"; } if (isset($_GET['order']) && $_GET['order'] != "") { switch ($_GET['order']) { case "asc": $rorder = "asc"; break; case "desc": $rorder = "desc"; break; default: $rorder = "asc"; break; } } else { $rorder = "asc"; } ////////////////////////////////////////////////// if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0) { $page = (int)$_GET['page']; } else { $page = 1; } $from = ($page-1)*$results_per_page; $where = ""; if (isset($_GET['cat']) && is_numeric($_GET['cat']) && $_GET['cat'] > 0) { $cat_id = (int)$_GET['cat']; unset($retailers_per_category); $retailers_per_category = array(); $retailers_per_category[] = "111111111111111111111"; $sql_retailers_per_category = smart_mysql_query("SELECT retailer_id FROM cashbackengine_retailer_to_category WHERE category_id='$cat_id'"); while ($row_retailers_per_category = mysql_fetch_array($sql_retailers_per_category)) { $retailers_per_category[] = $row_retailers_per_category['retailer_id']; } $where .= "retailer_id IN (".implode(",",$retailers_per_category).") AND"; } if (isset($_GET['letter']) && in_array($_GET['letter'], $alphabet)) { $ltr = mysql_real_escape_string(getGetParameter('letter')); if ($ltr == "0-9") { $where .= " title REGEXP '^[0-9]' AND"; }else{ $ltr = substr($ltr, 0, 1); $where .= " UPPER(title) LIKE '$ltr%' AND"; } } $where .= " status='active'"; if ($rrorder == "cashback") $query = "SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY ABS(cashback) $rorder LIMIT $from, $results_per_page"; else $query = "SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY $rrorder $rorder LIMIT $from, $results_per_page"; $total_result = smart_mysql_query("SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY title ASC"); $total = mysql_num_rows($total_result); $result = smart_mysql_query($query); $total_on_page = mysql_num_rows($result); /////////////// Page config /////////////// $PAGE_TITLE = getCategory($_GET['cat']); require_once ("inc/header.inc.php"); ?> <h1><?php echo getCategory($_GET['cat']); ?></h1> <?php if ($total > 0) { ?> <p class="category_description"><?php echo getCategory($_GET['cat'], 1); ?></p> <div id="alphabet"> <ul> <li><a href="/retailers.php">All</a></li> <?php $numLetters = count($alphabet); $i = 0; foreach ($alphabet as $letter) { $i++; if ($i == $numLetters) $lilast = ' class="last"'; else $lilast = ''; if (isset($cat_id) && is_numeric($cat_id)) echo "<li".$lilast."><a href=\"/retailers.php?cat=$cat_id&letter=$letter\">$letter</a></li>"; else echo "<li".$lilast."><a href=\"/retailers.php?letter=$letter\">$letter</a></li>"; } ?> </ul> </div> <div class="browse_top"> <div class="sortby"> <form action="retailers.php" id="form1" name="form1" method="get"> <span>Sort by:</span> <select name="column" id="column" onChange="document.form1.submit()"> <option value="title" <?php if ($_GET['column'] == "title") echo "selected"; ?>>Name</option> <option value="visits" <?php if ($_GET['column'] == "visits") echo "selected"; ?>>Popular</option> <option value="added" <?php if ($_GET['column'] == "added") echo "selected"; ?>>Newest</option> <option value="cashback" <?php if ($_GET['column'] == "cashback") echo "selected"; ?>>Cashback</option> </select> <select name="order" id="order" onChange="document.form1.submit()"> <option value="desc"<?php if ($_GET['order'] == "desc") echo "selected"; ?>>Descending</option> <option value="asc" <?php if ($_GET['order'] == "asc") echo "selected"; ?>>Ascending</option> </select> <?php if ($cat_id) { ?><input type="hidden" name="cat" value="<?php echo $cat_id; ?>" /><?php } ?> <?php if ($ltr) { ?><input type="hidden" name="letter" value="<?php echo $ltr; ?>" /><?php } ?> <input type="hidden" name="page" value="<?php echo $page; ?>" /> </form> </div> <div class="results"> Showing <?php echo ($from + 1); ?> - <?php echo min($from + $total_on_page, $total); ?> of <?php echo $total; ?> </div> </div> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="5"> <?php while ($row = mysql_fetch_array($result)) { $cc++; ?> <tr class="<?php if (($cc%2) == 0) echo "even"; else echo "odd"; ?>"> <td width="125" align="center" valign="middle"> <?php if ($row['featured'] == 1) { ?><span class="featured" alt="Featured Retailer" title="Featured Retailer"></span><?php } ?> <div id="shadow"><a href="/view_retailer.php?rid=<?php echo $row['retailer_id']; ?>"><img src="<?php if (!stristr($row['image'], 'http')) echo "/img/"; echo $row['image']; ?>" width="<?php echo IMAGE_WIDTH; ?>" height="<?php echo IMAGE_HEIGHT; ?>" alt="<?php echo $row['title']; ?>" title="<?php echo $row['title']; ?>" border="0" class="imgs" /></a></div> </td> <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="80%" align="left" valign="top"> <a class="retailer_title" href="/view_retailer.php?rid=<?php echo $row['retailer_id']; ?>"><?php echo $row['title']; ?></a> </td> <td nowrap="nowrap" width="20%" align="right" valign="top"> <span class="cashback"><?php echo DisplayCashback($row['cashback']); ?>X Points</span> </td> </tr> <tr> <td colspan="2" valign="middle" align="left"><p class="retailer_description"><?php echo $row['description']; ?> </p></td> </tr> <tr> <td valign="middle" align="left"> <?php if ($row['conditions'] != "") { ?> <div class="cashbackengine_tooltip"> <a class="conditions" href="#">Conditions</a> <span class="tooltip"><?php echo $row['conditions']; ?></span> </div> <?php } ?> <a class="favorites" href="#" onclick="if (confirm('Are you sure you want to add this retailer to your favorites?') )location.href='/myfavorites.php?act=add&rid=<?php echo $row['retailer_id']; ?>'">Add to Favorites</a> </td> <td valign="middle" align="right"> <a class="go2store" href="/go2store.php?id=<?php echo $row['retailer_id']; ?>" target="_blank">Go to Store</a> </td> </tr> </table> </td> </tr> <?php } ?> <tr> <td valign="middle" align="center" colspan="2"> <?php $params = ""; if (isset($cat_id) && $cat_id > 0) { $params = "cat=$cat_id&"; } if (isset($ltr) && $ltr != "") { $params = "letter=$ltr&"; } echo ShowPagination("retailers",$results_per_page,"retailers.php?".$params."column=$rrorder&order=$rorder&","WHERE ".$where); ?> </td> </tr> </table> <?php }else{ ?> <p align="center">There are no stores to list in this category!<br/><br/><a class="goback" href="#" onclick="history.go(-1);return false;">Go Back</a></p> <?php } ?> <?php require_once ("inc/footer.inc.php"); ?> Here is the code from the browser (View Source) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Retailers | Bonus.me</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="/css/style.css" /> <script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="/js/jquery.autocomplete.js"></script> <script type="text/javascript" src="/js/cashbackengine.js"></script> <link rel="shortcut icon" href="/favicon.ico" /> <link rel="icon" type="image/ico" href="/favicon.ico" /> </head> <body> <div id="container"> <div id="header"> <div id="logo"><a href="http://www.bonus.me/"><img src="/images/LogoSiteFinal.png" alt="Bonus.me" title="Bonus.me" border="0" /></a></div> <div id="links"> <a href="/login.php">Log In</a> | <a href="/register.php">Sign Up</a> </div> <div id="searchbox"> <form action="search.php" method="get" id="searchfrm" name="searchfrm"> <input type="text" id="searchtext" name="searchtext" class="search_inputt" value="Search for stores..." onclick="if (this.defaultValue==this.value) this.value=''" onkeydown="this.style.color='#000000'" onblur="if (this.value=='') this.value=this.defaultValue" /> <input type="hidden" name="action" value="search" /> <input type="submit" class="search_button" value="" /> </form> </div> </div> <div id="menu"> <a href="/">Home</a> <a href="/retailers.php">Online Shopping</a> <a href="/instore.php">In Store Shopping</a> <a href="/myaccount.php">My Account</a> <a href="/withdraw.php">My Rewards</a> <a href="/invite.php">Get More</a> <a href="/benny.php">Benny</a> </div> <div id="column_left"> <div class="box"> <div class="top">Member Login</div> <div class="middle"> <form action="login.php" method="post"> Email Address:<br/> <input type="text" class="inputt" name="username" value="" size="22" /> Password:<br/> <input type="password" class="inputt" name="password" value="" size="22" /> <input type="hidden" name="action" value="login" /> <input type="submit" class="butt" style="margin-top: 2px;" name="login" id="login" value="Login" /> <br/><br/><a href="/forgot.php">Forgot your password?</a> <br/><br/>Not a Member? <a href="/register.php">Sign Up!</a> </form> </div> <div class="bottom"> </div> </div> <div class="box"> <div class="top">Shop by Category</div> <div class="middle"> <ul id="categories"> <li><a href="/retailers.php">All Stores</a></li> <ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=41">Art, Music & Photo</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=40">Automotive</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=1">Books & Magazines</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=38">Department & Discount</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=6">Education</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=7">Electronics & Computers</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=2">Fashion & Apparel</a></li></ul><ul style='padding-left:10px;margin:0;'><li><a href="/retailers.php?cat=36">Children's Fashion</a></li></ul><ul style='padding-left:10px;margin:0;'><li><a href="/retailers.php?cat=35">Men's Fashions</a></li></ul><ul style='padding-left:10px;margin:0;'><li><a href="/retailers.php?cat=42">Shoes</a></li></ul><ul style='padding-left:10px;margin:0;'><li><a href="/retailers.php?cat=34">Women's Fashion</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=9">Flowers</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=10">Food & Drink</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=12">Gifts & Party</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=13">Health & Beauty</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=14">Home & Garden</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=16">Jewelry</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=17">Mobile Phones & Accesories</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=19">Office</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=22">Pets</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=39">Recreation & Leisure</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=15">Software</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=23">Sports & Fitness</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=24">Toys & Games</a></li></ul><ul style='padding-left:0px;margin:0;'><li><a href="/retailers.php?cat=37">Travel</a></li></ul> </ul> </div> <div class="bottom"> </div> </div> </div> <div id="column_center"> <h1>Retailers</h1> <p class="category_description"></p> <div id="alphabet"> <ul> <li><a href="/retailers.php">All</a></li> <li><a href="/retailers.php?letter=0-9">0-9</a></li><li><a href="/retailers.php?letter=A">A</a></li><li><a href="/retailers.php?letter=B">B</a></li><li><a href="/retailers.php?letter=C">C</a></li><li><a href="/retailers.php?letter=D">D</a></li><li><a href="/retailers.php?letter=E">E</a></li><li><a href="/retailers.php?letter=F">F</a></li><li><a href="/retailers.php?letter=G">G</a></li><li><a href="/retailers.php?letter=H">H</a></li><li><a href="/retailers.php?letter=I">I</a></li><li><a href="/retailers.php?letter=J">J</a></li><li><a href="/retailers.php?letter=K">K</a></li><li><a href="/retailers.php?letter=L">L</a></li><li><a href="/retailers.php?letter=M">M</a></li><li><a href="/retailers.php?letter=N">N</a></li><li><a href="/retailers.php?letter=O">O</a></li><li><a href="/retailers.php?letter=P">P</a></li><li><a href="/retailers.php?letter=Q">Q</a></li><li><a href="/retailers.php?letter=R">R</a></li><li><a href="/retailers.php?letter=S">S</a></li><li><a href="/retailers.php?letter=T">T</a></li><li><a href="/retailers.php?letter=U">U</a></li><li><a href="/retailers.php?letter=V">V</a></li><li><a href="/retailers.php?letter=W">W</a></li><li><a href="/retailers.php?letter=X">X</a></li><li><a href="/retailers.php?letter=Y">Y</a></li><li class="last"><a href="/retailers.php?letter=Z">Z</a></li> </ul> </div> <div class="browse_top"> <div class="sortby"> <form action="retailers.php" id="form1" name="form1" method="get"> <span>Sort by:</span> <select name="column" id="column" onChange="document.form1.submit()"> <option value="title" >Name</option> <option value="visits" >Popular</option> <option value="added" >Newest</option> <option value="cashback" >Cashback</option> </select> <select name="order" id="order" onChange="document.form1.submit()"> <option value="desc">Descending</option> <option value="asc" >Ascending</option> </select> <input type="hidden" name="page" value="1" /> </form> </div> <div class="results"> Showing 1 - 2 of 2 </div> </div> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="5"> <tr class="odd"> <td width="125" align="center" valign="middle"> <div id="shadow"><a href="/view_retailer.php?rid=13"><img src="<a href="http://click.linksynergy.com/fs-bin/click?id=8jghEyj/xMI&offerid=226353.10000004&subid=0&type=4"><IMG border="0" alt="Fanzz General Banner 120x90" src="http://ad.linksynergy.com/fs-bin/show?id=8jghEyj/xMI&bids=226353.10000004&subid=0&type=4&gri" width="120" height="60" alt="Fanzz.com" title="Fanzz.com" border="0" class="imgs" /></a></div> </td> <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="80%" align="left" valign="top"> <a class="retailer_title" href="/view_retailer.php?rid=13">Fanzz.com</a> </td> <td nowrap="nowrap" width="20%" align="right" valign="top"> <span class="cashback">7X Points</span> </td> </tr> <tr> <td colspan="2" valign="middle" align="left"><p class="retailer_description">Fanzz.com sells licensed sports apparel and gifts from the NFL, NBA, MLB, NCAA, NHL, MLS, NASCAR and WNBA. We have dozens of top brands on our site including Nike, Adidas, Reebok, New Era, Antigua, Baseline, Fathead, Fanmats, Majestic, Mitchell and Ness, Under Armour, Wilson, Wincraft and many more. </p></td> </tr> <tr> <td valign="middle" align="left"> <a class="favorites" href="#" onclick="if (confirm('Are you sure you want to add this retailer to your favorites?') )location.href='/myfavorites.php?act=add&rid=13'">Add to Favorites</a> </td> <td valign="middle" align="right"> <a class="go2store" href="/go2store.php?id=13" target="_blank">Go to Store</a> </td> </tr> </table> </td> </tr> <tr class="even"> <td width="125" align="center" valign="middle"> <div id="shadow"><a href="/view_retailer.php?rid=14"><img src="http://www.ftjcfx.com/image-5471697-10807939" width="120" height="60" alt="Pets Warehouse" title="Pets Warehouse" border="0" class="imgs" /></a></div> </td> <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="80%" align="left" valign="top"> <a class="retailer_title" href="/view_retailer.php?rid=14">Pets Warehouse</a> </td> <td nowrap="nowrap" width="20%" align="right" valign="top"> <span class="cashback">9X Points</span> </td> </tr> <tr> <td colspan="2" valign="middle" align="left"><p class="retailer_description">Founded in 1974 Pets Warehouse® provides the broadest selection of pet supplies available anywhere online, add value to your site and benefit your customers with low prices. </p></td> </tr> <tr> <td valign="middle" align="left"> <a class="favorites" href="#" onclick="if (confirm('Are you sure you want to add this retailer to your favorites?') )location.href='/myfavorites.php?act=add&rid=14'">Add to Favorites</a> </td> <td valign="middle" align="right"> <a class="go2store" href="/go2store.php?id=14" target="_blank">Go to Store</a> </td> </tr> </table> </td> </tr> <tr> <td valign="middle" align="center" colspan="2"> </td> </tr> </table> </div> <div id="column_right"> <div class="center"> <p align="center"> <a href="/invite.php"><img src="/images/ReferAFriend.gif" border="0"></a></br> <a href="/invite.php">Refer A Friend<br/>And Get More!</a> </p> </div> </div> <div id="footer"> <a href="/terms.php">Terms & Conditions</a> · <a href="/contact.php">Contact Us</a> · <a href="/help.php">FAQs</a> <p>© December, 2011. Bonus.Me. All rights reserved.</p> </div> </div> </body> </html> $results_per_page = RESULTS_PER_PAGE; $cc = 0; function getCategory($category_id, $description = 0) { if (isset($category_id) && is_numeric($category_id) && $category_id != 0) { $query = "SELECT name, description FROM cashbackengine_categories WHERE category_id='".(int)$category_id."'"; $result = smart_mysql_query($query); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); if ($description == 1) return $row['description']; else return $row['name']; }else { return "Category not found"; } } else { if ($description != 1) return "Retailers"; } } ////////////////// filter ////////////////////// if (isset($_GET['column']) && $_GET['column'] != "") { switch ($_GET['column']) { case "title": $rrorder = "title"; break; case "added": $rrorder = "added"; break; case "visits": $rrorder = "visits"; break; case "cashback": $rrorder = "cashback"; break; default: $rrorder = "title"; break; } } else { $rrorder = "title"; } if (isset($_GET['order']) && $_GET['order'] != "") { switch ($_GET['order']) { case "asc": $rorder = "asc"; break; case "desc": $rorder = "desc"; break; default: $rorder = "asc"; break; } } else { $rorder = "asc"; } ////////////////////////////////////////////////// if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0) { $page = (int)$_GET['page']; } else { $page = 1; } $from = ($page-1)*$results_per_page; $where = ""; if (isset($_GET['cat']) && is_numeric($_GET['cat']) && $_GET['cat'] > 0) { $cat_id = (int)$_GET['cat']; unset($retailers_per_category); $retailers_per_category = array(); $retailers_per_category[] = "111111111111111111111"; $sql_retailers_per_category = smart_mysql_query("SELECT retailer_id FROM cashbackengine_retailer_to_category WHERE category_id='$cat_id'"); while ($row_retailers_per_category = mysql_fetch_array($sql_retailers_per_category)) { $retailers_per_category[] = $row_retailers_per_category['retailer_id']; } $where .= "retailer_id IN (".implode(",",$retailers_per_category).") AND"; } if (isset($_GET['letter']) && in_array($_GET['letter'], $alphabet)) { $ltr = mysql_real_escape_string(getGetParameter('letter')); if ($ltr == "0-9") { $where .= " title REGEXP '^[0-9]' AND"; }else{ $ltr = substr($ltr, 0, 1); $where .= " UPPER(title) LIKE '$ltr%' AND"; } } $where .= " status='active'"; if ($rrorder == "cashback") $query = "SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY ABS(cashback) $rorder LIMIT $from, $results_per_page"; else $query = "SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY $rrorder $rorder LIMIT $from, $results_per_page"; $total_result = smart_mysql_query("SELECT * FROM cashbackengine_retailers WHERE $where ORDER BY title ASC"); $total = mysql_num_rows($total_result); $result = smart_mysql_query($query); $total_on_page = mysql_num_rows($result); /////////////// Page config /////////////// $PAGE_TITLE = getCategory($_GET['cat']); require_once ("inc/header.inc.php"); ?> <h1><?php echo getCategory($_GET['cat']); ?></h1> <?php if ($total > 0) { ?> <p class="category_description"><?php echo getCategory($_GET['cat'], 1); ?></p> <div id="alphabet"> <ul> <li><a href="/retailers.php">All</a></li> <?php $numLetters = count($alphabet); $i = 0; foreach ($alphabet as $letter) { $i++; if ($i == $numLetters) $lilast = ' class="last"'; else $lilast = ''; if (isset($cat_id) && is_numeric($cat_id)) echo "<li".$lilast."><a href=\"/retailers.php?cat=$cat_id&letter=$letter\">$letter</a></li>"; else echo "<li".$lilast."><a href=\"/retailers.php?letter=$letter\">$letter</a></li>"; } ?> </ul> </div> <div class="browse_top"> <div class="sortby"> <form action="retailers.php" id="form1" name="form1" method="get"> <span>Sort by:</span> <select name="column" id="column" onChange="document.form1.submit()"> <option value="title" <?php if ($_GET['column'] == "title") echo "selected"; ?>>Name</option> <option value="visits" <?php if ($_GET['column'] == "visits") echo "selected"; ?>>Popular</option> <option value="added" <?php if ($_GET['column'] == "added") echo "selected"; ?>>Newest</option> <option value="cashback" <?php if ($_GET['column'] == "cashback") echo "selected"; ?>>Cashback</option> </select> <select name="order" id="order" onChange="document.form1.submit()"> <option value="desc"<?php if ($_GET['order'] == "desc") echo "selected"; ?>>Descending</option> <option value="asc" <?php if ($_GET['order'] == "asc") echo "selected"; ?>>Ascending</option> </select> <?php if ($cat_id) { ?><input type="hidden" name="cat" value="<?php echo $cat_id; ?>" /><?php } ?> <?php if ($ltr) { ?><input type="hidden" name="letter" value="<?php echo $ltr; ?>" /><?php } ?> <input type="hidden" name="page" value="<?php echo $page; ?>" /> </form> </div> <div class="results"> Showing <?php echo ($from + 1); ?> - <?php echo min($from + $total_on_page, $total); ?> of <?php echo $total; ?> </div> </div> <table align="center" width="100%" border="0" cellspacing="0" cellpadding="5"> <?php while ($row = mysql_fetch_array($result)) { $cc++; ?> <tr class="<?php if (($cc%2) == 0) echo "even"; else echo "odd"; ?>"> <td width="125" align="center" valign="middle"> <?php if ($row['featured'] == 1) { ?><span class="featured" alt="Featured Retailer" title="Featured Retailer"></span><?php } ?> <div id="shadow"><a href="/view_retailer.php?rid=<?php echo $row['retailer_id']; ?>"><img src="<?php if (!stristr($row['image'], 'http')) echo "/img/"; echo $row['image']; ?>" width="<?php echo IMAGE_WIDTH; ?>" height="<?php echo IMAGE_HEIGHT; ?>" alt="<?php echo $row['title']; ?>" title="<?php echo $row['title']; ?>" border="0" class="imgs" /></a></div> </td> <td align="left" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="80%" align="left" valign="top"> <a class="retailer_title" href="/view_retailer.php?rid=<?php echo $row['retailer_id']; ?>"><?php echo $row['title']; ?></a> </td> <td nowrap="nowrap" width="20%" align="right" valign="top"> <span class="cashback"><?php echo DisplayCashback($row['cashback']); ?>X Points</span> </td> </tr> <tr> <td colspan="2" valign="middle" align="left"><p class="retailer_description"><?php echo $row['description']; ?> </p></td> </tr> <tr> <td valign="middle" align="left"> <?php if ($row['conditions'] != "") { ?> <div class="cashbackengine_tooltip"> <a class="conditions" href="#">Conditions</a> <span class="tooltip"><?php echo $row['conditions']; ?></span> </div> <?php } ?> <a class="favorites" href="#" onclick="if (confirm('Are you sure you want to add this retailer to your favorites?') )location.href='/myfavorites.php?act=add&rid=<?php echo $row['retailer_id']; ?>'">Add to Favorites</a> </td> <td valign="middle" align="right"> <a class="go2store" href="/go2store.php?id=<?php echo $row['retailer_id']; ?>" target="_blank">Go to Store</a> </td> </tr> </table> </td> </tr> <?php } ?> <tr> <td valign="middle" align="center" colspan="2"> <?php $params = ""; if (isset($cat_id) && $cat_id > 0) { $params = "cat=$cat_id&"; } if (isset($ltr) && $ltr != "") { $params = "letter=$ltr&"; } &nbs Hey guys, After my php script a HTML code follows. But i can't edit the HTML code because it isn't recognised. It does show up, however i can't edit it. Problem: Unable to edit HTML code below php scripts Code: <?php function createNewFile($name,$mail,$subject,$comments,$count,$date,$other="",$up="0") { global $settings; $header=implode('',file('header.txt')); $footer=implode('',file('footer.txt')); $content=' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>'.$subject.'</title> <meta content="text/html; charset=windows-1250"> Thanks in advance Hello, freaks. I need a little help with the best way to go about this. I have a field in mysql that contains a comma separated string of values. What I need to do is get those values out of the db and list them into editable text fields so the user can update the values in a html form. So far this is my code, I left out all the in betweens - validation, results, etc - for this post...but its there . SELECT servs FROM services WHERE id = $a_id $services = $row['servs']; $srvs = explode(',', $services); Then for the form: <?php foreach ($srvs as $service) { ?> <input type="text" name="servs[]" value="<?php echo $service ?>" /> <?php } ?> This gives me a text field for each value of servs, great! But the problem is, the user can enter up to 15 servs. Some currently have less than that saved in the db. I want to give them the ability to 1. edit any of the current servs value and 2. add more values if they have less than 15. My question is, how do I echo out 15 editable text fields for servs[] no matter the number of values they currently have? And when I go to implode the values, will blank text fields screw everything up? I can't find anything in the forums that relate to this. I believe it probably will involve $i, but I am not too familiar with counting in php yet, so I could really use some help. Thanks! Oh - and I am not stuck on using text fields, but I couldn't figure how to make this work using a select list or checkboxes. Any suggestions either way would help. Hello i have a SQL db that has some Empty Rows in it .... I Had used a if else statement to make it display N/A If the answer is different than it should be like this <?php if ($string) {echo $string} else {echo"N/A"};?> but i think there are better ways of doing this Can anyone teach me how may i do it? Edit: it should be a way to see if the db row value is empty/null :| I'm writing a highscore board for a game and I can only display one value from a DB... I don't know what I could be doing wrong. I've done this kind of DB work before. <?php $name = $_GET['lvl']; if($_GET['lvl']=="Strength"){ //1/21 $skill = "strlvl"; $exp = "strexp"; } else if($_GET['lvl']=="Attack"){ //2/21 $skill = "atklvl"; $exp = "atkexp"; } else if($_GET['lvl']=="Defence"){ //3/21 $skill = "deflvl"; $exp = "defexp"; } else if($_GET['lvl']=="Hitpoints"){ //4/21 $skill = "hplvl"; $exp = "hpexp"; } else if($_GET['lvl']=="Range"){ //5/21 $skill = "rglvl"; $exp = "rgexp"; } else if($_GET['lvl']=="Magic"){ //6/21 $skill = "mglvl"; $exp = "mgexp"; } else if($_GET['lvl']=="Hitpoints"){ //7/21 $skill = "hplvl"; $exp = "hpexp"; } else if($_GET['lvl']=="Prayer"){ //8/21 $skill = "prlvl"; $exp = "prexp"; } else if($_GET['lvl']=="Runecraft"){ //9/21 $skill = "rclvl"; $exp = "rcexp"; } else if($_GET['lvl']=="Slayer"){ //10/21 $skill = "sllvl"; $exp = "slexp"; } else if($_GET['lvl']=="Thieve"){ //11/21 $skill = "thlvl"; $exp = "thexp"; } else if($_GET['lvl']=="Agility"){ //12/21 $skill = "hplvl"; $exp = "hpexp"; } else if($_GET['lvl']=="Firemaking"){ //13/21 $skill = "fmlvl"; $exp = "fmexp"; } else if($_GET['lvl']=="Woodcut"){ //14/21 $skill = "wclvl"; $exp = "wcexp"; } else if($_GET['lvl']=="Cooking"){ //15/21 $skill = "cklvl"; $exp = "ckexp"; } else if($_GET['lvl']=="Herblore"){ //16/21 $skill = "hblvl"; $exp = "hbexp"; } else if($_GET['lvl']=="Mining"){ //17/21 $skill = "mnlvl"; $exp = "mnexp"; } else if($_GET['lvl']=="Farming"){ //18/21 $skill = "frmlvl"; $exp = "frmexp"; } else if($_GET['lvl']=="Fishing"){ //19/21 $skill = "fshlvl"; $exp = "fshexp"; } else if($_GET['lvl']=="Smithing"){ //20/21 $skill = "smlvl"; $exp = "smexp"; } else if($_GET['lvl']=="Fletching"){ //21/21 $skill = "fltlvl"; $exp = "fltexp"; } else if($_GET['lvl']==""){ //0/21 echo "<center><br /><br />No skill selected!</center><br />"; } mysql_connect("mysql", "15557_test", "**************") or die("Could not connect: " . mysql_error()); mysql_select_db("15557_test"); //STARTS HERE $result = mysql_query("SELECT playerName, $skill, $exp FROM skills ORDER BY $exp ASC LIMIT 5000"); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo"Skill: " . $name . "<br />"; printf("Player: %s - Rank: %s - EXP: %s<br />", $row[0],$row[1],$row[2]); mysql_free_result($result //ENDS HERE } ?> Hello, I recently came upon this website and I want to implement something similar. The 'remove' box is what I would like to do with PHP. I have no idea where to start. I would like to be able to search through my database, select one of its components and add it to that window. Within that window I would also like to be able to remove it. Does anyone know where I should go from there? here is the site: http://www.sealandserpent.org/schedgen/schedulegenerator.php I'm currently trying...struggling....to teach myself PHP and I'm really bugged with this database stuff. I am slowly managing but I'm a tad bit stuck now. I want to show a specific piece of information from a table. Lets say my table is structured like so: id user email 1 Bob Bob@Name.com 2 Fred Fred@Name.com 3 Matt Matt@Name.com What would I need to do to display ONLY Freds user? One way I tried only displayed the first rows info (Bob) the second way I tried (with a while loop) only displayed the last rows info (Matt) Heres my current code: <html> <body> <?php include 'dbwire.php'; $query = mysql_query('SELECT * FROM user'); $row = mysql_fetch_array($query); while ($row = mysql_fetch_array($query)) { echo '<b>User:</b> ' . $row['user'] . '<br />'; } ?> </body> </html> <?php require_once('upper.php'); require_once('database.php'); if(isset($_COOKIE['LoginIdCookie'])) { echo '<h4>Welcome '.$_COOKIE['LoginIdCookie'].'</h4>'; } else{ echo '<h4>Events</h4>';} $result=mysqli_query($dbc,"select * from events") or die('Not Connected'); echo "<html> <body>"; echo "<form method='post' action='EventParticipator.php'>"; echo "<u><h4>Please tick events in which you want to participate</h4></u>"; /*echo "<table cellspacing='0' cellpadding='15'> <th><b>Event Title:</b></th> <th ><b>Event City:</b></th> <th><b>Content:</b></th> <th><b>Images:</b></th> <th><b>Event Date:</b></th>";*/ //while($row=mysqli_fetch_array($result)) $row=mysqli_fetch_array($result); for($i=0;$i<5;$i++) { $Title=$row['Title']; $City=$row['City']; $Content=$row['Content']; //$Photo=$row['Photo']; $Date=$row['Date']; $EventId=$row['EventId']; $Photo=$row['Photo']; //echo $Photo; echo "<tr><td><img src='$Photo' width='120' height='90'/></td><td>$City</td><td>,</td><td>$Date</td><td>:</td><td>$Title</td></tr> <tr><td>$Content</td></tr> <tr><td><a href='#'>Know more</a></td><td>/</td><td><a href='#'>Click here to participate</a></td></tr>"; } //echo "<tr><td><input type='submit' name='submit' value='Participate'</td>"; if(isset($_COOKIE['LoginIdCookie'])) { echo "<td><a href='log_out.php'>Log out</a></td>"; echo "<td><a href='EditActivity.php'>Edit Your Activities</a></td></tr>"; } echo "</table></form></body></html>"; require_once('lower.php'); ?> Quote Hi friends .......... I write above code to display top 5 rows from the database but it not works properly. It displays first row 5 times which is undesireable. Anyone please help????????????????? thanks in advance.................. |