PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Dec 19, 2018 1:39 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: PHP MYSQL Errir
PostPosted: Fri Feb 13, 2015 8:42 pm 
Offline
Forum Newbie

Joined: Fri Feb 13, 2015 8:38 pm
Posts: 1
I am trying to make it so that it displays a table with the data from the one table on the first bunch of columns but on the last colum it is supposed to take the event id and see how many times it appears in the signup tree with the status set to yes:

Hello I have this code :

Syntax: [ Download ] [ Hide ]
<?php
$con=mysqli_connect("login info here");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT events.*, signup.status FROM events, signup ");

//$result = mysqli_query($con,"SELECT events.*, signup.status FROM events, signup ");

echo "<table class='TFtable'><tr><td>Name</td><td>Event ID</td><td>Location</td><td>Time / Date</td><td>Lead</td><td># Needed</td><td>Complete?</td><td>Materials</td><td>Teacher</td><td>Duration</td><td>Summary</td><td>Signed Up</td></tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['eventname'] . "</td>";
echo "<td>" . $row['eventid'] . "</td>";
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>" . $row['lead'] . "</td>";
echo "<td>" . $row['need'] . "</td>";
echo "<td>" . $row['complete'] . "</td>";
echo "<td>" . $row['materials'] . "</td>";
echo "<td>" . $row['teacher'] . "</td>";
echo "<td>" . $row['duration'] . "</td>";
echo "<td>" . $row['eventsummary'] . "</td>";
$row1 = mysqli_fetch_array(SELECT COUNT(status) FROM signup WHERE eventid='$row['eventid']' and status='yes';)

echo "<td>" . $row1 . "</td>";

}

echo "</tr>";
echo "</table>";
echo "<br><br><br><br>";
mysqli_close($con);
?>


And I'm getting this error:

Parse error: syntax error, unexpected 'COUNT' (T_STRING) in /home/howto570/public_html/dmcisc/home/index.php on line 55

Line 55 is:

$row1 = mysqli_fetch_array(SELECT COUNT(status) FROM signup WHERE eventid='$row['eventid']' and status='yes';)


Thanks


Top
 Profile  
 
 Post subject: Re: PHP MYSQL Errir
PostPosted: Fri Feb 13, 2015 9:05 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
This is actually a PHP problem: you didn't put quotes around your query.

Did you not notice that or were you not aware you have to use quotes in PHP?


Top
 Profile  
 
 Post subject: Re: PHP MYSQL Errir
PostPosted: Sat Feb 14, 2015 7:21 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6424
Location: Montreal, Canada
Also, that query is passed as a parameter to mysqli_fetch_array instead of mysqli_query.

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group