Hi i have created a events script for my members to post there planned event all is working there but i want it where all members will see the events that other members have submitted in a list style like

My list of events :

Type: Meet at your place
When: 2015/01/09
Country/Region: East Midlands
Postcode: s433ds
Town: staveley
Title: This is a test please ignore
Description: THTHETRUJMDYJRASKJMDGTZHBTHNZDE
Looking to meet: Females, Males, CoupleTV/TS/CD

how can i do this any help would be great ty jan

Hi,

So what do you have so far? :-)

Do you mean loop the data you have in a view?

Here are the 3 files i have so far

This is the meetsform.html

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<script>         
            function textCounter(field, countfield, maxlimit) {
            if (field.value.length > maxlimit) // if too long...trim it!
            field.value = field.value.substring(0, maxlimit);
            // otherwise, update 'characters left' counter
            else 
            countfield.value = maxlimit - field.value.length;
            }                       
</script>
<body>
<form action="meet.php" name="input" method="post">

    <table width="400" border="0">
      <tbody>
        <tr>
          <td><label for="etype">Type:</label></td>
        </tr>
        <tr>
          <td>
              <select name="etype" required id="etype">
                <option value="">Choose meet type...</option>
                <option value="4">Meet at your place</option>
                <option value="5">Social meetup</option>
                <option value="6">Meet at our place</option>
                <option value="7">Dogging meet</option>
                <option value="8">Gangbang</option>
                <option value="9">Night out</option>
                <option value="10">Anything, anywhere</option>
                <option value="11">Hotel meet</option>
                <option value="12">Club meet</option>
              </select>
          </td>
        </tr>
        <tr>
          <td><label for="edate">When:</label></td>
        </tr>
        <tr>
          <td>
            <select name="edate" required id="edate">
                <option value="">Choose date...</option>
                <option value="2015/01/08">08 January 2015</option>
                <option value="2015/01/09">09 January 2015</option>
                <option value="2015/01/10">10 January 2015</option>
                <option value="2015/01/11">11 January 2015</option>
                <option value="2015/01/12">12 January 2015</option>
                <option value="2015/01/13">13 January 2015</option>
                <option value="2015/01/14">14 January 2015</option>
                <option value="2015/01/15">15 January 2015</option>
                <option value="2015/01/16">16 January 2015</option>
                <option value="2015/01/17">17 January 2015</option>
                <option value="2015/01/18">18 January 2015</option>
                <option value="2015/01/19">19 January 2015</option>
                <option value="2015/01/20">20 January 2015</option>
                <option value="2015/01/21">21 January 2015</option>
                <option value="2015/01/22">22 January 2015</option>
                <option value="2015/01/23">23 January 2015</option>
                <option value="2015/01/24">24 January 2015</option>
                <option value="2015/01/25">25 January 2015</option>
                <option value="2015/01/26">26 January 2015</option>
                <option value="2015/01/27">27 January 2015</option>
                <option value="2015/01/28">28 January 2015</option>
                <option value="2015/01/29">29 January 2015</option>
                <option value="2015/01/30">30 January 2015</option>
                <option value="2015/01/31">31 January 2015</option>
                <option value="2015/02/01">01 February 2015</option>
                <option value="2015/02/02">02 February 2015</option>
                <option value="2015/02/03">03 February 2015</option>
                <option value="2015/02/04">04 February 2015</option>
                <option value="2015/02/05">05 February 2015</option>
                <option value="2015/02/06">06 February 2015</option>
                <option value="2015/02/07">07 February 2015</option>
                <option value="2015/02/08">08 February 2015</option>
                <option value="2015/02/09">09 February 2015</option>
                <option value="2015/02/10">10 February 2015</option>
                <option value="2015/02/11">11 February 2015</option>
                <option value="2015/02/12">12 February 2015</option>
                <option value="2015/02/13">13 February 2015</option>
                <option value="2015/02/14">14 February 2015</option>
                <option value="2015/02/15">15 February 2015</option>
                <option value="2015/02/16">16 February 2015</option>
                <option value="2015/02/17">17 February 2015</option>
                <option value="2015/02/18">18 February 2015</option>
                <option value="2015/02/19">19 February 2015</option>
                <option value="2015/02/20">20 February 2015</option>
                <option value="2015/02/21">21 February 2015</option>
                <option value="2015/02/22">22 February 2015</option>
                <option value="2015/02/23">23 February 2015</option>
                <option value="2015/02/24">24 February 2015</option>
                <option value="2015/02/25">25 February 2015</option>
                <option value="2015/02/26">26 February 2015</option>
                <option value="2015/02/27">27 February 2015</option>
                <option value="2015/02/28">28 February 2015</option>
                <option value="2015/03/01">01 March 2015</option>
                <option value="2015/03/02">02 March 2015</option>
                <option value="2015/03/03">03 March 2015</option>
                <option value="2015/03/04">04 March 2015</option>
                <option value="2015/03/05">05 March 2015</option>
                <option value="2015/03/06">06 March 2015</option>
                <option value="2015/03/07">07 March 2015</option>
                <option value="2015/03/08">08 March 2015</option>
                <option value="2015/03/09">09 March 2015</option>
                <option value="2015/03/10">10 March 2015</option>
                <option value="2015/03/11">11 March 2015</option>
                <option value="2015/03/12">12 March 2015</option>
                <option value="2015/03/13">13 March 2015</option>
                <option value="2015/03/14">14 March 2015</option>
                <option value="2015/03/15">15 March 2015</option>
                <option value="2015/03/16">16 March 2015</option>
                <option value="2015/03/17">17 March 2015</option>
                <option value="2015/03/18">18 March 2015</option>
                <option value="2015/03/19">19 March 2015</option>
                <option value="2015/03/20">20 March 2015</option>
                <option value="2015/03/21">21 March 2015</option>
                <option value="2015/03/22">22 March 2015</option>
                <option value="2015/03/23">23 March 2015</option>
                <option value="2015/03/24">24 March 2015</option>
                <option value="2015/03/25">25 March 2015</option>
                <option value="2015/03/26">26 March 2015</option>
                <option value="2015/03/27">27 March 2015</option>
                <option value="2015/03/28">28 March 2015</option>
                <option value="2015/03/29">29 March 2015</option>
                <option value="2015/03/30">30 March 2015</option>
                <option value="2015/03/31">31 March 2015</option>
            </select>
          </td>
        </tr>
        <tr>
          <td><label for="region">Country/Region</label></td>
        </tr>
        <tr>
          <td>
              <select name="region" required id="region">
                <option value="0">Any</option>
                <option value="59">Channel Islands</option>
                <option selected value="60">East Midlands</option>
                <option value="61">Greater London</option>
                <option value="62">Isle of Man</option>
                <option value="63">North East</option>
                <option value="64">North West</option>
                <option value="65">Northern Ireland</option>
                <option value="66">Scotland</option>
                <option value="67">South East</option>
                <option value="68">South West</option>
                <option value="69">Wales</option>
                <option value="70">West Midlands</option>
              </select>
          </td>
        </tr>
        <tr>
          <td><label for="pcode">Postcode:</label></td>
        </tr>
        <tr>
          <td><input name="pcode" type="text" required id="pcode" size="10"></td>
        </tr>
        <tr>
          <td><label for="town">Town:</label></td>
        </tr>
        <tr>
          <td>
            <input name="town" required id="town" value="" size="40" maxlength="40">
            <input type="hidden" name="event_title" value="Meet">
          </td>
        </tr>
        <tr>
          <td><label for="title">Title</label></td>
        </tr>
        <tr>
          <td><input name="title" required id="title" value="" size="60" maxlength="40"><input type="hidden" name="event_title" value="Meet"></td>
        </tr>
        <tr>
          <td><label for="advert">Description (160 characters max):</label></td>
        </tr>
        <tr>
          <td>
            <textarea id="advert" name="advert" rows="3" cols="47" onKeyDown="textCounter(this.form.advert,this.form.remLen,160);" onKeyUp="textCounter(this.form.advert,this.form.remLen,160);">
            </textarea>
            <input readonly type="text" name="remLen" size="3" maxlength="3" value="160">
            </div><div class="field">
          </td>
        </tr>
        <tr>
          <td><label for="ltm">Looking to meet:</label></td>
        </tr>
        <tr>
          <td>
              <input type="checkbox" id="ltmF" name="ltmF" value="1"><label for="ltm">Females</label>
              <br/>          
              <input type="checkbox" id="ltmM" name="ltmM" value="1"><label for="ltm">Males</label>          
              <br/>                    
              <input type="checkbox" id="ltmC" name="ltmC" value="1"><label for="ltm">Couple</label>
              <br/>
              <input type="checkbox" id="ltmT" name="ltmT" value="1"><label for="ltm">TV/TS/CD</label>
              <br/>
           </td>
        </tr>
        <tr>
          <td><input type="submit" name=onclick="return doMeetFormValidation();" value="Add Meet"></td>
        </tr>
      </tbody>
    </table>
