Jump to content

Simber33

Members
  • Posts

    9
  • Joined

  • Last visited

Simber33's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. What would be the best way do implement this situation in php and mySQL: I want users to be able to rate and review restaurants. This would mean that their ratings and reviews have to be inserted into the databse. This wouldn't be a problem. My question is, what is the most efficient and SEO friendliest way to show the ratings and reviews per restaurant. Should I make a script that generate a page for each restaurant? Or should I have one page which gets the data from the database for each company (would that be SEO friendly).
  2. Hello, I'm trying to create a script which searchs through several columns in a table, using a keyword to search. I use mysqli and a query with MATCH AGAINST. I have got a code but it does not work and I do not know why. It does not give any error, but it basicly returns nothing. Here is my code: <?php if (isset($_POST['submit'])) { $tag = $_POST['tag']; include("database/database.php"); $query = ("SELECT Tutorialid, Title, Author FROM tutorials WHERE MATCH (Title, Body1, Body2, Body3, Body4, Author) AGAINST (?)"); if ($stmt = $connection->prepare($query)){ $stmt->bind_param("s",$tag); $stmt->execute(); $stmt->bind_result($id, $title, $author); $html_table = '</br></br><table class="cats" cellpadding="10" cellspacing="0"> <tr> <th class="cath">Title</th> <th class="cath">Author</th> <th class="cath">Link</th> </tr>'; while ($stmt->fetch()) { $link = "<a href='http://everytutorial.net/tutorials/".$id."'>Click here to open</a>"; $html_table .= '<tr><td class="catd">' .$title. '</td><td class="catd">' .$author.'</td><td class="catd">'.$link.'</td></tr>'; } $html_table .='</table></br></br></br>'; if (empty($id)) { echo "<p>No tutorials found milord.</p>"; } else { echo $html_table; $stmt->free_result(); $connection->close(); } } } I'm not sure what's wrong with it - any help could be great, thanks!
  3. Thanks! I found what the problem was - there is an unknown column. And yes, I'm new to using mysqli, so Im not sure how to use the prepared statement. Could you tell me how to use it? Thank you for your time!
  4. Hello, I´m trying to insert data from a form into a mysql table using mysqli and php. I use the code below to connect to the database: $host = "myhost"; $db = "a5066994_tutors"; $user = "a5066994_tutors"; $pass = "mypassword"; $connection = mysqli_connect("$host", "$user", "$pass", "$db"); if ($connection->errno) { printf("Connect failed: %s\n", $connection->error); exit(); and the code below to insert: $stmt = $connection->prepare("INSERT INTO tutorials (Author, Website, Title, Body1, Body2, Body3, Body4, Subtitle1, Subtitle2, Subtitle3, Subtitle4, Category, WTitle, Userid) VALUES ('$author','$website', '$title', '$text1', '$text2', '$text3', '$text4', '$s1', '$s2', '$s3', '$s4', '$cat', '$wtitle', '$userid') "); And it results in this error: Call to a member function execute() on a non-object I have also tried doing a var dump of the connection, which results in: object(mysqli)#1 (0) { } and a var dump of the statement, which results in: bool(false) Any help would be great, thank you!
  5. It says that it basically is that you tidy up your table and remove unnecessary aspects of it.
  6. I have a reason to have twenty different columns "for the same thing", there is no need to tidy up my table. I do not exactly understand why it would be more handy to use a user id instead of a username.
  7. Hello, I recently started working with PHP and MySQL and I have written a code to insert a variable into a MySQL column and if this column is already filled (Not NULL) that it would then continue on and try to update the next column. Here is my code: $result=mysql_query(" UPDATE user_info SET Amount20 = ( case when ( Amount19 is not null and Amount20 is null ) then ‘$amount’ WHERE Username ='$user' else Amount20 end ) , Amount19 = ( case when ( Amount18 is not null and Amount19 is null ) then ‘$amount’ WHERE Username ='$user' else Amount19 end ) , Amount18 = ( case when ( Amount17 is not null and Amount 18 is null ) then ‘$amount’ WHERE Username ='$user' else Amount18 end ) , Amount17 = ( case when ( Amount16 is not null and Amount17 is null ) then ‘$amount’ WHERE Username ='$user' else Amount17 end ) , Amount16 = ( case when ( Amount15 is not null and Amount16 is null ) then ‘$amount’ WHERE Username ='$user' else Amount16 end ) , Amount15 = ( case when ( Amount14 is not null and Amount15 is null ) then ‘$amount’ WHERE Username ='$user' else Amount15 end ) , Amount14 = ( case when ( Amount13 is not null and Amount14 is null ) then ‘$amount’ WHERE Username ='$user' else Amount14 end ) , Amount13 = ( case when ( Amount12 is not null and Amount13 is null ) then ‘$amount’ WHERE Username ='$user' else Amount13 end ) , Amount12 = ( case when ( Amount11 is not null and Amount12 is null ) then ‘$amount’ WHERE Username ='$user' else Amount12 end ) , Amount11 = ( case when ( Amount10 is not null and Amount11 is null ) then ‘$amount’ WHERE Username ='$user'else Amount11 end ) , Amount10 = ( case when ( Amount9 is not null and Amount10 is null ) then ‘$amount’ WHERE Username ='$user' else Amount10 end ) , Amount9 = ( case when ( Amount8 is not null and Amount9 is null ) then ‘$amount’ WHERE Username ='$user' else Amount9 end ) , Amount8 = ( case when ( Amount7 is not null and Amount8 is null ) then ‘$amount’ WHERE Username ='$user' else Amount8 end ) , Amount7 = ( case when ( Amount6 is not null and Amount7 is null ) then ‘$amount’ WHERE Username ='$user' else Amount7 end ) , Amount6 = ( case when ( Amount5 is not null and Amount6 is null ) then ‘$amount’ WHERE Username ='$user' else Amount6 end ) , Amount5 = ( case when ( Amount4 is not null and Amount5 is null ) then ‘$amount’ WHERE Username ='$user' else Amount5 end ) , Amount4 = ( case when ( Amount3 is not null and Amount4 is null ) then ‘$amount’ WHERE Username ='$user' else Amount4 end ) , Amount3 = ( case when ( Amount2 is not null and Amount3 is null ) then ‘$amount’ WHERE Username ='$user' else Amount3 end ) , Amount2 = ( case when ( Amount1 is not null and Amount2 is null ) then ‘$amount’ WHERE Username ='$user' else Amount2 end ) , Amount1 = ( case when ( Amount1 is null ) then '$amount' else Amount1 WHERE Username ='$user' end ) "); I have no idea what is wrong, any help would be great!
×
×
  • 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.