Jump to content

Need help with php / mysql wether to display or not


Recommended Posts

here are the tables and fields in my mysql dataabse sex1800_loginbux

 

- = table

* = field

 

- completed_surveys

*member_id  <-- When user Completes a Survey their member_id is added

*survey_id <-- When user Completes a the Survey id Goes Here

 

- survey

*id <-- This Is The Survey ID

*title <-- This is the Survey title used in displaying Survey

*adlink <-- This is the Survey Ad Link Used in displaying Survey

 

- users

*userid <-- This is Where the Users Id is Stored

 

==================================

 

How would i make it so when php displays the surveys in the table survey

 

to not show ones that are in the survey_completed table

 

 

Hope I have explained this well enough for everyone to understand

 

 

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Table 'sex1800_loginbux.surveys' doesn't exist

 

was it trying to open the table survey not surveys

 

Heres The Code:

 

<?php
mysql_connect("localhost", "sex1800_admin", "Password") or die(mysql_error()); //add you password
mysql_select_db("sex1800_loginbux") or die(mysql_error());

$query = "SELECT s.* FROM completed_surveys cs, surveys s WHERE cs.id != s.survey_id";
$result = mysql_query($query) or die(mysql_error());
echo mysql_num_rows($result);


die();
while($row = mysql_fetch_array($result)){
echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>";
}
?>

CREATE TABLE `sex1800_loginbux`.`surveys` (

`id` INT NOT NULL AUTO_INCREMENT ,

`title` VARCHAR( 32 ) NOT NULL ,

`adlink` VARCHAR( 32 ) NOT NULL ,

PRIMARY KEY ( `id` )

) ENGINE = MYISAM

 

CREATE TABLE `sex1800_loginbux`.`completed_surveys` (

`member_id` VARCHAR( 32 ) NOT NULL ,

`survey_id` NOT NULL AUTO_INCREMENT ,

) ENGINE = MYISAM

No I mean, where did you set it up? When you created your tables, that's the code, but how did you give the db that code? From a command line? Through phpmyadmin or some other interface?  by using mysql_query in a php script?

select your survey table from the list of tables, and at the top where it says

 

    * Browse    * Structure    * SQL    * Search    * Insert    * Export    * Import    * Operations    * Empty    * Drop

 

click the SQL tab.

 

There should be a huge textarea box labeled "Run SQL query/queries on database <database name>:

 

Put the query string in it and on the bottom right, click the "Go" button.

it needs to go by user if i create a new user then visit the home page still displays 0

 

http://epicbux.com/

 

you can log in with this account i just made

 

user: demo1

pass: demo1

 

=====================

Is it possible to do what i want it to do ...

 

Well it must be possible because thats what other survey sites do

 

if their is another way to do what i want it to do please let me know

their is also another page called addsurvey.php

 

heres the codes:

 

<?php
include("include/session.php");
?>

<?php



if (isset($_POST['action'])) {

mysql_connect("localhost", "sex1800_admin", "PASSWORD") or die(mysql_error());
mysql_select_db("sex1800_loginbux") or die(mysql_error());

$title = mysql_real_escape_string($_POST['title']);
$link = mysql_real_escape_string($_POST['link']);

mysql_query("INSERT INTO survey 
(title, adlink) VALUES('$title', '$link') ") 
or die(mysql_error());  

echo "Survey Added!";

}

?>


<html>
<head>
</head>
<title> Add a Survey </title>
<center>
<?php 

if($session->isAdmin()){

?>



<table border="1">
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<tr>
<td>Survey Title: <input type="text" name="title"><br>Ad Link: <input type="text" name="link"></td>
</tr>
<tr>
<td><input type="submit" name="action" value="Add Survey"></td>
<input type='hidden' name='submitted' value='yes'>
</tr>
</form>
</table>



<?php
} else {

echo 'You Must Be An Administrator to add a Survey';

}

?>

 

 

 

ok i tried running

 

select id, title, adlink from survey where id not in (select survey_id from completed_surveys)

 

in

 

this but now it just displays the number 4

 

<?php
mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password
mysql_select_db("sex1800_loginbux") or die(mysql_error());

$query = "select id, title, adlink from survey where id not in (select survey_id from completed_surveys)";
$result = mysql_query($query) or die(mysql_error());
echo mysql_num_rows($result);


die();
while($row = mysql_fetch_array($result)){
echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>";
}
?>

 

it needs to actually display survey like this

 

<?php
echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>";
}
?>

 

 

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.