Jump to content

Search the Community

Showing results for tags 'sql'.

  • 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 this function for a search engine using pdo public function GetPageurlByPagecontent() { $db = Database::getDB(); $query = "SELECT * FROM searchengine where pageurl Like Pagecontent"; $searchengine =$db->query($query); return $searchengine; } in the data base pagecontent = keyword pageurl is the url to match that keyword this is my form , I want the pagecontent to match the pageurl only when i do a search by the pagecontent dont even think this query work any ideas? <form action="searchhome.php" method="post" id="search"> <b>Enter Search Term:</b> <input type="text" name="term" size="50"> <b>Results:</b> <select name="results"> <option>10</option> <option>20</option> <option>50</option> </select><br> <input type="submit" value="Search"> </form> <br /> <br /> <?php if(isset($_POST['pageurl'])){ $c_name = $_POST['pageurl']; $pdb2 = new SearchDB(); $search= $pdb2->GetPageurlByPagecontent($c_name); ?> <h1> Results <?php echo $c_name ?> </h1> <?php foreach($search as $list): ?> <br /> <br /> <table> <tr> <td> <p><em> url </em>: <?php echo $list['pageurl'] ?> </p> </td> </tr> </table> <?php endforeach; ?> <?php }?>
  2. Hello everyone, I am new to php coding and i am currently trying to check for duplicate data when inserting new values (i.e. a question) in mysql database table. I keep getting this error 'Warning: mysqli_num_rows() expects exactly 1 parameter,2 given in'. Below is the code i am currently working with. Thanks in advance <?php session_start(); $link = mysqli_connect("elephant.ecs.westminster.ac.uk", "w1268094", "euMm27FZwZDK", "w1268094_0"); ?> <?php //Error reporting due to long script error_reporting(E_ALL); ini_set('display_errors','1'); ?> <?php ob_start(); //Add question to table If (isset($_POST['question'])) { $question = mysqli_real_escape_string($link, $_POST['question']); $date = mysqli_real_escape_string($link, $_POST['questiondate']); //See if question is identical to another question in the table $sql = mysqli_query($link,"SELECT pQuestionNo FROM presidentQuestion WHERE pQuestion='$question'LIMIT 1"); $questionMatch = mysqli_num_rows($link, $sql); //count the output amount if ($questionMatch>0){ echo 'Sorry you tried to place a duplicate "Question" into the table, <a href="inventory.php">Click here</a>'; exit(); } //Add the question to the database $sql = mysqli_query($link,"INSERT INTO presidentQuestion (pQuestion,pDate) VALUES ('". mysqli_real_escape_string($link, $question) ."','". mysqli_real_escape_string($link, $date) ."')") or die (mysqli_error($link)); header("location: inventory.php"); exit(); } ?> <?php //Grabs the whole queston list $question_list=""; $sql = mysqli_query($link,"SELECT * FROM presidentQuestion LIMIT 0,10") or die(mysql_error()); $questionCount = mysqli_num_rows($sql);// count the output amount if($questionCount>0){ while($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){ $question = $row["pQuestion"]; $date = $row["pDate"]; $question_list .= "$question <br/>"; } }else{ $question_list = "There are no questions in the inventory yet"; } ?> <?php $prop_id = $_GET['prop_id']; ?>
  3. I have created a web page where my customers will be able to enter details of all items there return back to my store. I have created in such a way that, 1 customer can enter his personal details once but can add any number of items he is returning. I have created a "add more" button to do this job. I have used arrays for this job, but when I am testing my site, database is not taking the items entered and is not displayed by phpMyAdmin. index.php.txt
  4. javascript is not looping with mysql_fetch_array result even though it showing timer on one product only .i don't know what mistake i have did ,,plz help me ,,i ma very new with php and java script..even i have taken javascript timer from google itself ..plz help me <?php $conn = mysql_connect('localhost','root',''); if(!$conn) die("Failed to connect to database!"); $status = mysql_select_db('bidding', $conn); if(!$status) die("Failed to select database!"); $result = mysql_query("SELECT * FROM bids where id"); $numrow = mysql_num_rows($result); if ($numrow == 0) { die('No record found.'); } ?> <?php while($row=mysql_fetch_array($result)){ $closedate = date_format(date_create($row['closing_date']), 'm/d/Y H:i:s'); $images_field= $row['image']; $image_show= "images/$images_field"; ?> <div class="bidbar1"> <div id="lastsold"><strong>Last Sold : ₹ </strong><?php echo $row['lastsold']; ?> </div> <div id="title"><?php echo $row['description']; ?></div> <div id="detail"><img src="image/moredetail.jpg" height="150" alt="more detail" /> </div> <div id="image"><img src="<?php echo $image_show; ?>" width="205" height="150" alt="more detail" /></div> <div id="clock"><table><tr><td style="font-size:18px;text-align:center; padding- left:30px;">Days Hr Min Sec</td></tr> <tr><td style="font-size:32px; font:bold; text-align:center;padding-left:30px;"> <script> var cdtd = function(id,end) { var start = new Date(); var timeDiff = end.getTime() - start.getTime(); if(timeDiff <=0 ) { //$('#bidbar1').remove(); //return; // alert('We have lift off!'); //$('#bidbar1').delay(50000000).fadeout(); $(window).load(function(){$('#bidbar1').remove(); }); return false; } var seconds = Math.floor(timeDiff / 1000); var minutes = Math.floor(seconds / 60); var hours = Math.floor(minutes / 60); var days = Math.floor(hours / 24); hours %= 24; minutes %= 60; seconds %= 60; $( id + " .days").html(days); $( id + " .hours").html(hours); $( id + " .minutes").html( minutes); $( id + " .seconds").html( seconds ); console.log(id + " .hoursBox",$( id + " .hoursBox").length,id,end,hours,minutes,seconds) var timer = setTimeout(function(){cdtd(id,end)},1000); } cdtd("#counter1",new Date("<?php echo $closedate; ?>")); //cdtd("#counter2",new Date("march 16, 2014 18:06:30")); //cdtd("#counter3",new Date("march 16, 2014 17:37:00")); //cdtd("#counter4",new Date("march 16, 2014 17:38:00")); //cdtd("#counter5",new Date("june 2, 2014 10:55:00")); //cdtd("#counter6",new Date("April 2, 2014 10:30:00")); //cdtd("#counter7",new Date("April 3, 2014 00:01:00")); //cdtd("#counter8",new Date("April 1, 2014 00:01:00")); //cdtd("#counter9",new Date("April 4, 2014 00:01:00")); //cdtd("#counter10",new Date("April 5, 2014 00:01:00")); //cdtd("#counter11",new Date("April 19, 2014 00:01:00")); //cdtd("#counter12",new Date("April 20, 2014 00:01:00")); </script> <div id="counter1"> <div class="box days">0</div> <div class="box hours">0</div> <div class="box minutes">0</div> <div class="box seconds">0</div> </div> </td></tr></table></div> <div id="mrp"><strong>MRP : ₹</strong><?php echo $row['mrp']; ?></div> <div id="endt"><strong>End Time: ₹</strong><?php echo $row['closing_date']; ?></div> <div id="fee"><strong>Bid Fee : ₹</strong><?php echo $row['bid fee']; ?></div> <div id="current"><strong>Current Winner</br>↓ </strong></div> <div id="buy"> <table width="271" border="0" cellpadding="0.1"> <tr> <td><img src="image/buy.png" alt="buy now" longdesc="http://buy now" /></td> <td width=110><?php echo $row['currentwinner']; ?></td> <td><img src="image/bid.png" alt="bid now" longdesc="http://bidnow " /></td> </tr> </table> </div></div> <?php } ?>
  5. I have two arrays and all I want from them is the differences to show and any item that existed in both not to show. Please find my workings below mysql_select_db($database_dbconnect, $dbconnect);$query_Asset = "SELECT idAsset, AssetName FROM Asset WHERE idLocation = '1'";$AssetUp = mysql_query($query_Asset, $dbconnect) or die(mysql_error()); $array1 = array(); while ($f = mysql_fetch_assoc($AssetUp)) {$array1[] = $f;} mysql_select_db($database_dbconnect, $dbconnect);$query_DocUp = "SELECT Asset.idAsset, Asset.AssetName FROM AssetDocStand INNER JOIN Asset ON AssetDocStand.idAsset = Asset.idAssetWHERE AssetDocStand.idDocumentStandards = '2' AND Asset.idLocation ='1'";$DocUp = mysql_query($query_DocUp, $dbconnect) or die(mysql_error());$array2 = array(); while ($f = mysql_fetch_assoc($DocUp)) {$array2[] = $f;} print_r($array1); echo "<br><br><br>"; print_r($array2); shows the following when the page is loaded. Array ( [0] => Array ( [idAsset] => 10000005 [AssetName] => HP ) [1] => Array ( [idAsset] => 10000006 [AssetName] => HP Server ) [2] => Array ( [idAsset] => 10000009 [AssetName] => HP Laptop ) [3] => Array ( [idAsset] => 10000010 [AssetName] => Office Printer ) [4] => Array ( [idAsset] => 10000023 [AssetName] => test ) ) Array ( [0] => Array ( [idAsset] => 10000023 [AssetName] => test ) ) Now when i type $array3 = array_diff($array1, $array2 ); print_r($array3); I get Array ( ) Ive also tried array_diff_key() which also produces nothing. All I want to be left with is Array ( [0] => Array ( [idAsset] => 10000005 [AssetName] => HP ) [1] => Array ( [idAsset] => 10000006 [AssetName] => HP Server ) [2] => Array ( [idAsset] => 10000009 [AssetName] => HP Laptop ) [3] => Array ( [idAsset] => 10000010 [AssetName] => Office Printer ))
  6. Hi Guys I have written this function which basically finds all assets that have a certain document associated with them in a certain location. It works great however I need the opposite. I need all the assets that don't have this document but i cant get my head around the query can anyone help me please? function GetUploadedDocsNoAsset($doctype,$archive, $location){ $colname_DocUp = "-1";if (isset($doctype)) { $colname_DocUp = $doctype;} $colname_Archive = "-1";if (isset($archive)) { $colname_Archive = $archive;}$colname_Location = "-1";if (isset($location)) { $colname_Location = $location;} $query_DocUp = sprintf("SELECT idAssetDocStand FROM AssetDocStand INNER JOINAsset ON AssetDocStand.idAsset = Asset.idAssetWHERE AssetDocStand.idDocumentStandards = %s AND AssetDocStand.Archive=%s AND Asset.idLocation = %s", GetSQLValueString($colname_DocUp, "int"), GetSQLValueString($colname_Archive, "text"), GetSQLValueString($colname_Location, "int"));$DocUp = mysql_query($query_DocUp);$totalRows_DocUp = mysql_num_rows($DocUp);return $totalRows_DocUp;}
  7. hello I am looking for help on a sql problem. Not sure if I have a statement mixed up or not but the table simply won't render. Any help would be greatly appreciated. Database name = test I have two tables table 1 = parts table 2 = parts_pricing The main recordset name is RSparts Please see my current php code - $maxRows_RSparts = 10; $pageNum_RSparts = 0; if (isset($_GET['pageNum_RSparts'])) { $pageNum_RSparts = $_GET['pageNum_RSparts']; } $startRow_RSparts = $pageNum_RSparts * $maxRows_RSparts; $colname1_RSparts = "-1"; if (isset($_GET['figno'])) { $colname1_RSparts = $_GET['figno']; } $colname2_RSparts = "-1"; if (isset($_GET['modelno'])) { $colname2_RSparts = $_GET['modelno']; } mysql_select_db($database_test, $test); $query_RSparts = sprintf("SELECT * FROM parts INNER JOIN partspricing ON partspricing.sellingprice=parts.partID WHERE figno = %s AND modelno = %s ORDERBY ACS ", GetSQLValueString($colname1_RSparts, "text"),GetSQLValueString($colname2_RSparts, "text")); $query_limit_RSparts = sprintf("%s LIMIT %d, %d", $query_RSparts, $startRow_RSparts, $maxRows_RSparts); $RSparts = mysql_query($query_limit_RSRSparts, $test) or die(mysql_error()); $row_RSparts = mysql_fetch_assoc($RSparts; if (isset($_GET['totalRows_RSparts'])) { $totalRows_RSparts = $_GET['totalRows_RSparts']; } else { $all_RSparts = mysql_query($query_RSparts, $test); $totalRows_RSRSparts = mysql_num_rows($all_RSparts); } $totalPages_RSparts = ceil($totalRows_RSparts/$maxRows_RSparts)-1; Table setup; <table> <tr> <td>Key No.</td> <td>Part Number</td> <td>Description</td> <td>QTY</td> <td>S/N Break</td> <td>Availabilty</td> <td>Price</td> </tr> <?php do { ?> <tr> <td><?php echo $row_RSparts['keyno']; ?></td> <td><?php echo $row_RSparts['partno']; ?></td> <td><?php echo $row_RSparts['description']; ?></td> <td><?php echo $row_RSparts['qty']; ?></td> <td><?php echo $row_RSparts['snbreak']; ?></td> <td><?php echo $row_RSparts['availability']; ?></td> <td><?php echo $row_RSparts['sellingprice']; ?></td> </tr> <?php } while ($row_RSparts = mysql_fetch_assoc($RSparts)); ?> If I leave out parts INNER JOIN partspricing ON partspricing.sellingprice=parts.partID the table works and renders fine or if I leave out WHERE figno = %s AND modelno = %s ORDERBY ACS the table renders fine. I am missing something here. If I leave it as is the table will not render at all. Hopefully this is something simple any help would be greatly appreciated!
  8. I have a <a>, on click delete a product from database that is on server, I want to delete the product and the same time delete the image of that product. I using unlink() my code delete the product but don't delete the image and I don't no why someone can tell me what is missing ? if((isset($_GET["remove"])) && ($_GET["remove"] != "")){ $idproduct = $_GET["remove"]; $sql ="DELETE FROM product WHERE idproduct = '".$idproduct."'"; if(mysqli_query($connect, $sql) or die ("Erro")){ //the part that don't work $file = $frontpage_url."/images/".$_FILES["imagem"]["name"]; unlink($file); echo "success"; } }
  9. Hi can i find out if it is possible to retrieve rows from my tables in the database but display them as hyperlinks which can lead to a page (can it be just 1 page that allows values to be inserted into?) that allows charts (using highcharts) or so to be created based on the values passed from the database? Sorry if this is a stupid question. I'm new to this and I'm exploring ways to present my data. Thanks!
  10. I've run into a few problems as I was following this guys tutorial to setup a registration, log-in, etc. into my website. - for references here is the tutorial that I was going through and the problem that I have encountered has occurred during the process at: http://youtu.be/740kEwoRPKk?t=15m20s As you can see in the 3rd image attached each one of my .php documents also have a notification bar on the top of the coding which entitles, "Dynamically-related files could not be resolved because the site definition is not correct for the server. Retry | Setup" I have my php files setup exactly as he has it only thing different then his is that I had to change my localhost to localhost:8080 due to a bump in the road that happened due to the fact that I have Skype on my computer which encounters a problem with the testing-server service I am using which is PhPMyAdmin The error that I am getting when I try to connect my database to my testing server is in the image attached. Please reply to this post as soon as possible so I can get this problem resolved asap! Take note that I am working on everything from Dreamweaver CC!! Also I have tried several variables for setting up the database 'MySQL server:' such as 'localhost' , 'localhost:8080' , 'localhost8080' , 'localhost' , etc. If you have any further questions you can reply to me on here or you can add me on skype as well! My skype name is: lowheartrate Thank you to all in advance!! ~Codi Bezouka-Smith 'PHP-Beginner' - screenshots of the other images that weren't uploaded - - http://prntscr.com/302xut - http://prntscr.com/302xz8 - http://prntscr.com/302y3f
  11. Hi all, having some trouble working out whats going wrong here, don't get no errors to work from so I am stuck! Why is this NOT storing in the table? I have other code using the execution function and working, but this is failing but no errors. Please help! SQL Passing SQLExecute(" INSERT INTO `dbleads`.`offer` (`Username`, `Password`, `PWSalt`, `FullName`, `Email`, `Phone`, `Mobile`, `CompanyName`, `CompanyABN`, `Street`, `Suburb`, `State`, `Postcode`, `BStreet`, `BSuburb`, `BState`, `BPostcode`, `Comment`, `AgreeTC`, `TimeStamp`) VALUES (`$unop`, `$pwop`, `$salted`, `$fnop`, `$emailop`, `$phoneop`, `$mbop`, `$cnameop`, `$cabnop`, `$streetop`, `$suburbop`, `$stateop`, `$postcodeop`, `$Bstreetop`, `$Bsuburbop`, `$Bstateop`, `$Bpostcodeop`, `$commentop`, `$AgreeTC`, `$Timestamp`); "); Connection: function SQLExecute($sqlstring){ // CONNECTION $mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $mysqli->query($sqlstring); /* close connection */ $mysqli->close(); }
  12. In my first page I have I have a query that returns tournaments names in a table in this format echo "<td><a href='tournament.php'>" . $info['tournament'] . "</a></td>"; $info['tournament'] has the tournament name which when clicked takes me to the page tournament.php where I have this code $data = mysql_query("SELECT team1,score1,team2,score2 FROM smite where tournament='';") or die(mysql_error()); what i want is to have the value clicked in the previous page that linked to this one, in tournament='HERE' so that the query retrieve the data for that tournament i have tried echo "<td><a href='tournament.php?tournament=".$info['tournament']."'>" . $info['tournament'] . "</a></td>"; and $tournamentName = $_GET['tournament']; $data = mysql_query("SELECT team1,score1,team2,score2 FROM smite where tournament='$tournamentName';") or die(mysql_error()); the query returns empty and when i print $tournamentName i get for example (Golden Cup) which should be (Golden Cup #1) the $_GET removed #1 which is why the query returns NULL and if i do partial match to $tournamentName i will get all the Golden Cup tournaments not just the one i clicked can anyone help me solve this problem ? Thank you
  13. Hi, you all know that from phpmyadmin you can run an SQL Query for example "select * from table where code like '0011'" now my question is can I add a query box like this directly into my website, so I can run a query without login into phpmyadmin? your help is very appreciated since I cannot make this happen. thanks
  14. Hi guys, I was wondering if i could have some help on a piece of functionality I am trying to implement onto a website I am currently developing. The Scenario is as follows : I have a table residing on a MySql data base called Bookings. The Bookings table consists of a composite primary key based upon the following 2 fields: BookingDate & Booking Slot. On my website, I have built a bookings page which will consist of a a simple HTML Form, which has a Date Field and a Radio-Button group which has 3 different time slots (eg: 9am, 2pm and 4pm). Firstly, the User will select a Date they would wish to place a booking on and then click a submit button called "Check Availablity". Once this button is clicked, Ideally, I would like a script to check an see what free slots are available for that Date and then disable the radio buttons related the slots which are already booked. Here is a simple scenario to help explain the functionality i am trying to implement : The User comes to the Bookings page, and selects the Date 14/03/2011. Then clicks the "Check Availablity" button. In this scenario, the 9am slot is already booked for this date (eg: this booking already exists on the MySql database table), so the 9am radio button on the page is then disabled, not allowing the user to try an attempt to book this timeslot on this date. Below is the a simplified version of the php script which I wrote to implement the this functionality. <?php function checkSlot() { // Get data $test_date = $_GET["bookingDate"]; // Database connection $conn = mysqli_connect("localhost","root","","wordpress"); if(!$conn) { die('Problem in database connection: ' . mysql_error()); } // Attempt to find Duplicate Primary Keys $query = "SELECT Count(*) AS 'total' FROM Bookings WHERE booking_date ='{$booking_date}' AND booking_slot = '9am'"; $result = mysqli_query($conn, $query) or die(mysqli_error($conn)); $num = $result->fetch_assoc(); If ($num['total'] == 0) { echo "<script> document.getElementById('9amTimeSlotRadioButton').disabled = false; </script>"; } else if($num['total'] > 0) { echo "<script> document.getElementById('9amTimeSlotRadioButton').disabled = true; </script>"; } } ?> My problem is that I cant get the Javascript line within the if statement to execute and disable/enable the related 9am radio button. Upon research into this, I have recently found out that it is not possible to do this with just Php and JavaScript, as php runs serverside and javascript runs client-side and Ajax would be needed here. So, im in a spot of bother now as one of the main selling points of this project was to be able to get this functionality working. I have a massive favour to ask of you guys, could you chime in and guide me on how to implement this functionality by using Ajax? I have zero experience in the language so I really dont know where to start. Any input at all on this topic would be much appreciated. Thanks in advance guys, Dave Ireland.
  15. i'm wondering what is this problems. i copy paste it to other page. it works fine. but only this page have the error. spend most of time searching solution and i google for other solution still not working. the dreamweaver said there is no syntax error but when running it on localhost. then this appear "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\fpdf\form3_final_dead.php on line 14" 2nd, i'm creating a form.. it should be look like this : http://prntscr.com/2xfd0g but when run on localhost, this happen : http://prntscr.com/2xfd48 //note that, there is a missing column in the page. the code also contain this
  16. I'm using sql with php and mysql_fetch_assoc is returning null even though mysql_num_rows returns 1. I've echoed the query statement I'm using and entered the output manually and sql does return a value. I'm not sure why the code is returning a null. Basically I have $rv = mysql_query("SELECT (blah) from my_table WHERE my_key = " . $value . ";", $mysql_link); echo "" . mysql_num_rows($rv); if(!$rv) { echo 'There was a problem with your order. '; die('Could not connect: ' . mysql_error($mysql_link)); }else { if ($row = mysql_fetch_assoc($sql)) { //code }else { echo 'There was a problem setting up your order. '; die('Missing fields: ' . mysql_error($mysql_link)); } } And the missing fields is printing out even though echo "" . mysql_num_rows($rv); shows 1.
  17. Hii.. I had made a table in the database. And also had printed out the data... There are 20 episodes in a movie... And I had fetch and printed all the 20 episodes. Now I want to make those 20 lines clickable link and when user clicks on that link than it should perform some operation like in the thenewboston.org website when you click on Video & Tutorials Tab from the nav bar than it opens up all the topics. and when we click on for e.g. PHP VIDEOS than it takes to the particular page and than in the PHP Tutorials it shows a list of 200 videos and than when you click on any of the page than it fetch the data from database and than print the related data. So how should I make the dynamic links like http://thenewboston.org/watch.php?cat=11&number=21 ... And how should I write the operation in my php page which than performs the query and display it on that page... Any link referring to tutorial will work... Any Help would be appreciated.
  18. I am wanting to echo a table if a field = x and if not echo another table. Can this be done easily? I have tried but not having much luck. Any help would be appreciated by this "on the fly" learner. Something like... IF AdviserCode=X then <table width="610" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="85">RCTI</td> <td width="85">Detail 1</td> <td width="85">Detail 2</td> <td width="85">Detail 3</td> <td width="85">Detail 4</td> <td width="85">Detail 5</td> </tr> <?php include("../edb.php"); $result=mysql_query("SELECT * FROM `afddocs_adviser_comm` WHERE AdviserCode =".$_SESSION['uid']." order by DateUploaded DESC"); while($test = mysql_fetch_array($result)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td><a class='".$test['RCTIcssclass']."'href =".$test['RCTIURL'].">".$test['RCTIImageType']."</a>"; echo"<td><a class='".$test['Detail1cssclass']."'href =".$test['Detail1URL'].">".$test['Detail1ImageType']."</a>"; echo"<td><a class='".$test['Detail2cssclass']."'href =".$test['Detail2URL'].">".$test['Detail2ImageType']."</a>"; echo"<td><a class='".$test['Detail3cssclass']."'href =".$test['Detail3URL'].">".$test['Detail3ImageType']."</a>"; echo"<td><a class='".$test['Detail4cssclass']."'href =".$test['Detail4URL'].">".$test['Detail4ImageType']."</a>"; echo"<td><a class='".$test['Detail5cssclass']."'href =".$test['Detail5URL'].">".$test['Detail5ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> OR (same table as above minus a couple of colums)
  19. Need help badly! Setting up a new website with user logins. Pretty simple kind of stuff. Started working on letting the user upload a profile photo for their account, managed to get the user to be able to upload the photo in to a file on the site (upload/) and the image name entered in to their user details in SQL database. Worked fine. Only problem is when I try to recall the information, i've only been able to recall everybody's information and not just the logged in user. Here is the code I'm using. Bare in mind, I'm no pro with PHP and SQL so please help with as many details as possible. Thanks! ---------------------------------------------------------- <?php // Connects to your Database mysql_connect("localhost", "username", "password") or die(mysql_error()) ; mysql_select_db("database name") or die(mysql_error()) ; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM users") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=http://www.mysite/users/upload/".$info['photo'] ."> <br>"; Echo "<b>Name:</b> ".$info['name'] . "<br> "; } ?> ---------------------------------- This seems to recall everyones info. I only want the display photo to be shown for the logged in user. I have tried a lot of changes and either the image doesn't show or nothing shows.
  20. Ok, so I created a test database on my server, created 1 table with 1 row in it and the row is populated with values. I can connect to the database without error, but when I try to put in a while loop to print the results I get nothing but a blank screen. I tried placing some debug code in the while loop to see where its getting hung up but the while loop doesn't want to run at all. I placed an echo directly outside of the loop and the debug text is displayed fine but anything I put in the loop doesn't work. Can anyone help me out? Here is my code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $dbuser = "webestat_testdb"; $dbpass = "password"; $dbname = "webestat_testdb"; $server = "localhost"; $conn = mysql_connect($server, $dbuser, $dbpass); if (!$conn) { echo "Failed to connect to db" . mysql_error(); } $selectdb = mysql_select_db('webestat_testdb', $conn); $sql = "SELECT * FROM 4000Series"; $results = mysql_query($conn, $sql); while($row = mysql_fetch_assoc($results)) { echo "test"; echo $row['gpu']. " " .$row['khs']. " " .$row['usd']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
  21. Can anyone help me please? I am trying to populate my page with data that is filtered from the dropdown box. It can either be "onchange" or clicking a button, not too fussed on this. I have tried so many ways but getting more and more lost an confused and ended up with nothing at all. I have stripped the coding back to where it last worked so any help is appreciated. <body> <table width="680" border="0" align="center" cellpadding="4" cellspacing="0"> <tr> <td> </td> </tr> <tr><td class="text-heading"><p>Financial Services Guides and Adviser Profiles</p><p class="Text_Heading_Black1">PAGE STILL IN DEVELOPMENT</p> <form id="form1" name="form1" method="post" action=""> <span class="text-questions">Adviser: </span> <select name="advselect" id="advselect"> <option value=" " selected="selected"> </option> <?php require ('../edb.php'); if (!$con) { die("MySQL could not connect!"); } $result= mysql_query("SELECT id, LastName, FirstName, UserType FROM `eusers` WHERE UserType='ADV' or UserType='STF' ORDER by LastName ASC"); while ($row = mysql_fetch_array($result)){ echo '<option value="'. $row['id'] .'">'. $row['LastName'] .', '. $row['FirstName'] .'</option>'; } ?> </select> <input type="submit" name="advselect" id="advselect" value="Filter / View" /> </form></td> </tr> <tr><td><p class="Text_SubHeading">Current Version </p> <table width="650" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="150">Adviser</td> <td width="200">Document</td> <td width="100">Version</td> <td width="50">Current</td> <td width="50">View</td> </tr> <?php include("../edb.php"); $data=mysql_query("SELECT * FROM `adocs_fsg_profile` INNER JOIN `eusers` ON eusers.id = adocs_fsg_profile.AdviserCode WHERE Current='Y' and ORDER BY LastName ASC, FirstName ASC, DocName ASC, DateUploaded DESC"); while($test = mysql_fetch_array($data)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td class='text-questions'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='text-questions'>".$test['DocName']."</td>"; echo"<td class='text-questions'>".$test['Version']."</td>"; echo"<td class='text-questions'>".$test['Current']."</td>"; echo"<td><a class='".$test['cssclass']."'href =".$test['URL'].">".$test['ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> </table> <p class="Text_SubHeading">Previous Versions </p> <table width="650" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="150">Adviser</td> <td width="200">Document</td> <td width="100">Version</td> <td width="50">Current</td> <td width="50">View</td> </tr> <?php include("../edb.php"); $data=mysql_query("SELECT * FROM `adocs_fsg_profile` INNER JOIN `eusers` ON eusers.id = adocs_fsg_profile.AdviserCode WHERE Current='N' ORDER BY LastName ASC, FirstName ASC, DocName ASC, DateUploaded DESC"); while($test = mysql_fetch_array($data)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td class='text-questions'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='text-questions'>".$test['DocName']."</td>"; echo"<td class='text-questions'>".$test['Version']."</td>"; echo"<td class='text-questions'>".$test['Current']."</td>"; echo"<td><a class='".$test['cssclass']."'href =".$test['URL'].">".$test['ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> </table></td> </tr> </table> </body>
  22. Hi how can i get this sql query to work in php ? this query worked in navicat /* API */ INSERT IGNORE INTO ps_search_index (id_product, id_word, weight) SELECT DISTINCT Product_ID, Product_ID + 5000 'id_word', '1' FROM ps_product_part_number WHERE API != '' AND API IS NOT NULL; INSERT IGNORE INTO ps_search_word (id_word, id_shop, id_lang, word) SELECT DISTINCT Product_ID + 5000 'id_word', '1', '1', API FROM ps_product_part_number WHERE API != '' AND API IS NOT NULL; I GOT THIS FAR "INSERT INTO ps_search_index (id_product, id_word, weight) SELECT DISTINCT Product_ID, Product_ID + 5000 AS id_word , '1' FROM ps_product_part_number WHERE API != '' AND API IS NOT NULL" "INSERT INTO ps_search_index (id_product, id_word, weight) SELECT DISTINCT Product_ID, Product_ID + 5000, '1' FROM ps_product_part_number WHERE API != '' AND API IS NOT NULL"
  23. Hi, I'm not sure if this is possible and it might be a bit of a wired question but basically. Is there a away to select a column from a name stored in a row. So for example: I have these to tables: TABLE 1 | ID | USER | Column Needed | | 1 | Bob | i2 | | 2 | Jim | i4 | TABLE 2 | i1 | i2 | i3 | i4 | i5| | 0 | 9 | 1 | 0 | 2 | And I want to select Bob and the column from TABLE 2 that is needed is i2. I then also want to select Jim and the column from TABLE 2 that is needed is i4. I want to do this all in one SQL query. And the column name that they need for each row is stores in TABLE 1 under column needed. Thanks for any help!!!!
  24. how to make a stored procedure in sql and use it on php?? i wanna make a stored procedure of my queries below and use it on my php program. can anyone help me? Please //query 1 INSERT INTO afnup_worksheet (faic,fnl_name,ftotal) SELECT DISTINCT atic ,atname ,(SELECT SUM(inttotal) FROM app_interview t2 WHERE t2.atic = t.atic)/7 FROM app_interview t GROUP BY atname HAVING COUNT(DISTINCT atic) //query 2 SELECT count(t.atic) as total,t2.name FROM app_interview as t, tb_applicants as t2 WHERE t.atic = t2.aic GROUP BY t.atic;
  25. <?php include("../../connect.php"); $burger=$row['event_name']; $query=mysql_query("CREATE TABLE $burger (id int(10) AUTO_INCREMENT,event_id char(50), name char(100))")or die (mysql_error()); ?> error : Incorrect table definition; there can be only one auto column and it must be defined as a key
×
×
  • 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.