</form>
</body>
</html>

now we have the meet.php


<?php 

include("config/db_connect.php");

// Check user id
if($_SESSION['userid'] == "")
{
    header('Location: logcom.php');
}else{
    // it's ok
}

$userid = $_SESSION['userid'];

$etypeValues = array(
"4" => "Meet at your place",
"5" => "Social meetup",
"6" => "Meet at our place",
"7" => "Dogging meet",
"8" => "Gangbang",
"9" => "Night out",
"10" => "Anything, anywhere",
"11" => "Hotel meet",
"12" => "Club meet" 
);

$etype_key = get_data_from_post('etype');
$etype = $etypeValues[$etype_key];

$edate = get_data_from_post('edate'); 

$regionValues = array(
"59" => "Channel Islands",
"60" => "East Midlands",
"61" => "Greater London",
"62" => "Isle of Man",
"63" => "North East",
"64" => "North West",
"65" => "Northern Ireland",
"66" => "Scotland",
"67" => "South East",
"68" => "South West",
"69" => "Wales",
"70" => "West Midlands",
);

$region_key = get_data_from_post('region');
$region = $regionValues[$region_key];

$pcode = get_data_from_post('pcode');

$town = get_data_from_post('town');

$title = get_data_from_post('title');

$advert = get_data_from_post('advert');

