?
Solved

drop down menu showing old records from the database

Posted on 2014-01-24
4
Medium Priority
?
351 Views
Last Modified: 2014-02-03
im doing this project, they is a page called insert a review, in my insert review page , before you can write a review you select the title of the book, i use a drop down menu for this, so the user writes a review on an existing book in my books database,

but now the issue is, my drop down menu is showing old records, book's title that i have deleted. and when i display my books table, the old records don't show, which is correct.

i just want to know why is my drop down menu showing old deleted records?

<?php
echo "<select name='title' >";
$res=mysql_query("SELECT *  FROM mbooks");

while($entry=mysql_fetch_array($res))
{
    echo "<option";

    if($entry['title'] ==fred)
    {
        echo " selected=selected";
     } 

    echo ">"  .$entry['title']. "</option>";
}
echo "</select>";
?>

Open in new window

Edited to put the code into the code snippet ~Ray
dropdownreviews.txt
0
Comment
Question by:JCWEBHOST
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39806117
It absolutely impossible to tell from that.

Database records aren't cached, so you need to double check you're using the correct connection to the correct database, and using the correct table. Do you have the database on a development and a live server - make sure you select the right one.

Other than that, we're working blind here - nothing wrong with your code (apart from mySQL library being deprecated in PHP, but that won't affect the records!)
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39806407
We would need to see your CREATE TABLE statements and your test data model.  We might need to see the other processes that led to the current state of the test data model.  In other words, it's not a question with any one answer.  It's a research project.

Maybe step back from this a little bit and try to get a foundation in how PHP works?  This article can lead you to good learning resources.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html

And this article can help you avoid many of the bad things that happen to people who start copying code samples from the internet without any real understand of what they're doing.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12293-AntiPHPatterns-and-AntiPHPractices.html

Since you will have to convert the data base extension from MySQL to something else, you might as well learn the right way now, and never go back to MySQL.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

Line 9 of the code snippet is almost certainly wrong, unless you have a defined constant somewhere else named "fred."  You might want to read this article, paying particular attention the part about time bombs.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12241-Quotation-Marks-in-PHP.html
0
 

Author Comment

by:JCWEBHOST
ID: 39811555
what do you mean by  "deprecated in PHP" is they a new way to do a drop down menu?

my connect seems alright, because my other drop downs are working fine.
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 1500 total points
ID: 39811573
In PHP there are several libraries you can use to access your mySQL database - mysql, mysqli, and PDO - the mysql libraries are deprecated meaning that you will have to switch to using one of the other 2.

In your code you are using the mysql library (functions such as mysql_query() and mysql_fectch_array()). Read through Ray's article and it'll show you how to switch to using one of the other.

That said, it's not the cause of your problem, and switching to another library won't help you solve it (but it still needs to be done anyway)
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question