Dynamic links using PHP and MySQL in a loop -
i'm learning php , mysql self-project , apparently got stuck. site trying make includes submitting forms , reviewing them. i've managed create loop in order display forms have been submitted , not yet processed (therefore, prone review), , each form has own link redirects data said form includes.
$query = mysqli_query ( $conn, "select * members username = '$myrealusername' limit 1" ); $result = $query->fetch_assoc (); $id = $result ['id']; echo 'welcome ' . $id . '. <br>'; $quer = mysqli_query ( $conn, "select count(*) total carforms aboveid='$id' , processed='0'" ); $data = $quer->fetch_assoc (); $total = $data ['total']; $quer = mysqli_query ( $conn, "select fullname currentname, formid currentform carforms aboveid='$id' , processed='0'" ); ($x=1; $x<=$total; $x++) { $data = $quer->fetch_assoc (); $forms = $data ['currentname']; $forma = $data ['currentform']; echo 'form no.'. $forma .' by: ' .$forms .'<a href="reviewform.php">click here review</a>.<br>'; } ?>
and shows:
welcome 2. form no.1 by: john miller click here review. form no.2 by: john miller click here review. form no.3 by: mike tywell click here review. form no.4 by: john miller click here review. form no.5 by: eric paton click here review.
the problem is, have no idea how pass different data every link shown mysql carform table includes data such car type, car colour etc. , different each person.
thanks in advance.
you need add query string e.g
echo 'form no.'. $forma .' by: ' .$forms .'<a href="reviewform.php?id='.$row['id'].'">click here review</a>.<br>';
fyi can make lot simpler
$query = mysqli_query ( $conn, "select * members username = '$myrealusername' limit 1" ); $result = $query->fetch_assoc (); $id = $result ['id']; echo 'welcome ' . $id . '. <br>'; $quer = mysqli_query ( $conn, "select id,fullname currentname, formid currentform carforms aboveid='$id' , processed='0'" ); while($data= mysqli_fetch_array($quer)) { $forms = $data ['currentname']; $forma = $data ['currentform']; echo 'form no.'. $forma .' by: ' .$forms .'<a href="reviewform.php?id='.$data['id'].'">click here review</a>.<br>'; } ?>
or that.
Comments
Post a Comment