$ltm = get_ltm_data_from_post() ;

/*
echo $userid . '<br/>';
echo $etype . '<br/>';
echo $edate . '<br/>';
echo $region . '<br/>';
echo $pcode . '<br/>';
echo $town . '<br/>';
echo $title . '<br/>';
echo $advert . '<br/>';
echo $ltm . '<br/>';
*/

$query = 'insert into events set etype = "'.$etype.'", edate = "'.$edate.'", region = "' .$region.'", pcode = "'.$pcode.'", town = "'.$town.'", title = "'.$title.'", advert ="' .$advert.'", ltm ="' .$ltm. '", user_id =' . $userid  ;

//echo $query ;

$insert = mysql_query ( $query ) or die(mysql_error()) ;

if($insert)
{
    //echo "added" ;
    header("location: addedmeets.php");
    exit;   
}


function prepare_insert($data) {
    $data = trim ( $data );
    if (get_magic_quotes_gpc ())
        $data = stripslashes ( $data );

    return mysql_escape_string ( $data );
}

function prepare_show($data) {
    $data = stripslashes ( $data );
    $data = htmlspecialchars ( $data, ENT_QUOTES );
    return nl2br ( $data );
}

function get_data_from_post($key){
    if (null !== $_POST[$key] && $_POST[$key]){
        return prepare_insert($_POST[$key]);
    }
    return "";
}

