Gravity Forms file upload query

<?php

//Connect to Database
$gravity_post_id = get_the_ID();

$dbc = mysqli_connect('localhost','dankuniv_wp02','H0fx81McyP','dankuniv_wp02')
or die('Error connecting to Database');

//This query gets the secondary ID
$query = "SELECT id
FROM wp_rg_lead
WHERE post_id = $gravity_post_id
LIMIT 0 , 30";

$result = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($result);

//The secondary ID from above
$secondary_id = $row[0];

if ($row[0] != ''){

//This query grabs the file URL
$query2 = "SELECT value
FROM wp_rg_lead_detail
WHERE lead_id = $secondary_id
AND field_number = 3
LIMIT 0 , 200";

$result2 = mysqli_query($dbc, $query2);
$row2 = mysqli_fetch_array($result2);

//Create Source file link:
if ($row2[0] == ''){
//Empty field - exit conditional;
}
else {
echo '<a href="' . $row2[0] . '"><img src="/graphics/download_source.png" /></a>';
}
}

//Close the Connection
mysqli_close($dbc);

?>

0 Comments

You must be logged in to post a comment.