Re: cross join check syntax please
Posted by:
John carey
Date: April 24, 2022 01:34PM
<!DOCTYPE html>
<html>
<head>
<title>mygallery</title>
</head>
<body bgcolor=lightyellow>
<div>
<font face="comic sans ms" size=6>Add To Gallery</font><br>
<form method="POST">
<table width="100%" bgcolor=lightblue border=1>
<tr>
<td width="35%" valign='top'>
<!-- <label><font face="courier"><b>id: </b></font> <input type="text" name="id" readonly></label><br>-->
<label><font face="courier"><b>Refnbr: </b></font><input type="text" name="refnbr" size=11 readonly> </label><br>
<label><font face="courier"><b>Custid: </b></font><input type="text" name="custid" required="required" size=15></label><br>
<label><font face="courier"><b>Pseudo: </b></font><input type="text" name="pseudo"></label><br>
<label><font face="courier"><b>Musician: </b></font><input type="text" name="musician"></label><br>
<label><font face="courier"><b>Nickname: </b></font><input type="text" name="nickname"></label><br>
<label><font face="courier"><b>Group1: </b></font><input type="text" name="group1"></label><br>
<label><font face="courier"><b>Description:</b></font><input type="text" name="description"></label><br>
<label><font face="courier"><b>Date Added: </b></font><input type="date" name="date"></label><br>
<label><font face="courier"><b>Status: </b></font><input type="text" name="status" size=8</label> <font color=yellow>trading/selling/pending/wanting</font><br>
<label><font face="courier"><b>Price: </b></font><input type="text" name="price"></label><br>
<label><font face="courier"><b>Picture: </b></font><input type="text" name="picture" required="required" placeholder=" .jgp .gif .png"></label> <font color=yellow>*</font><br>
<label><font face="courier"><b>Email: </b></font><input type="text" name="email" required="required"></label><br>
<!-- <label><font face="courier"><b>Securitycode: </b></font><input type="text" name="securitycode" required="required" readonly></label><br> -->
<!--<input type="submit" value="MySQLi Object-oriented" name="mysqli_oop">-->
<!--<input type="submit" value="MySQLi Procedural" name="mysqli_procedural">-->
<input type="submit" value=" Add " name="pdo"> <b><font color=yellow>*</font></b>Required
</form>
</td>
<td width="25%" valign="bottom">
<?php
if(isset($_REQUEST['submit']))
{
$filename= $_FILES["imgfile"]["name"];
if ((($_FILES["imgfile"]["type"] == "image/gif")|| ($_FILES["imgfile"]["type"] == "image/jpeg") || ($_FILES["imgfile"]["type"] == "image/png") || ($_FILES["imgfile"]["type"] == "image/pjpeg")) && ($_FILES["imgfile"]["size"] < 200000))
{
if(file_exists($_FILES["imgfile"]["name"]))
{
echo "File name exists.";
}
else
{
move_uploaded_file($_FILES["imgfile"]["tmp_name"],"uploads/$filename");
echo "<center><img src='uploads/$filename' width='40%' height='45%'></center>";
echo "Upload Successful . <a href='uploads/$filename'>Click here</a> to view the uploaded image";
}
}
else
{
echo "invalid file.";
}
}
else
{
?>
<form method="post" enctype="multipart/form-data">
Picture File Name:<input type="file" name="imgfile"><br>
<input type="submit" name="submit" value="upload">
</form>
<?php
}
?>
</td>
<td width="40%" bgcolor="lightyellow">
</td>
</tr>
</table>
<?php
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//MySQLi Object-oriented
if (isset($_POST['mysqli_oop'])){
}
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//MySQLi Procedural
elseif (isset($_POST['mysqli_procedural'])){
}
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hhhhhhhhhhhhhhh
//PDO
elseif (isset($_POST['pdo'])){
$servername = "db5005980166.hosting-data.io";
$username = "dbu1511040";
$password = "myAcct1^db";
$dbname = "dbs5009628";
try {
$con = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// $id=$_POST['id'];
$refnbr=$_POST['refnbr'];
$custid=$_POST['custid'];
$pseudo=$_POST['pseudo'];
$musician=$_POST['musician'];
$nickname=$_POST['nickname'];
$group1=$_POST['group1'];
$description=$_POST['description'];
$date=$_POST['date'];
$status=$_POST['status'];
$price=$_POST['price'];
$picture=$_POST['picture'];
$email=$_POST['email'];
$custid1=$_POST['custid1'];
// $securitycode=$_POST['securitycode'];
// if ($securitycode = "2"){
//$refnbr1 = 20000003;
//$refnbr = (++$refnbr);
$nameid=$custid;
// if ($email == "check"){
$sql = "insert into mygallery(refnbr,custid,pseudo,musician,nickname,group1,description,date,status,price,picture,email,custid1)
values('$refnbr','$custid','$pseudo','$musician','$nickname','$group1','$description','$date','$status','$price','$picture','$email','$custid1')";
// }
//$refnbr=(++$refnbr);
//}else{
//echo "hello";
//}
// use exec() because no results are returned
$con->exec($sql);
echo "New record created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$con = null;
}
?>
<!-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->
</div>
<br>
<div>
<table border="1" bgcolor=tan>
<thead>
<th bgcolor=lightblue>Refnbr</th>
<th bgcolor=lightblue>Custid</th>
<th bgcolor=lightblue>Pseudo</th>
<th bgcolor=lightblue>Musician</th>
<th bgcolor=lightblue>Nickname</th>
<th bgcolor=lightblue>Group1</th>
<th bgcolor=lightblue>Description</th>
<th bgcolor=lightblue>Date Added</th>
<th bgcolor=lightblue>Status</th>
<th bgcolor=lightblue>Price</th>
<th bgcolor=lightblue>Picture</th>
<th bgcolor=lightblue>email</th>
<th bgcolor=lightblue>custid1</th>
<!-- <th bgcolor=lightblue>securitycode</th> -->
</thead>
<tbody>
<?php
$servername = "db5005980166.hosting-data.io";
$username = "dbu1511040";
$password = "myAcct1^db";
$dbname = "dbs5009628";
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$con = mysqli_connect("db5005980166.hosting-data.io","dbu1511040","myAcct1^db","dbs5009628");
// xxxxxxxxxxxxx
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
/*
$query=mysqli_query($con,"select * from mygallery
CROSS JOIN subscribe
where mygallery.custid = subscribe.custid1
order by mygallery.refnbr desc");
*/
$query=mysqli_query($con,"select * from mygallery
CROSS JOIN subscribe
where mygallery.custid = subscribe.custid1
order by mygallery.refnbr desc");
while($row=mysqli_fetch_array($query)){
?>
<tr>
<td><?php echo $row['refnbr']; ?></td>
<td><?php echo $row['custid']; ?></td>
<td><?php echo $row['pseudo']; ?></td>
<td><?php echo $row['musician']; ?></td>
<td><?php echo $row['nickname']; ?></td>
<td><?php echo $row['group1']; ?></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['price']; ?></td>
<td><?php echo $row['picture']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['custid1']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</body>
</html>