function get_ltm_data_from_post(){
    $ltm = "" ;
    if(isset($_POST['ltmF'])){
        if( $_POST['ltmF'] == 1) $ltm .= "Females, ";
    }
    if(isset($_POST['ltmM'])){
        if( $_POST['ltmM'] == 1) $ltm .= "Males, ";
    }
    if(isset($_POST['ltmC'])){
        if( $_POST['ltmC'] == 1) $ltm .= "Couple";
    }
    if(isset($_POST['ltmT'])){
        if( $_POST['ltmT'] == 1) $ltm .= "TV/TS/CD";
    }

    if (substr($ltm, -1) == ','){
        $ltm = substr($ltm, 0, strlen($ltm)-1);
    }else if (substr($ltm, -2) == ', '){
        $ltm = substr($ltm, 0, strlen($ltm)-2);
    }

    return $ltm ;
}

/*
foreach ($_POST as $key => $value) {
    echo '<p>'.$key.'</p>';
    echo '<p>'.$value.'</p>';
} 
*/
?>

and finally we have the addedmeets.php

<?php
include("config/db_connect.php");

// Check user id
if($_SESSION['userid'] == "")
{
    header('Location: logcom.php');
}else{
    // it's ok
}
$userid = $_SESSION['userid'] ;

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>

<?php

$query = "select * from user where user_id =" . $userid;
$userinfomfm = mysql_fetch_array(mysql_query($query));
$username = $userinfomfm['user_name'];
echo 'Username : ' . $username . '<br/>';


$user_image = mysql_query("select * from user_images where user_id = ".$userid." and main_image = '1' ");
$fetch_image = mysql_fetch_array($user_image);

if($fetch_image['user_image']!='') {
       echo '<img  src="images/user_images/' . $fetch_image['user_image'] .'"height="100px;" width="100px;"/><br/>';
}else { 
      echo '<img  src="images/blank_big.jpg" height="100px;" width="100px;"/><br/>';
} 

echo '<br/> My list of events : <br/><br/>';

$query = "select * from events where user_id =" . $userid ;

$data = mysql_query($query);

    if(mysql_num_rows($data)>0)
    {
        while($row = mysql_fetch_array($data)) 
        {
            $etype = $row['etype'];
            $edate = $row['edate'];
            $region = $row['region'];
            $pcode = $row['pcode'];
            $town = $row['town'];
            $title = $row['title'];
            $advert = $row['advert'];
            $ltm = $row['ltm'];

            echo '<b>Type:</b> '. $etype .'</br>';
            echo '<b>When:</b> '. $edate .'</br>';
            echo '<b>Country/Region:</b> '. $region .'</br>';
            echo '<b>Postcode:</b> '. $pcode .'</br>';
            echo '<b>Town:</b> '. $town  .'</br>';
            echo '<b>Title:</b> '. $title .'</br>';
            echo '<b>Description:</b> '. $advert .'</br>';
            echo '<b>Looking to meet:</b> '. $ltm .'</br>';

            echo '<hr>';

        }
    }

?>


</body>
</html>

I suppose you already have the data from a database, and need to echo the events out?

$events = 'Your db result array';

foreach( $events as $event )
{
    echo 'Type:' . $event['type'] . '<br />';
    echo 'When:' . $event['when'] . '<br />';
    echo 'Country/Region:' . $event['country_region'] . '<br />';
    echo 'Town:' . $event['town'] . '<br />';
    echo 'Title:' . $event['title'] . '<br />';
    echo 'Description:' . $event['description'] . '<br />';
    echo 'Looking to meet:' . $event['looking_to_meet'];

    # Etc etc
}

Give som more details, if this is misunderstood..

yes i have the database table setup and all info is going to database and is echoing to a page that only shows my event not anybody elses

Do you get any errors? :-)

in addedmeets.php you can leave out a few lines if you dont use the variables later on:

