Jump to content

Select Statement


Go to solution Solved by ginerjm,

Recommended Posts

Wonder if someone can give me a hand. My select statement is working on command line, but not in PHP.

SELECT id,DAY(date),MONTH(date),title,location,address,timestart,timeend,ticketprice,buynowaddress FROM Events WHERE active = true ORDER BY date DESC

But when I put it into PHP, I get an error: 

Notice: Undefined index: date in /var/www/html/site.com/evets.php on line 9

Here is the PHP:

<?php
include("dbconnect.php");

$result = mysql_query("SELECT id,DAY(date),MONTH(date),title,location,address,timestart,timeend,ticketprice,buynowaddress FROM Events WHERE active = true OR$

while ($row = mysql_fetch_array($result)) {
        echo "<p>ID: " .$row['id'] ."<br>";
        echo "Title: " .$row['title'] ."<br>";
        echo "Date: " .$row['date'] ."<br>";
        echo "Location: " .$row['location'] ."<br>";
        echo "Address: " .$row['address'] ."<br>";
        echo "Time Start: " .$row['timestart'] ."<br>";
        echo "Time End: " .$row['timeend'] ."<br>";
        echo "Ticket Price: " .$row['ticketprice'] ."<br>";
        echo 'Buy Ticket Link: <a href="' .$row['buynowaddress'] .'">address</a><br></p>';
        echo "<hr>";
}



?>

Thank you all in advance

Edited by -envious
Link to comment
https://forums.phpfreaks.com/topic/298137-select-statement/
Share on other sites

  • Solution

How about "DAY(date) as date_dd" and "MONTH(date) as date_mm" and then use date_dd and date_mm as your indices into $row?

 

AND definitely change your code to stop using MySQL_* functions. They are going out of PHP soon.

Link to comment
https://forums.phpfreaks.com/topic/298137-select-statement/#findComment-1520686
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.