Jump to content

echo results


Rother2005

Recommended Posts

hi im trying to do a search within my db and display the result any help?

[code]<?php
include('connect1.inc');?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Booze Cruise Reg</title>

</head>
<body>

<?php
if(!$_POST['register']){echo'<p align="center"><strong>Member Registration</strong></p>
<form name="form1" method="POST" action="">
<p align="center">Username:  <input type="text" name="username" maxlength="10"></p>
<p align="center"><input type="submit" name="register" value="Enter Details"></p></form>';}
//27
else{
//checks if user has input text

if(isset($_POST['username']) && !empty($_POST['username']))
{
    // valid
$username = $_POST['username'];
}
else
{
    // not valid
die ("No Username Input");
}

$sql = "SELECT * FROM MEMBER,NEWSLETTER WHERE MEMBER.Username='$username' = NEWSLETTER.Username='$username'";

mysql_query($sql)             

or die(mysql_error());
//50
echo ($sql);}
?>
</body>
</html>[/code]
Link to comment
https://forums.phpfreaks.com/topic/34333-echo-results/
Share on other sites

rite ive got the form showing but even when i put the right data in (e.g. a user that is in the db) its showing the error msg

[code]<?php

$conn=mysql_connect("localhost","root","");

if (!$conn) {
  echo "Unable to connect to DB: " . mysql_error();
  exit;
}
 
if (!mysql_select_db("booze")) {
  echo "Unable to select booze: " . mysql_error();
  exit;
}

if(!$_POST['register']){echo'<p align="center"><strong>check Newsletter Reg</strong></p>
<form name="form1" method="POST" action="">
<p align="center">Username:  <input type="text" name="username" maxlength="10"></p>
<p align="center"><input type="submit" name="register" value="Enter Details"></p></form>';}
//16
else{

$sql = "SELECT * FROM MEMBER,NEWSLETTER WHERE MEMBER.Username='$username' = NEWSLETTER.Username='$username'";

$result = mysql_query($sql);

if (!$result) {
  echo "Could not successfully run query ($sql) from DB: " . mysql_error();
  exit;
}

if (mysql_num_rows($result) == 0) {
  echo "No rows found, nothing to print so am exiting";
  exit;
}

// While a row of data exists, put that row in $row as an associative array
while ($row = mysql_fetch_assoc($result)) {
  echo $row["username"];
  echo $row["email"];
}

mysql_free_result($result);
}

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34333-echo-results/#findComment-161588
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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