$etype = $row['etype'];
$edate = $row['edate'];
$region = $row['region'];
$pcode = $row['pcode'];
$town = $row['town'];
$title = $row['title'];
$advert = $row['advert'];
$ltm = $row['ltm'];
echo '<b>Type:</b> '. $etype .'</br>';
echo '<b>When:</b> '. $edate .'</br>';
echo '<b>Country/Region:</b> '. $region .'</br>';
echo '<b>Postcode:</b> '. $pcode .'</br>';
echo '<b>Town:</b> '. $town .'</br>';
echo '<b>Title:</b> '. $title .'</br>';
echo '<b>Description:</b> '. $advert .'</br>';
echo '<b>Looking to meet:</b> '. $ltm .'</br>';

To

echo '<b>Type:</b> '. $row['etype'] .'</br>';
echo '<b>When:</b> '. $row['edate'] .'</br>';
echo '<b>Country/Region:</b> '. $row['region'] .'</br>';
echo '<b>Postcode:</b> '. $row['pcode'] .'</br>';
echo '<b>Town:</b> '. $row['town'] .'</br>';
echo '<b>Title:</b> '. $row['title'] .'</br>';
echo '<b>Description:</b> '. $row['advert'] .'</br>';
echo '<b>Looking to meet:</b> '. $row['ltm'] .'</br>';

Looks like you are only querying your own events on line 41?

EDIT EDIT EDIT

$query = "select * from events where user_id =" . $userid;

To

$query = "select * from events;

Is that working for you?

after changing those to lines im getting the following error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/letsswin/public_html/addedmeets.php on line 26

Sorry, I just edited the answer from before.

I think it is on line 41, you have to change your query, and leave out the user_id.

$query = "select * from events;

And leave the rest as it was before :-)

$query = "select * from user where user_id =" . $userid;

sorted that now im getting
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/letsswin/public_html/addedmeets.php on line 50

<?php
include("config/db_connect.php");

// Check user id
if($_SESSION['userid'] == "")
{
    header('Location: logcom.php');
}else{
    // it's ok
}
$userid = $_SESSION['userid'] ;

?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>

<?php

        $query = "select * from user where user_id =" . $userid;
$userinfomfm = mysql_fetch_array(mysql_query($query));
$username = $userinfomfm['user_name'];
echo 'Username : ' . $username . '<br/>';


$user_image = mysql_query("select * from user_images where user_id = ".$userid." and main_image = '1' ");
$fetch_image = mysql_fetch_array($user_image);

if($fetch_image['user_image']!='') {
       echo '<img  src="images/user_images/' . $fetch_image['user_image'] .'"height="100px;" width="100px;"/><br/>';
}else { 
      echo '<img  src="images/blank_big.jpg" height="100px;" width="100px;"/><br/>';
} 

echo '<br/> My list of events : <br/><br/>';

$query = "select * from events;


$data = mysql_query($query);

    if(mysql_num_rows($data)>0)
    {
        while($row = mysql_fetch_array($data)) 
        {
            $etype = $row['etype'];
            $edate = $row['edate'];
            $region = $row['region'];
            $pcode = $row['pcode'];
            $town = $row['town'];
            $title = $row['title'];
            $advert = $row['advert'];
            $ltm = $row['ltm'];

            echo '<b>Type:</b> '. $etype .'</br>';
            echo '<b>When:</b> '. $edate .'</br>';
            echo '<b>Country/Region:</b> '. $region .'</br>';
            echo '<b>Postcode:</b> '. $pcode .'</br>';
            echo '<b>Town:</b> '. $town  .'</br>';
            echo '<b>Title:</b> '. $title .'</br>';
            echo '<b>Description:</b> '. $advert .'</br>';
            echo '<b>Looking to meet:</b> '. $ltm .'</br>';

            echo '<hr>';

        }
    }

?>


</body>
</html>

Emphasized Text Here

Line 41 is missing "

$query = "select * from events;

To

$query = "select * from events";

Did you get all the events displayed? :-)

thankyou hun all sorted x

thankyou all for your help in this matter x x x

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.