Jump to content

urielk

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

urielk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am not sure I agree. A similar code in another program seems to work fine and even though there is only one result, it returns the details - articlename, date, and short description - where the article name becomes a hyperlink allowing one to get the full article text. That is what I am trying to do here and it is not working. That is the reason for my request. Later as I add more articles I am expecting the program to return a hyperlinked list so people get the details. Thanks for your comment anyway.
  2. I get a "1" in addition to the statement that echoed back earlier. Here is an exact copy: ** The SQL is : SELECT * FROM articles WHERE articlename LIKE '%Metabolism%'1 OK so it returns one row which is non-zero. Since the if statement is false it should go to else and execute the while loop right? Do I need a count at the end of the query so it has some limit to step through? Maybe that is the problem. Thanks for any additional comments or suggestions.
  3. Hello Everyone, Thanks for the patience. I made the correction suggested by Pica and also added both the error reporting and ini_set statements. What I get back is: ** The SQL is : SELECT * FROM articles WHERE articlename LIKE '%Metabolism%' That is all I get and I copied it exactly as it appears. So if the search term is being passed to the query and I can find the result from phpMyAdmin but not from the program, where are things going wrong? Thanks for the help.
  4. Hi, Thank you for pointing out the error. Did not see it neither did someone else who looked at the code several times. I made the change but I am still not getting any results from the query. I have a file index.php where I have an included file for the connection. I also have an included file for the sidebar which is where I have the form for the search. I left an echo statement in my connection file to tell me if the connection is successful and that statement is still there and I get a message that the connection is successful. My query is not working and I am not sure what statements to use to find out the source of the error so I can fix it. Thanks for all the help.
  5. New to php so I apologize but I don't see an error in the statement. I looked at hph code hint by doing a query using phpMyAdmin. They seemed to have a parentheses between Where and the before the double quotes. I tried that and the query says there are no records when I can find them. For some reason the query is not picking up the $phrase and I am n0ot sure how to figure out why. Be a big help if anyone can point me to a way to get this information. Thanks.
  6. Hi, I am having problems returning values from a select statement. When I query directly in the databse, I get back the information I am looking for. I use an includes file for the database connection and my page shows that the connection was successful. Here is my code: <?php $search = $_GET['searchFor']; $words = explode(" ", $search); $phrase = implode("%' AND articlename LIKE '%", $words); $sql ="SELECT * FROM articles WHERE articlename LIKE '%phrase%'"; $result =$conn->query($sql) or die('Sorry, could not get any articles at this time'); $row =($result->fetch_all()) or die('No records found'); $numRows =$result->num_rows; If($numRows==0) { echo "<h2>Sorry, no articles were found with '$search' in them.</h2>"; } else { While($row=$result->fetch_assoc()) { $articleid = $row['articleid']; $title = $row['articlename']; $shortdesc = $row['shortdesc']; echo "<h2>Search Results</h2><br><br>\n"; echo "<a href=\"index.php?content=showarticle&id=$articleid\">$title</a><br>\n"; echo "$shortdesc<br><br>\n"; } } ?> The search term is coming from a search form in the navigation. I have used "echo" statements to check and make sure that the sesrch word is coming through to tghe page containing the above code. I have tried mysqli_error() statements in several places and don't see where the problem is. When I try the search the message that comes back is "No records found" Does not makee sense because I know it is there, can find it, and even have the same syntax as the SELECT statement I use when I ask for the php code. Going crazy trying to sort this out. Any suggestions, help etc are greatly appreciated. Thank youi.
  7. Hi, I want to show part of the text from a page containing my article on my main page. The article resides in a database in mysql. How do I limit the amount of text that is shown without setting up a separate excerpt box for the article. I want to then provide a link so the user can go to another page that displays the entire article. Thanks for any suggestions.
×
×
  • 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.